Obtaining baseline from CATextLayer
Obtaining baseline from CATextLayer
- Subject: Obtaining baseline from CATextLayer
- From: Graham Cox <email@hidden>
- Date: Sun, 10 Aug 2014 14:50:47 +1000
One of the things that bugs me about text on OS X is that it's laid out from the top edge of a bounding box, not based off a baseline. In particular, CATextLayer lays out text from its top edge, but provides no way to find out the baseline that results. This makes laying out layers with text labels quite hard work when ensuring that text that can vary in size or that uses a mix of fonts stays aligned to a particular baseline.
Since CATextLayer has no -baseline method, is there any other way to figure this out? If it's only using a single font, things aren't too bad, since the ascender can be obtained from the font (though since any of several different font objects or even just a string can be assigned as the -font property, this requires a little bit of effort). Much harder is if a mix of fonts is used, or if font substitution was necessary due to unsupported characters in the font. In that case you have to effectively perform all of the line layout yourself, just to figure the baseline, yet surely CATextLayer is already doing exacty the same work internally.
Am I missing something more obvious, or is it really this hard?
--Graham
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden