Hi there,
I am using Core Text to draw a line of text exactly centered in the middle of a rectangle.
For reasons that I am not going to explain I can't/don't want to use the image bounds of the line.
So, in order to retrieve the line metrics I am using the CTLineGetTypographicBounds function.
The width returned by the function perfectly centers my line in the rectangle and I am happy with it.
However, I still don't seem to find a way to retrieve the correct height in order for the line to be perfectly centered.
In theory the correct way to get the line height is to add the ascent and descent together (no leading).
In the majority of the cases this leaves the font too close to the lower edge of my rectangle.
I also tried to use the font X-height, but that doesn't really centers my line of text any better.
I found out that the method that - even though far from perfect - works best is to subtract the descent to the ascent and use that measure as the line height.
However that something I discovered by trial and error and doesn't really make sense to me.
Now, I understand that different fonts have different ways of adhering to the standard font metric rules. (some probably don't)
However is there a more accurate way to get the correct line height to vertically center text, or is what I am after like a moving target ?
Any help is highly appreciated.
Thank you.
- Luigi
------------------------------------------------------------
THIS E-MAIL MESSAGE IS FOR THE SOLE USE OF THE INTENDED RECIPIENT AND MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. ANY UNAUTHORIZED REVIEW, USE, DISCLOSURE OR DISTRIBUTION IS PROHIBITED. IF YOU ARE NOT THE INTENDED RECIPIENT, CONTACT THE SENDER BY E-MAIL AT email@hidden AND DESTROY ALL COPIES OF THE ORIGINAL MESSAGE. WITHOUT PREJUDICE UCC 1-207.
------------------------------------------------------------
____________________________________________________________________________________
Looking for last minute shopping deals?
Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartz-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartz-dev/email@hidden
This email sent to email@hidden