I am looking for a way to align a character as shown in the picture:

The method should work for any given character (or at least all common Unicode characters).
Here is my actual approach (in Swift, inspired by this and this question):
let char = "a" let ctFont = CTFontCreateWithNameAndOptions("HelveticaNeue", 12, nil, nil) var ctGlyph = CTFontGetGlyphWithName(ctFont, char) let boundingBox = withUnsafePointer(&ctGlyph) { pointer -> CGRect in return CTFontGetBoundingRectsForGlyphs(ctFont, CTFontOrientation.OrientationDefault, pointer, nil, 1) }
The descent I need is just -boundingBox.origin.y . This approach works well for alphabetic, numeric, and numeric characters (see this answer for a graphical representation).
The problem is that for all other letters or numbers (for example: .,#')* ) I get the same bounding box: {x:0.612, y:0.012, w:4.908, h:8.532} . This is clearly wrong.
How can I associate a descent rectangle directly for all characters?
string iso swift core-text
drasto Nov 20 '14 at 20:20 2014-11-20 20:20
source share