GNOME Bugzilla – Bug 665384
Artifact when drawing the letter 'u' with the 'Sans' font family
Last modified: 2012-08-25 19:32:07 UTC
Created attachment 202584 [details] Screenshot showing artifact on the letter 'u' The attached screenshot shows a consistent artifact on the letter 'u', it seems I can only reproduce this when using 'Sans 24' font name, or any 'Sans' font... using other fonts don't produce this dot. The screenshot attached is rendered using pango_cairo_layout_path() and then cairo_fill_preserve() with yellow and finally the cairo_stroke() with purple is causing this dot/artifact to appear over the letter 'u'. It's currently rendered to a ClutterCairoTexture, however I highly doubt that has anything to do with the artifact.
Created attachment 202585 [details] Screenshot showing artifact on the letter 'u' Here's a better version of the screenshot (the last one was scaled up and fuzzy looking). This one also shows that the text is rendered along with a capital letter, there is no vertical pixel wrapping going on or the like (i.e. there is sufficient space in the cairo surface to render the letter).
Quite possibly a font bug, escaping through FreeType and cairo. Which font is it? Someone needs to track down. Can you printout the cairo_copy_path results?
(In reply to comment #2) > Quite possibly a font bug, escaping through FreeType and cairo. Which font is > it? Someone needs to track down. Sure... right now on my system I'm using: pango_font_description_from_string ("Sans 48px") (or whatever pixel size I specify has the same results). Any pointers on how I can track down the exact font in use ? FWIW, I am running an Ubuntu 10.04LTS on my laptop... I also did notice that in cairo_glyph_path(), there is a fallback mechanism in place, I'll try to recompile cairo to get a trace of whether I'm hitting that fallback or not... > Can you printout the cairo_copy_path results? Do you mean there is some cairo debugging printout to capture ? I'll perform a render of a copy of the cairo path later on today and upload a screenshot, see if it differs...
To get the actual font you can: - Do "fc-match sans" or "fc-match -v sans". - Do a pmap on the process and grep for fonts. The latter is safer. At any rate, send me the font and your FreeType version. By printing out cairo_copy_path() results I meant looping over the path and printf'ing yourself.
Here is the printed cairo path: Header: move to Point 1: x = 7.437500 y = 48.250000 Header: line to Point 1: x = 7.437500 y = 27.000000 Header: line to Point 1: x = 13.187500 y = 27.000000 Header: line to Point 1: x = 13.187500 y = 48.015625 Header: curve to Point 1: x = 13.187500 y = 51.339844 Point 2: x = 13.832031 y = 53.835938 Point 3: x = 15.125000 y = 55.500000 Header: curve to Point 1: x = 16.414062 y = 57.156250 Point 2: x = 18.351562 y = 57.984375 Point 3: x = 20.937500 y = 57.984375 Header: curve to Point 1: x = 24.039062 y = 57.984375 Point 2: x = 26.492188 y = 56.996094 Point 3: x = 28.296875 y = 55.015625 Header: curve to Point 1: x = 30.097656 y = 53.027344 Point 2: x = 31.000000 y = 50.320312 Point 3: x = 31.000000 y = 46.890625 Header: line to Point 1: x = 31.000000 y = 27.000000 Header: line to Point 1: x = 36.750000 y = 27.000000 Header: line to Point 1: x = 36.750000 y = 62.156250 Header: line to Point 1: x = 31.000000 y = 62.156250 Header: line to Point 1: x = 31.000000 y = 56.703125 Header: curve to Point 1: x = 29.601562 y = 58.828125 Point 2: x = 27.984375 y = 60.414062 Point 3: x = 26.140625 y = 61.453125 Header: curve to Point 1: x = 24.296875 y = 62.484375 Point 2: x = 22.156250 y = 63.000000 Point 3: x = 19.718750 y = 63.000000 Header: curve to Point 1: x = 15.695312 y = 63.000000 Point 2: x = 12.644531 y = 61.750000 Point 3: x = 10.562500 y = 59.250000 Header: curve to Point 1: x = 8.476562 y = 56.742188 Point 2: x = 7.437500 y = 53.074219 Point 3: x = 7.437500 y = 48.250000 Header: close path Header: move to Point 1: x = 21.906250 y = 26.156250 Header: close path I tried both methods you described above and both point to the font I have installed at: /usr/share/fonts/truetype/ttf-dejavu/DejaVuSans.ttf I'll upload a copy of that in a second...
Created attachment 203042 [details] The font in use causing the artifact
The final move_to/close_path is definitely wrong and what's causing the problem. Can you try with latest version of DejaVuSans? I'll propose a fix to cairo and FreeType.
Humm. I'm a bit lazy reporting this right now as I'm in the middle of something else. Here's the place this can be fixed in cairo: In cairo-ft-font.c: Around here: /* Font glyphs have an inverted Y axis compared to cairo. */ FT_Outline_Transform (&glyph->outline, &invert_y); if (FT_Outline_Decompose (&glyph->outline, &outline_funcs, path)) { ↦ _cairo_path_fixed_destroy (path); ↦ return _cairo_error (CAIRO_STATUS_NO_MEMORY); } status = _cairo_path_fixed_close_path (path); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if (unlikely (status)) { ↦ _cairo_path_fixed_destroy (path); ↦ return status; } This logic should be updated instead to check whether the last operation is a move_to, and in that case simply drop the move_to instead of adding a close_path(). In fact, same fix is needed in the move_to outline_funcs callback too. One should also pursue a fix in FreeType. And in DejaVu. And possibly Fontforge who generated the TTF. Are you up to the challenge of following up? :) Cheers, behdad
(In reply to comment #8) [...] > > Are you up to the challenge of following up? :) > I had forgotten my password at bugs.freedesktop.org, now fixed that and filed this in the proper cairo bug DB as: http://bugs.freedesktop.org/show_bug.cgi?id=43686 ... I don't know if I'll have time to write a patch for this though ...
What's the status of this?
Tracking upstream. Closing.