Re: Pango: Accessing x-height/mean-line in Pango layout
- From: Behdad Esfahbod <behdad behdad org>
- To: Olivier Fourdan <ofourdan redhat com>
- Cc: gtk-i18n-list gnome org
- Subject: Re: Pango: Accessing x-height/mean-line in Pango layout
- Date: Tue, 18 Dec 2012 12:19:47 -0500
On 12-12-18 04:32 AM, Olivier Fourdan wrote:
> 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.
That's not correct. "Papa" and "papa" have the same logical height. That's
the whole difference between logical and ink extents.
> 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?
Not directly. If you are using pangofc, you can obtain the FT_Face from the
PangoFont, then get the (I think) "OS/2" table of the font, and get the
x-height from in there.
behdad
> Cheers,
> Olivier
>
> [1] http://en.wikipedia.org/wiki/Typeface
> [2] http://upload.wikimedia.org/wikipedia/commons/3/39/Typography_Line_Terms.svg
> _______________________________________________
> gtk-i18n-list mailing list
> gtk-i18n-list gnome org
> https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
>
--
behdad
http://behdad.org/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]