Pango: Accessing x-height/mean-line in Pango layout



Hi,

For a small project I am working on, I need to render labels and leaders on a drawing.

For labels placed on each side, the label should be placed vertically so that the leader ends vertically in the middle of the label, something like:

<-------- Some Label

My first implementation was using the logical rectangle from pango_layout_get_pixel_extents() to compute the height of the layout and position the label in the middle, ie:

    pango_layout_get_pixel_extents (layout, NULL, &logical_rect);
    lx = priv->label_x + logical_rect.x;
    ly = priv->label_y + logical_rect.y - logical_rect.height / 2;

While this would mostly work, it's not perfect as the positioning is done based on the logical rect, which may vary depending on the text, ie "Papa" and "papa" would not have the same height. Beside, to improve the positioning, it's been requested that the label is placed at the middle of the lowercase characters.

Looking at typefaces definitions here [1] and [2], the positioning should be ideally made based in between the baseline and the mean-line (baseline - x-height).

I wonder, how can I access the x-height (or better the meanline) using the Pango API? Is there a simple API for this?

Cheers,
Olivier

[1] http://en.wikipedia.org/wiki/Typeface
[2] http://upload.wikimedia.org/wikipedia/commons/3/39/Typography_Line_Terms.svg

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