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 342525 - With PangoFc and PangoWin32, approximate digit width is not what it says
With PangoFc and PangoWin32, approximate digit width is not what it says
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks: 342529
 
 
Reported: 2006-05-21 21:22 UTC by Behdad Esfahbod
Modified: 2006-05-22 20:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case (1000 bytes, text/x-python)
2006-05-21 22:48 UTC, Behdad Esfahbod
Details
screenshot (7.51 KB, image/png)
2006-05-21 23:01 UTC, Behdad Esfahbod
Details

Description Behdad Esfahbod 2006-05-21 21:22:53 UTC
pango_layout_set_text (layout, "0123456789", -1);
  metrics->approximate_digit_width = max_glyph_width (layout);

This is apparently max digit width, not approximate.  I like to fix it.
Comment 1 Behdad Esfahbod 2006-05-21 21:25:03 UTC
Same thing about win32, but not pangocairo-win32.
Comment 2 Behdad Esfahbod 2006-05-21 21:26:38 UTC
*** Bug 314114 has been marked as a duplicate of this bug. ***
Comment 3 Behdad Esfahbod 2006-05-21 22:46:04 UTC
Hum, apparently the max is not the issue here.  Something else is causing it.  I'm testing with a small python app, and seems like for sizes > 8, the reported digit width is one or two pixels wider than the actual thing.  Donno what's happening.  Attaching test case.
Comment 4 Behdad Esfahbod 2006-05-21 22:48:26 UTC
Created attachment 65969 [details]
test case
Comment 5 Behdad Esfahbod 2006-05-21 23:01:57 UTC
Created attachment 65970 [details]
screenshot

While the test program reports a 21px approx digit width, the actual value seems to be 18 at this size.

Seems like dpi not being propagated somewhere when creating layout for metrics.
Comment 6 Behdad Esfahbod 2006-05-21 23:19:14 UTC
Ok, I filed this new issue as bug 342529 (and found the cause, which was indeed a dpi setting ignored).

This bug is about what the opening comment says.
Comment 7 Behdad Esfahbod 2006-05-21 23:38:15 UTC
Owen, do you have any strong reasons to keep this as max instead of mean:

pango_layout_set_text (layout, "0123456789", -1);
  metrics->approximate_digit_width = max_glyph_width (layout);
Comment 8 Behdad Esfahbod 2006-05-22 00:25:34 UTC
2006-05-21  Behdad Esfahbod  <behdad@gnome.org>

        Bug 342525 – With PangoFc and PangoWin32, approximate digit width is
        not what it says

        * pango/pangofc-font.c (pango_fc_font_create_metrics_for_context):
        Likewise for PangoFc.  Compute average instead of max.
        (max_glpyh_with): Now unused, drop.

Comment 9 Owen Taylor 2006-05-22 15:01:52 UTC
The reason for doing a max, is that if you want an entry that can
hold 10 digit numbers, you want an entry that can hold 10 9's, 
even if 1 is significantly narrower.

Of course, many fonts have numerals that are designed to all be
the same width, even if they are proportionally spaced for letters,
but in that case, it won't matter.
Comment 10 Behdad Esfahbod 2006-05-22 15:08:46 UTC
I could think of that, of course, but:

  1) doesn't the same hold for char_width too?
  2) the name approx_digit_width is misleading.

but I do understand what you're saying.  Ok, I'll back up the changes, and ask Tor to make pangocairo-win32 do a max too.
Comment 11 Owen Taylor 2006-05-22 15:29:38 UTC
1) The difference is that digit widths tend to be more or less uniform, so the
   max isn't ridiculously too large. But letters are much less uniform,
   so taking the max isn't feasible.

2) It's approx_digit_width, not average_digit_width :-). The max is just
   a different sort of approximation.
Comment 12 Behdad Esfahbod 2006-05-22 20:25:46 UTC
Tor, can you please check that HEAD and branch compile fine?

2006-05-22  Behdad Esfahbod  <behdad@gnome.org>

        Bug 342525 – With PangoFc and PangoWin32, approximate digit width is
        not what it says

        * pango/pangocairo-win32font.c (max_glyph_width),
        (create_metrics_for_context): Use max digit width instead of average.

        Reverted the following changes:

        * pango/pangofc-font.c (pango_fc_font_create_metrics_for_context):
        Likewise for PangoFc.  Compute average instead of max.
        (max_glpyh_with): Now unused, drop.

        * pango/pangowin32.c (pango_win32_font_get_metrics): Calculate
        average digit width correctly, not as max of the digit
        widths. (#342525) Note that this code doesn't really get much used
        currently (instead the code in pangocairo-win32font.c is used),
        fixed only for completeness.
        (max_glpyh_with): Now unused, drop.

Comment 13 Behdad Esfahbod 2006-05-22 20:26:35 UTC
Oops, closing.