ctframe

How do you satisfy the 'lineOrigins' argument in CTFrameGetLineOrigins() in Swift? [duplicate]

一曲冷凌霜 提交于 2019-12-23 04:12:36
问题 This question already has an answer here : Issue with CoreText CTFrameGetLineOrigins in Swift (1 answer) Closed last year . I'm trying to figure out CTFrameGetLineOrigins from here: CTFrameGetLineOrigins Got Incorrect Origins, and trying to convert the ObjC to Swift. Obj-C: CFArrayRef lines = CTFrameGetLines(frame); size_t numOfLines = CFArrayGetCount(lines); CGPoint lineOrigins[numOfLines]; CTFrameGetLineOrigins(frame, CFRangeMake(0, 0), lineOrigins); Swift: let lines = CTFrameGetLines(frame

Setting line spacing in a CTFrame

删除回忆录丶 提交于 2019-12-13 02:35:38
问题 I'm working in a kind of QR Code generator, it's a Mac app. I know how draw the text, but I don't know how I can set line spacing. My code: // Prepare font CTFontRef font = CTFontCreateWithName(CFSTR("LucidaSansUnicode"), 16, NULL); // Create Path CGMutablePathRef gpath = CGPathCreateMutable(); CGPathAddRect(gpath, NULL, CGRectMake(10, 0, pixelsWidth, pixelsHigh)); CGContextSetTextDrawingMode (newcontext, kCGTextFill); CGContextSetGrayFillColor(newcontext, 0.0, 1.0); // Create an attributed

How do you satisfy the 'lineOrigins' argument in CTFrameGetLineOrigins() in Swift? [duplicate]

别等时光非礼了梦想. 提交于 2019-12-06 15:56:54
This question already has an answer here : Issue with CoreText CTFrameGetLineOrigins in Swift (1 answer) Closed last year . I'm trying to figure out CTFrameGetLineOrigins from here: CTFrameGetLineOrigins Got Incorrect Origins , and trying to convert the ObjC to Swift. Obj-C: CFArrayRef lines = CTFrameGetLines(frame); size_t numOfLines = CFArrayGetCount(lines); CGPoint lineOrigins[numOfLines]; CTFrameGetLineOrigins(frame, CFRangeMake(0, 0), lineOrigins); Swift: let lines = CTFrameGetLines(frame) let numOfLines: size_t = CFArrayGetCount(lines) let lineOrigins = [CGPoint](repeating: CGPoint.zero,