After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 563356 - The input area of firefox and the blank width after text in gnome-menu was stretched too wide, under pango-1.22.3
The input area of firefox and the blank width after text in gnome-menu was st...
Status: VERIFIED FIXED
Product: pango
Classification: Platform
Component: general
1.22.x
Other Linux
: Normal major
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2008-12-05 16:54 UTC by Yu Yuwei
Modified: 2009-01-05 13:58 UTC
See Also:
GNOME target: ---
GNOME version: 2.23/2.24


Attachments
the stretched google, invoked under LC_ALL=zh_CN.UTF-8 (172.02 KB, image/png)
2008-12-05 16:55 UTC, Yu Yuwei
Details
correct google invoke under LC_ALL=en_US.UTF-8 (172.35 KB, image/png)
2008-12-05 16:55 UTC, Yu Yuwei
Details
The screenshot of gnome-menu under pango-1.20.5 (161.05 KB, image/png)
2008-12-06 00:38 UTC, Yu Yuwei
Details
The screenshot of gnome-menu under pango-1.22.3 (144.46 KB, image/png)
2008-12-06 00:39 UTC, Yu Yuwei
Details
This page under pango-1.20.5 (199.78 KB, image/png)
2008-12-06 00:39 UTC, Yu Yuwei
Details
This page under pango-1.22.3 (167.43 KB, image/png)
2008-12-06 00:40 UTC, Yu Yuwei
Details
this page displayed correctly under pango svn (208.24 KB, image/png)
2008-12-06 04:24 UTC, Yu Yuwei
Details
google also displayed correctly in firefox invoked under zh_CN.UTF-8 with pango svn (192.40 KB, image/png)
2008-12-06 04:26 UTC, Yu Yuwei
Details
gnome-menu also correct under pango svn :) (151.00 KB, image/png)
2008-12-06 04:29 UTC, Yu Yuwei
Details
the input correct input field on firefox 3.0.5 (39.07 KB, image/png)
2009-01-05 13:52 UTC, seenxu
Details
long input field length with fifty chinese charactors (38.34 KB, image/png)
2009-01-05 13:54 UTC, seenxu
Details
long input field length with fifty letters (37.76 KB, image/png)
2009-01-05 13:55 UTC, seenxu
Details

Description Yu Yuwei 2008-12-05 16:54:11 UTC
Please describe the problem:
Under pango-1.22.3,
When GTK+ program running under LC_MESSAGES=zh_CN.UTF-8 the blank area width was very large, about the same size of text; the firefox running under LC_MESSAGES=zh_CN.UTF-8, the input area in webpages will be stretch to very wide.

when downgraded to pango-1.20.5, everything displayed correctly.

Steps to reproduce:
1. export LC_ALL=zh_CN.UTF-8
2. run firefox
3. open www.g.cn


Actual results:
See the stretched input area


Expected results:
the correct inut area width

Does this happen every time?
verytime

Other information:
xorg-server: 1.5.2
glib: 2.18.3
gtk+: 2.14.5
cairo: 1.8.4
Comment 1 Yu Yuwei 2008-12-05 16:55:03 UTC
Created attachment 124010 [details]
the stretched google, invoked under LC_ALL=zh_CN.UTF-8
Comment 2 Yu Yuwei 2008-12-05 16:55:55 UTC
Created attachment 124011 [details]
correct google invoke under LC_ALL=en_US.UTF-8
Comment 3 Yu Yuwei 2008-12-05 17:01:09 UTC
lots of Chinese users complaint about this bug. 
Comment 4 Behdad Esfahbod 2008-12-05 17:06:41 UTC
That's a Google or Firefox bug.  Under a Chinese locale, the default font has metrics for Chinese characters, which is typically twice wider than Latin chars.  The Google text box has size="55", that is, 55 chars wide.  I know the firefox guys wanted to work around this.  Anyway, take it to firefox please.
Comment 5 Yu Yuwei 2008-12-06 00:38:36 UTC
Created attachment 124032 [details]
The screenshot of gnome-menu under pango-1.20.5
Comment 6 Yu Yuwei 2008-12-06 00:39:09 UTC
Created attachment 124033 [details]
The screenshot of gnome-menu under pango-1.22.3
Comment 7 Yu Yuwei 2008-12-06 00:39:56 UTC
Created attachment 124035 [details]
This page under pango-1.20.5
Comment 8 Yu Yuwei 2008-12-06 00:40:37 UTC
Created attachment 124036 [details]
This page under pango-1.22.3
Comment 9 Yu Yuwei 2008-12-06 00:44:59 UTC
Seems not the bug of google, because lots of pages have this problem in firefox under pango-1.22.3, including current page as show in the attached screenshots.

