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 665384 - Artifact when drawing the letter 'u' with the 'Sans' font family
Artifact when drawing the letter 'u' with the 'Sans' font family
Status: RESOLVED NOTGNOME
Product: pango
Classification: Platform
Component: cairo
unspecified
Other Linux
: Normal normal
: ---
Assigned To: pango-maint
pango-maint
Depends on:
Blocks:
 
 
Reported: 2011-12-02 11:09 UTC by Tristan Van Berkom
Modified: 2012-08-25 19:32 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Screenshot showing artifact on the letter 'u' (6.97 KB, image/png)
2011-12-02 11:09 UTC, Tristan Van Berkom
Details
Screenshot showing artifact on the letter 'u' (5.16 KB, image/png)
2011-12-02 11:15 UTC, Tristan Van Berkom
Details
The font in use causing the artifact (607.70 KB, application/octet-stream)
2011-12-08 06:37 UTC, Tristan Van Berkom
Details

Description Tristan Van Berkom 2011-12-02 11:09:37 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.
Comment 1 Tristan Van Berkom 2011-12-02 11:15:53 UTC
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).
Comment 2 Behdad Esfahbod 2011-12-05 18:55:20 UTC
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?
Comment 3 Tristan Van Berkom 2011-12-06 07:59:15 UTC
(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...
Comment 4 Behdad Esfahbod 2011-12-06 14:18:05 UTC
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.
Comment 5 Tristan Van Berkom 2011-12-08 06:36:06 UTC
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...
Comment 6 Tristan Van Berkom 2011-12-08 06:37:48 UTC
Created attachment 203042 [details]
The font in use causing the artifact
Comment 7 Behdad Esfahbod 2011-12-08 19:40:05 UTC
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.
Comment 8 Behdad Esfahbod 2011-12-08 19:44:48 UTC
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
Comment 9 Tristan Van Berkom 2011-12-10 10:14:10 UTC
(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 ...
Comment 10 Behdad Esfahbod 2012-08-18 17:13:27 UTC
What's the status of this?
Comment 11 Behdad Esfahbod 2012-08-25 19:32:07 UTC
Tracking upstream.  Closing.