Computing character height



Hi all,

I'm triyng to compute the height of each *individual* character of a rendered text (I'm using Pango over Cairo). It seems all characters are of the same height, and I wonder if this is so by design or if I'm doing something wrong (I'm new to Pango).

What I do is to get a PangoLayoutIter from a PangoLayout and then compute the extents of each char (see [1] below).

What I'm getting looks like the image at [2] (http://imgur.com/vUnwJIs), this is, basically all characters are of the same height.

Is it possible to compute individual heights of each character? If so, how?

Thanks in advance,
Antonio


[1]
void text_rectangles(cairo_t * cairo, PangoLayout * layout)
{
    PangoLayoutIter * iter = NULL;
    PangoRectangle extents;

    cairo_set_source_rgb(cairo, 0.6, 0.0, 0.6);
    cairo_set_line_width(cairo, 0.5);

    iter = pango_layout_get_iter(layout);
    do {
        pango_layout_iter_get_char_extents(iter, &extents);
        pango_extents_to_pixels(&extents, NULL);
cairo_rectangle(cairo, extents.x, extents.y, extents.width, extents.height);
    } while (pango_layout_iter_next_char(iter));

    cairo_stroke(cairo);

    pango_layout_iter_free(iter);
}

[2] http://imgur.com/vUnwJIs


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]