[cairo] How to measure Fonts
Behdad Esfahbod
behdad at behdad.org
Mon Feb 5 08:19:27 PST 2007
On Mon, 2007-02-05 at 03:44 -0500, Kalle Vahlman wrote:
>
>
> I think that in the move_to(), your calculation is a bit wrong. For
> example, for a font height of 10 pixels, it will end up in 15, while
> you'll want it to be 5. You should first take the half of the height
> of the rectangle (20/2) and then substract half of the height of the
> font (extents.height/2) to get it on the correct level. So:
>
> cairoContext->move_to(0, (20/2)-(extents.height/2));
>
> should take the current point to where you want it to be.
This is true for PangoLayout objects that have origin at top left. For
cairo text api and PangoLayoutLine objects however, the origin is at the
left of the baseline. So the calculations in the original message ar
crrect.
We sure can tell more if there was code and screenshot to see.
--
behdad
http://behdad.org/
"Those who would give up Essential Liberty to purchase a little
Temporary Safety, deserve neither Liberty nor Safety."
-- Benjamin Franklin, 1759
More information about the cairo
mailing list