On 12-12-19 05:43 AM, Olivier Fourdan wrote: > >>> 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. > > Humm, that sounds quite complicated and platform specific, no?
Right. For better or worse, Pango doesn't expose x-height. Which is not that bad when you consider that "x-height" makes little sense for most scripts other than Latin/Greek/Cyrillic.. > So I took another approach to the problem. > > Assuming Pango rightfully places the strikethrough, I retrieved the position > of the strikethrough with something like: > > context = pango_layout_get_context (layout); > language = pango_language_get_default (); > desc = pango_layout_get_font_description (layout); > metrics = pango_context_get_metrics (context, desc, language); > > baseline = pango_layout_get_baseline(layout); > strikethrough = pango_font_metrics_get_strikethrough_position (metrics); > thickness = pango_font_metrics_get_underline_thickness (metrics); > > return PANGO_PIXELS(baseline - strikethrough - thickness / 2); > > And that gives (what I believe is) an acceptable result, at least from my > point of view. Sounds reasonable. behdad > Cheers, > Olivier > -- behdad http://behdad.org/ _______________________________________________ gtk-i18n-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
