A question regarding text extents

Zozó Teki <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <CAE+APxgZJCvJgzbnJJf6qL2G3WZcmWgnrAn=v1oLP+Wr=2jMWg@mail.gmail.com>
Hi,

I use cairo_text_extents() to retrieve how much space is needed for a
piece of text to be able to draw a simple box around it. I have
noticed that this function returns a different value depending on the
transformation matrix in effect. Specifically, if I scale the context,
the returned x_advance is somewhat larger (and also the text is drawn
somewhat larger) - but not by the scaling factor.

In the example below, the two runs produce different values for
extents1.x_advance and extents2.x_advance. On Linux (1.10.2), the two
values are 115 and 116.5 (with whatever font "arial" maps to), whereas
on Windows (1.12.8) I got 109 and 117.

Is this the intended behaviour?

    cairo_surface_t *surface =
cairo_image_surface_create(CAIRO_FORMAT_RGB24, 0, 0);
    cairo_t *cr = cairo_create(surface);
    cairo_select_font_face(cr, "arial", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 16);
    cairo_text_extents_t extents1;
    cairo_text_extents(cr, "Now I have both", &extents1);
    cairo_destroy(cr);
    cairo_surface_destroy(surface);

    surface = cairo_image_surface_create(CAIRO_FORMAT_RGB24, 0, 0);
    cr = cairo_create(surface);
    cairo_scale(cr, 4, 4);
    cairo_select_font_face(cr, "arial", CAIRO_FONT_SLANT_NORMAL,
CAIRO_FONT_WEIGHT_NORMAL);
    cairo_set_font_size(cr, 16);
    cairo_text_extents_t extents2;
    cairo_text_extents(cr, "Now I have both", &extents2);
    cairo_destroy(cr);
    cairo_surface_destroy(surface);


Zoltan
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.