I am ultimately trying to get per-character font metrics from a line of text.
Using CTFramesetter
I've converted a swift String
into lines by following this post (and converting from Obj-C to Swift.
The simplified code below gives me the error Cannot convert value of type 'UnsafeRawPointer?' to expected argument type 'CTLine'
(error on theLine
)
let lines : CFArray = CTFrameGetLines(ctFrame)
var ascent : CGFloat
var descent : CGFloat
var leading : CGFloat
var theLine = CFArrayGetValueAtIndex(lines, 0)
let lineWidth = CTLineGetTypographicBounds(theLine, &ascent, &descent, &leading) // ERROR HERE
print("lineWidth \(lineWidth), ascent \(ascent), descent \(descent)")
I'm new to Swift but I've tried many things all to no avail. How can I fix it?