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 584585 - pango_layout_get_extents returns incorrect width in Windows
pango_layout_get_extents returns incorrect width in Windows
Status: RESOLVED NOTABUG
Product: pango
Classification: Platform
Component: cairo
1.22.x
Other All
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2009-06-02 04:49 UTC by Ian Puleston
Modified: 2009-07-20 18:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Small app to demo the problem (4.61 KB, application/x-compressed-tar)
2009-06-02 04:54 UTC, Ian Puleston
Details

Description Ian Puleston 2009-06-02 04:49:07 UTC
Please describe the problem:
I have an application that calls pango_layout_get_size() to calculate the width of a piece of text in order to correctly position it in a print operation. In Linux this works perfectly, but with the same code in Windows pango_layout_get_size() does not seem to be returning the correct width.

Note that is is actually pango_layout_get_extents() that is returning the wrong value in Windows (pango_layout_get_size() is simply a front end to that) - I made a version of the app that called pango_layout_get_extents() and printed the width from the ink_rect, and it showed the same problem.

The effect seems to vary with point size, and with a 14-point Arial font Windows seems to get it correct. The following are widths shown by the attached test app for the same text with different point sizes printed in Windows and Linux.

Pt Size  Windows  Linux
8        0.57"    0.62"
10       0.82"    0.77"
12       0.96"    0.93"
14       1.08"    1.08"
16       1.17"    1.24"
24       1.88"    1.85"
32       2.44"    2.47"


Steps to reproduce:
1. Run the test application that I will attach.
2. Enter some text and click print.
3. Measure the width of the printed text and check it against the calculated width reported in the printout (also reported via a g_print report if launched from a terminal).



Actual results:
The width is correct if run in Linux, generally wrong (OK with a 14-point Arial font) if run in Windows.

Expected results:
Windows and Linux should give the same results and the reported width should be the actual width of the printed text.

Does this happen every time?
Yes

Other information:
Comment 1 Ian Puleston 2009-06-02 04:54:34 UTC
Created attachment 135788 [details]
Small app to demo the problem

I have attached a small app to demo the problem. Note that function getPrintWidth() in tstApp.c contains the call to pango_layout_get_size() that is returning the wrong value.
Comment 2 Ian Puleston 2009-06-02 05:10:05 UTC
Note that in Windows the test application is also affected by the bug with pango_layout_set_width() reported in http://bugzilla.gnome.org/show_bug.cgi?id=584586, hence the printed text will get wrapped if anything more than very short input is entered.
Comment 3 Behdad Esfahbod 2009-07-20 18:04:10 UTC
I keep telling you.  You don't want to listen.  You can't use the context/layout from GtkLabel to measure text for print.  Hinting, etc, result in differences in the extents.