[cairo-bugs] [Bug 20779] New: text improperly positioned - scaled font glyph device transform misapplied

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Fri Mar 20 14:08:06 PDT 2009


http://bugs.freedesktop.org/show_bug.cgi?id=20779

           Summary: text improperly positioned - scaled font glyph device
                    transform misapplied
           Product: cairo
           Version: 1.8.6
          Platform: ARM
        OS/Version: other
            Status: NEW
          Severity: normal
          Priority: medium
         Component: freetype font backend
        AssignedTo: david at freetype.org
        ReportedBy: tony3 at GarlandConsulting.us
         QAContact: cairo-bugs at cairographics.org


When attempting to draw a truetype font an an embedded project where Cairo was
ported to run on an ARM9, the glyphs are drawn using
_cairo_scaled_font_show_glyphs().  Unfortunately, the device_transform offset
which is used to round glyph locations to the nearest pixel appears to subtract
the transform offsets when they should be added.

This typically causes the text to be positioned at a higher Y coordinate than
should be the case leaving the glyph to be rendered outside of the bounding
extent for the entire text string which causes the text to be completely
clipped and to not appear.

The call path leading to this behavior is:

main
cairo_show_text
_cairo_gstate_show_text_glyphs
_cairo_surface_fallback_show_glyphs
_clip_and_composite
_cairo_surface_old_show_glyphs
_cairo_scaled_font_show_glyphs

I'm not all that well-versed in cairo (my first time sleuthing around in the
code in am embedded debugger). But everywhere else that the
device_transform.{x0,y0} values appear to be used, they are considered to be
positive offsets and ADDED to the absolute x,y location.  In this one case,
they are being SUBTRACTED.

The fix, on our system, is to change the subtractions to additions (see below).

As to why this isn't causing serious text rendering problems for everyone using
Cairo 1.8.6 I'm not sure--perhaps the way the font is being rendered in our
system differs from typical somehow.

One thing we are doing differently: we are operating without fontconfig support
(we have no OS or real file system) by applying some patches that were
originally found here:

http://david.freetype.org/cairo/

which were mentioned here:

http://lists.cairographics.org/archives/cairo/2007-February/009838.html

I don't see off-hand how these patches (and their hand-corrections since cairo
has moved a bit since they were originally published) would have an effect upon
this bug.

Here's the patch which corrects the problem on our system:


*** a/cairo-scaled-font.c       Fri Mar 20 13:33:25 2009
--- b/cairo-scaled-font.c       Fri Mar 20 13:33:40 2009
*************** _cairo_scaled_font_show_glyphs (cairo_sc
*** 1919,1926 ****

        /* round glyph locations to the nearest pixel */
        /* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug?
*/
!       x = _cairo_lround (glyphs[i].x -
glyph_surface->base.device_transform.x0);
!       y = _cairo_lround (glyphs[i].y -
glyph_surface->base.device_transform.y0);

        _cairo_pattern_init_for_surface (&glyph_pattern, &glyph_surface->base);

--- 1919,1926 ----

        /* round glyph locations to the nearest pixel */
        /* XXX: FRAGILE: We're ignoring device_transform scaling here. A bug?
*/
!       x = _cairo_lround (glyphs[i].x +
glyph_surface->base.device_transform.x0);
!       y = _cairo_lround (glyphs[i].y +
glyph_surface->base.device_transform.y0);

        _cairo_pattern_init_for_surface (&glyph_pattern, &glyph_surface->base);


-- 
Configure bugmail: http://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the cairo-bugs mailing list