Below my code is broken into
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);
I am trying to install a font, please help me. Thanks.
+(void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect { // CFStringRef stringRef = (__bridge CFStringRef)textToDraw; // Prepare the text using a Core Text Framesetter NSAttributedString *stringRef=[[[NSAttributedString alloc]initWithString:textToDraw attributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIFont boldSystemFontOfSize:12.0],(NSString*)kCTFontAttributeName, nil]]autorelease]; CFAttributedStringRef currentText =(__bridge CFAttributedStringRef)stringRef; CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(currentText);// at this Line it giving me EXC_BAD_ACCESS CGMutablePathRef framePath = CGPathCreateMutable(); CGPathAddRect(framePath, NULL, frameRect); CFRange currentRange = CFRangeMake(0, 0); CTFrameRef frameRef = CTFramesetterCreateFrame(framesetter, currentRange, framePath, NULL); CGPathRelease(framePath); CGContextRef currentContext = UIGraphicsGetCurrentContext(); CGContextSetTextMatrix(currentContext, CGAffineTransformIdentity); CGContextTranslateCTM(currentContext, 0, frameRect.origin.y*2); CGContextScaleCTM(currentContext, 1.0, -1.0); CTFrameDraw(frameRef, currentContext); CGContextScaleCTM(currentContext, 1.0, -1.0); CGContextTranslateCTM(currentContext, 0, (-1)*frameRect.origin.y*2); CFRelease(frameRef); //CFRelease(currentText); CFRelease(framesetter); //CFRelease(stringRef); }
try it
CTFontRef font = CTFontCreateWithName((CFStringRef)@"Helvetica", 16.0f, nil); CFAttributedStringSetAttribute(currentText,CFRangeMake(0, _stringLength-1),kCTFontAttributeName,font);
Source: https://habr.com/ru/post/1436072/More articles:What is the correct way to reload UIView? - iosBPEL Apache ODE.deployed file - eclipseHow to get the base class for my protobuf-net classes - protobuf-netWhy is my UiProperty no longer editable in GWT Designer? - eclipseGCM (Google Cloud Messaging) bulk with Linux - google-cloud-messagingIs WebRTC available in Chrome 21 for iOS? - google-chromeHow to implement push notifications in Android - javaGCM transfer with curl (php) - androidWhy should I use implicit types (var) when possible? - c #Display text above notification icon in Windows application - c #All Articles