GNOME Bugzilla – Bug 341481
pangocairo kerning problem with nonidentity scaling
Last modified: 2009-12-04 19:45:33 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.
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.
I think what we need to do is to use the ctm in resolution computation for pangocairo contexts.
Owen, do you have any insights here?
The mini font of the hexbox is affected too...
*** Bug 500725 has been marked as a duplicate of this bug. ***
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.
No plans, sorry. So many things I want to fix tonight... :( I'll try to give this a shot for 1.20 though.
*** Bug 535041 has been marked as a duplicate of this bug. ***
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
*** Bug 570901 has been marked as a duplicate of this bug. ***
*** Bug 593538 has been marked as a duplicate of this bug. ***
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?
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.)
I actually have a semi-working patch for this in my tree. I'll finish it tonight.
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.
*** Bug 558350 has been marked as a duplicate of this bug. ***