GNOME Bugzilla – Bug 342525
With PangoFc and PangoWin32, approximate digit width is not what it says
Last modified: 2006-05-22 20:26:35 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.
Same thing about win32, but not pangocairo-win32.
*** Bug 314114 has been marked as a duplicate of this bug. ***
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.
Created attachment 65969 [details] test case
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.
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.
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);
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.
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.
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.
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.
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.
Oops, closing.