Artifact when drawing the letter 'u' from DejaVuSans.ttf
Submitted by Tristan Van Berkom
Assigned to David Turner
Description
Created attachment 54283 Screenshot showing artifact on the letter 'u'
This is originally filed as a pangocairo bug here: http://bugzilla.gnome.org/show_bug.cgi?id=665384
The attached screenshot show the problem (it happens to be rendered using pangocairo onto a CoglTexture and displayed with Clutter, that should of course not be relevant...).
I've made a printout of the resulting path drawing just the letter 'u', here it is for reference:
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
And some comments from Behdad which should be useful in fixing the problem here:
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.
As I can only attach one file at a time, following up next with an attachment of the actual DejaVuSans.ttf from my system which is showing the problem.
Attachment 54283, "Screenshot showing artifact on the letter 'u'":
Version: 1.10.3