<div dir="ltr">I absolutely agree that using the font extents for this works better.<br><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 17, 2015 at 1:38 PM, Lawrence D'Oliveiro <span dir="ltr"><<a href="mailto:ldo@geek-central.gen.nz" target="_blank">ldo@geek-central.gen.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This code sample <<a href="http://cairographics.org/samples/text_align_center/" rel="noreferrer" target="_blank">http://cairographics.org/samples/text_align_center/</a>><br>
is supposed to show how to center text around a position both<br>
horizontally and vertically. I don’t think the vertical centring looks<br>
good.<br>
<br>
If you want to do accurate vertical centring, the formula I came up<br>
with is<br>
<br>
text_mid_y = (- 2 * text_extents.y_bearing - text_extents.height) / 2<br>
<br>
However, I find that it looks a bit better overall to do the vertical<br>
centring based on the font metrics, rather than that of the specific<br>
text:<br>
<br>
font_mid_y = (font_extents.ascent - font_extents.descent) / 2<br>
<br>
You can compare the different effects here<br>
<<a href="http://default-cube.deviantart.com/art/Text-Vert-Align-520839470" rel="noreferrer" target="_blank">http://default-cube.deviantart.com/art/Text-Vert-Align-520839470</a>>, and<br>
see if you agree or not.<br>
<span class="HOEnZb"><font color="#888888">--<br>
cairo mailing list<br>
<a href="mailto:cairo@cairographics.org">cairo@cairographics.org</a><br>
<a href="http://lists.cairographics.org/mailman/listinfo/cairo" rel="noreferrer" target="_blank">http://lists.cairographics.org/mailman/listinfo/cairo</a></font></span></blockquote></div><br></div>