From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1USOGY-0008HQ-MY for mharc-grub-devel@gnu.org; Wed, 17 Apr 2013 05:02:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:56127) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USOGT-0008CU-0i for grub-devel@gnu.org; Wed, 17 Apr 2013 05:02:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1USOGO-0002xe-RQ for grub-devel@gnu.org; Wed, 17 Apr 2013 05:02:52 -0400 Received: from collab.rosalab.ru ([217.199.216.181]:37524) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1USOGO-0002xN-Gi for grub-devel@gnu.org; Wed, 17 Apr 2013 05:02:48 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by collab.rosalab.ru (Postfix) with ESMTP id D49FD29C286; Wed, 17 Apr 2013 13:02:46 +0400 (MSK) X-Virus-Scanned: amavisd-new at rosalab.ru Received: from collab.rosalab.ru ([127.0.0.1]) by localhost (collab.rosalab.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id d2zbPpncr1mE; Wed, 17 Apr 2013 13:02:44 +0400 (MSK) Received: from icedphoenix.localnet (unknown [10.168.1.56]) by collab.rosalab.ru (Postfix) with ESMTPSA id 7AC7429C284; Wed, 17 Apr 2013 13:02:44 +0400 (MSK) From: Vladimir Testov To: grub-devel@gnu.org Subject: Re: [PATCH] multistring support in gui_label Date: Wed, 17 Apr 2013 13:02:44 +0400 Message-ID: <21349117.1Nj3dUL9Cm@icedphoenix> User-Agent: KMail/4.9.5 (Linux/3.5.0-26-generic; KDE/4.9.5; x86_64; ; ) In-Reply-To: <516E48DB.8070506@gmail.com> References: <1720724.fd4NVO69U8@icedphoenix> <516E48DB.8070506@gmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart75901818.hG6jyt70gf" Content-Transfer-Encoding: 7Bit X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 217.199.216.181 Cc: Vladimir =?utf-8?B?J8+GLWNvZGVyL3BoY29kZXIn?= Serbinenko X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Apr 2013 09:02:57 -0000 This is a multi-part message in MIME format. --nextPart75901818.hG6jyt70gf Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Wednesday, April 17, 2013 09:01:47 AM Vladimir '=CF=86-coder/phcoder= ' Serbinenko=20 wrote: > Don't write any line-breaking at all yourself. I did not write any line-breaking. It is existing line-breaking. And it= have=20 one algorithmic problem. Do not see any problem if I will fix the probl= em. The problem persists when we have some long word which cannot be printe= d=20 entirely on one line... > > 2) There is funny handling of UTF-8 symbols. Each symbol have > > "device_width" parameter, > > which is used in calculation of string's length. >=20 > Where is it used? Show exactly. It must be some leftover code. > We don't do any kerning. No need to change algorithm. O.k. Here it is. from grub-core/font/font.c line 1387 function blit_comb : > do_blit (combining_glyphs[i], > main_glyph->device_width > + combining_glyphs[i]->offset_x, > -(combining_glyphs[i]->height > + combining_glyphs[i]->offset_y), &ctx); > add_device_width (combining_glyphs[i]->device_width, &ctx)= ; > } > } > } > add_device_width ((above_rightx > > below_rightx ? above_rightx : below_rightx) - > (main_glyph->offset_x + main_glyph->width), &ctx);= > add_device_width (above_leftx - main_glyph->offset_x, &ctx); > if (glyph && glyph->device_width < min_devwidth) > glyph->device_width =3D min_devwidth; > if (device_width && *device_width < min_devwidth) > *device_width =3D min_devwidth; ***device_width is changed sometimes. from grub-core/font/font.c line 1458 function grub_font_construct_dry_= run : > if (device_width) > *device_width =3D main_glyph->device_width; > > if (!glyph_id->ncomb && !glyph_id->attributes) > return main_glyph; > > combining_glyphs =3D grub_malloc (sizeof (combining_glyphs[0]) > * glyph_id->ncomb); > if (glyph_id->ncomb && !combining_glyphs) > { > grub_errno =3D GRUB_ERR_NONE; > return main_glyph; > } > > for (i =3D 0; i < glyph_id->ncomb; i++) > combining_glyphs[i] > =3D grub_font_get_glyph_with_fallback (main_glyph->font, > glyph_id->combining[i].code= ); > > blit_comb (glyph_id, NULL, bounds, main_glyph, combining_glyphs, > device_width); > if (combining_glyphs_out) > *combining_glyphs_out =3D combining_glyphs; > else > grub_free (combining_glyphs); > > return main_glyph; ***return value *device_width set to main_glyph->device_width before=20= main_glyph->device_width is changed during execution of blit_comb If we want to get device_width of some glyph - we use function=20 get_constructed_device_width. It returns device_width parameter of the = asked=20 glyph with parameter *device_width of the function=20 grub_font_construct_dry_run. When we actually construct glyph, we take device_width from glyph- >device_width. The most adequate way to find device_width of grub_unicode_glyph is to = call=20 grub_font_get_constructed_device_width. But it is miscalculated in some= cases. So these two values are different in some cases (This is all about prob= lem 2) Suggested patch to fix this problem (second one) is attached. I will remake the patch for multistring support for the upstream versio= n. --=20 With best regards, _______________________________ Vladimir Testov, ROSA Laboratory. www.rosalab.ru --nextPart75901818.hG6jyt70gf Content-Disposition: attachment; filename="grub-get_constructed_device_width-fixed.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="grub-get_constructed_device_width-fixed.patch" diff -Naur grub/grub-core/font/font.c grub-new/grub-core/font/font.c --- grub/grub-core/font/font.c 2013-03-28 23:28:47.784178000 +0400 +++ grub-new/grub-core/font/font.c 2013-04-17 12:21:53.682367388 +0400 @@ -1476,6 +1476,11 @@ blit_comb (glyph_id, NULL, bounds, main_glyph, combining_glyphs, device_width); + + /* The value could have been changed */ + if (device_width) + *device_width = main_glyph->device_width; + if (combining_glyphs_out) *combining_glyphs_out = combining_glyphs; else --nextPart75901818.hG6jyt70gf--