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 341481 - pangocairo kerning problem with nonidentity scaling
pangocairo kerning problem with nonidentity scaling
Status: RESOLVED FIXED
Product: pango
Classification: Platform
Component: cairo
unspecified
Other Linux
: High major
: ---
Assigned To: Behdad Esfahbod
pango-maint
: 500725 535041 558350 570901 593538 (view as bug list)
Depends on:
Blocks: 573261
 
 
Reported: 2006-05-11 22:56 UTC by Behdad Esfahbod
Modified: 2009-12-04 19:45 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
test case with python and pangocairo (1.54 KB, text/plain)
2008-01-10 11:38 UTC, Pierre Rust
  Details
patch showing and correcting the negative glyph width (585 bytes, patch)
2009-10-20 17:14 UTC, Hans Breuer
none Details | Review

Description Behdad Esfahbod 2006-05-11 22:56:28 UTC
As pointed out on the mailing list, pangocairo overkerns when you scale the pango context up.  A test case is available here:

  http://mail.gnome.org/archives/gtk-i18n-list/2006-May/msg00022.html

and my analysis:

If I understand it correctly, this is what happening:

  - When you choose a font size of 10pt, and a ctm that scales
5x5, the font size loaded by cairo at size 50pt, but glyph
metrics returned are scaled down by 5, and so dimensionally, they
correspond to a 10pt font.

  - In pango_fc_font_kern_glyphs and/or pango-ot-buffer.c:apply_gpos_*
the glyph positioning applied corresponds to a 50pt font, as no
distinction between font matrix and ctm is made here.

  - The glyphs are drawn to the cairo context using the 5x5
scaled ctm, making the 50pt positioning effectively a 250pt
positioning.
Comment 1 Behdad Esfahbod 2006-05-11 22:57:05 UTC
Note that to see the bug you need a font with kerning.  Changing the Times family name in the test case to Bitstream Vera Sans make it happen here.
Comment 2 Behdad Esfahbod 2006-05-13 04:15:38 UTC
I think what we need to do is to use the ctm in resolution computation for pangocairo contexts.
Comment 3 Behdad Esfahbod 2006-05-28 20:29:44 UTC
Owen, do you have any insights here?
Comment 4 Behdad Esfahbod 2006-06-07 08:15:11 UTC
The mini font of the hexbox is affected too...
Comment 5 Behdad Esfahbod 2007-11-30 23:33:09 UTC
*** Bug 500725 has been marked as a duplicate of this bug. ***
Comment 6 Pierre Rust 2008-01-10 11:38:38 UTC
Created attachment 102511 [details]
test case with python and pangocairo

Just in case it could be of any help, here is another test case using python and pangocairo.
is there any fix planned ? this bug is pretty annoying when using cairo's scaling to draw and write in a device independent resolution. Actually is make using kerning fonts impossible.
Comment 7 Behdad Esfahbod 2008-01-10 20:28:17 UTC
No plans, sorry.  So many things I want to fix tonight... :(

I'll try to give this a shot for 1.20 though.
Comment 8 Behdad Esfahbod 2008-08-12 17:45:43 UTC
*** Bug 535041 has been marked as a duplicate of this bug. ***
Comment 9 Paul Wise 2008-08-28 23:36:23 UTC
This bug is preventing screen-message from rendering Khmer properly:

http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=sm-khmer.png;att=2;bug=496733

This is what it should look like (in gedit):

http://bugs.debian.org/cgi-bin/bugreport.cgi?msg=5;filename=gedit-khmer.png;att=3;bug=496733
Comment 10 Behdad Esfahbod 2009-02-08 00:24:49 UTC
*** Bug 570901 has been marked as a duplicate of this bug. ***
Comment 11 Behdad Esfahbod 2009-08-30 17:07:07 UTC
*** Bug 593538 has been marked as a duplicate of this bug. ***
Comment 12 Hans Breuer 2009-10-20 17:08:40 UTC
Maybe I'm completely on the wrong track, but it seems like this bug is causing huge rendering artifacts with Dia (bug #573261) in all (pango-)cairo renderers.
Some debug code in pango_fc_font_kern_glyphs() shows cases, where the adjustment applied is bigger than the original width of the glyph - by more than a factor of three! 
I'm uncertain about the right fix, but maybe a workaround could be applied to avoid getting a negative glyph width through this?
Comment 13 Hans Breuer 2009-10-20 17:14:31 UTC
Created attachment 145880 [details] [review]
patch showing and correcting the negative glyph width

The above patch is not ready to apply - it prints some debug spew. Testing with Dia shows a zoom dependent adjustment, but glyph.width is staying constant.

To reproduce I used dia-object.dia from the Dia git repository (samples/Self), switched to antialized rendering and zoomed around. (the T in DiaObjectType is moving into the y and about three glyphs away from the small t.)
Comment 14 Behdad Esfahbod 2009-10-22 00:57:13 UTC
I actually have a semi-working patch for this in my tree.  I'll finish it tonight.
Comment 15 Behdad Esfahbod 2009-11-18 00:33:42 UTC
commit d9abcaf566e9cd7f702c98958f99f90fd53b4c0b
Author: Behdad Esfahbod <behdad@behdad.org>
Date:   Tue Nov 17 19:31:23 2009 -0500

    Bug 341481 - pangocairo kerning problem with nonidentity scaling
    
    Finally fix this embarrassing bug.  The fix is a kludge, but it will
    be redone for 1.28 (harfbuzz-ng) anyway.
Comment 16 Behdad Esfahbod 2009-12-04 19:45:33 UTC
*** Bug 558350 has been marked as a duplicate of this bug. ***