How to calculate word wide high in quartz

I want to calculate word wide heigh in swift, but apear an error is EXC_BREAKPOINT(code=1 subcode=0x******)


this is my code

@available(iOS 8,OSX 10.10, *)
    func drawFontApple() {
        let str:NSMutableAttributedString = NSMutableAttributedString(string: string)
        str.beginEditing()
        var attributes:Dictionary<String,Any> = [String(kCTForegroundColorAttributeName):fontColor.cgColor]
        let ctf:CTFont = CTFontCreateWithName(UIFont.systemFont(ofSize: CGFloat(fontSize)).fontName as CFString?, CGFloat(fontSize) * 2, nil)
        attributes[String(kCTFontAttributeName)] = ctf
        str.addAttributes(attributes, range: NSMakeRange(0, 0))
        str.endEditing()
        let framesetter:CTFramesetter = CTFramesetterCreateWithAttributedString(str)
        let path:CGMutablePath = CGMutablePath()
        if self.size == nil {
            path.addRect(CGRect(x: 0, y: 0, width: CGFloat((getParent()?.size?.Width)!), height: CGFloat((getParent()?.size?.Height)!)))
        }else{
            path.addRect(CGRect(x: 0, y: 0, width: CGFloat((self.size?.Width)!), height: CGFloat((self.size?.Height)!)))
        }
        let frame:CTFrame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, 0), path, nil)
    
        let size:DCSize = drawFontOnIOS(frame)
        let colorSpace:CGColorSpace = CGColorSpaceCreateDeviceRGB()
        let cgc:CGContext = CGContext(data: nil, width: Int(size.Width), height: Int(size.Height), bitsPerComponent: 8, bytesPerRow: 4*Int(size.Width), space: colorSpace, bitmapInfo: CGBitmapInfo.init(rawValue: 1).rawValue)!
        cgc.textMatrix = .identity
        cgc.saveGState()
        cgc.translateBy(x: 0, y: CGFloat(size.Height))
        cgc.scaleBy(x: 1, y: -1)
        CTFrameDraw(frame, cgc)
        self.data = DCImage()
        self.data.btCount = 4
        self.data.bufferSize = UInt32(size.Width*size.Height*4)
        self.data.width = UInt32(size.Width)
        self.data.hight = UInt32(size.Height)
        self.data.bytes = UnsafeRawPointer(cgc.data)
    }



@available(iOS 8,*)
    func drawFontOnIOS(_ frame:CTFrame) -> DCSize {
     
        let path:CGPath = CTFrameGetPath(frame)
        let framRect:CGRect = path.boundingBox
        let lines:CFArray = CTFrameGetLines(frame)
        let numLines:CFIndex = CFArrayGetCount(lines)
        var maxWidth:CGFloat = 0
        var TextHeight:CGFloat = 0
        for index in 0...numLines-1 {
            var ascent:CGFloat = 0
            var descent:CGFloat = 0
            var leading:CGFloat = 0
            var width:CGFloat
            let line:CTLine = CFArrayGetValueAtIndex(lines, index) as! CTLine//EXC_BREAKPOINT......
            width = CGFloat(CTLineGetTypographicBounds(line, &ascent, &descent, &leading))
            if width > maxWidth {
                maxWidth = width
            }
            if index == numLines-1 {
                var lastLineOrigin:CGPoint = CGPoint()
                CTFrameGetLineOrigins(frame, CFRangeMake(numLines-1, 1), &lastLineOrigin)
                TextHeight = framRect.maxY-lastLineOrigin.y+descent
            }
        }
        return DCSize(Width: ceil(Float(maxWidth)), Height: ceil(Float(TextHeight)))
    }


Why is this so, What should I do


frame CTFrame 0x00000001741ae7e0

self DCGameKit_IOS.DCLable 0x00000001741ae700

maxWidth CGFloat 0

TextHeight CGFloat 0

framRect CGRect (origin = (x = 0, y = 0), size = (width = 750, height = 1334))

colorSpace CGColorSpace 0x000000017402ebe0

path CGPath 0x0000000174032e80

lines CFArray 0x0000000174055f30

numLine CFIndex 1

index Int 0

ascent CGFloat 0

descent CGFloat 0

leading CGFloat 0

width CGFloat 3

How to calculate word wide high in quartz
 
 
Q