I should be specific, the gnome-menu suffer this problem. The attached screenshots illustrate it. 

I still think this problems are caused by pango :)
Comment 10 Behdad Esfahbod 2008-12-06 01:07:17 UTC
Ok, I see what's going on.  This is an old known issue.  The thing is, CJK characters are more information dense than non-CJK characters.  For example, a three/four word sentence in English translates to perhaps two CJK chars.  So, when someone sets the width of their input box to, say, 20 chars, they don't mean 20 CJK chars.  Another way to interpret it is "enough for a 20-char English sentence to fit".  When filling in with CJK, it typically takes much less.

So, by interpreting text box size as information size rather than strict character size, we can divide by an information density ratio for the language, which one can simply take as 2 for CJK and 1 for normal.  Good old double-width and single-width...  Expanding this further, we can redefine PangoFontMetrics' approximate_char_width in the same tune and so adjust for CJK.  Then you get your right-sized boxes back.  They will in fact become a bit shorter than then used to.

Owen, Matthias, does this make sense to you?

Oh, the reason this changed between 1.20.x and 1.22.x is that before 1.22, we were using a half English half Chinese string to measure the approximate width of Chinese.  That was obviously wrong.  When fixing that to measure a Chinese-only string, you now see the full reality of it...
Comment 11 Behdad Esfahbod 2008-12-06 01:44:34 UTC
Ok, committed the fix to SVN trunk.  Didn't test much.  Please test and report.  New screenshots appreciated!

2008-12-05  Behdad Esfahbod  <behdad@gnome.org>

        Bug 563356 – The input area of firefox and the blank width after text
        in gnome-menu was stretched too wide, under pango-1.22.3

        * docs/tmpl/fonts.sgml:
        * pango/pango-impl-utils.h:
        * pango/pangocairo-atsuifont.c
        (pango_cairo_atsui_font_create_metrics_for_context):
        * pango/pangocairo-win32font.c
        (pango_cairo_win32_font_create_metrics_for_context):
        * pango/pangofc-font.c (pango_fc_font_create_metrics_for_context):
        For approximate_char_width calculation take each char's width into 
        account.  That is, do a weighted average instead of uniform average.
        g_unichar_iszerowidth() chars count as 0, g_unichar_iswide() chars 
        count 2, and the rest count as 1.  Pretty much wcwidth() behavior.
        See bug report for rationale.

Comment 12 Yu Yuwei 2008-12-06 04:24:50 UTC
Created attachment 124043 [details]
this page displayed correctly under pango svn
Comment 13 Yu Yuwei 2008-12-06 04:26:00 UTC
Created attachment 124044 [details]
google also displayed correctly in firefox invoked under zh_CN.UTF-8 with pango svn
Comment 14 Yu Yuwei 2008-12-06 04:29:16 UTC
Created attachment 124045 [details]
gnome-menu also correct under pango svn :)

Behdad, 
Thanks for your effects and explanation, you did a great work :)
Comment 15 Yu Yuwei 2008-12-06 04:31:07 UTC
effects -> efforts
sorry for type :)
Comment 16 Behdad Esfahbod 2008-12-06 06:53:32 UTC
Thanks Yu.  Looks great.
Comment 17 seenxu 2009-01-05 13:52:22 UTC
Created attachment 125781 [details]
the input correct input field on firefox 3.0.5

spec: pango svn + cairo git + firefox 3.0.5 + ubuntu 8.10 amd64
Comment 18 seenxu 2009-01-05 13:54:17 UTC
Created attachment 125782 [details]
long input field length with fifty chinese charactors

spec: pango svn + cairo git + firefox 3.0.5 + ubuntu 8.10 amd64
Comment 19 seenxu 2009-01-05 13:55:19 UTC
Created attachment 125783 [details]
long input field length with fifty letters

spec: pango svn + cairo git + firefox 3.0.5 + ubuntu 8.10 amd64
Comment 20 seenxu 2009-01-05 13:58:28 UTC
check the attachments from comment #17 to #19, I think the bug is still exist on firefox 3.1

PS:
comment #18, #19 I had stated the wrong system spec, those two screenshots, are taken on firefox 3.1 not firefox 3.0.5, sorry.