Here is the solution. These features are deprecated in favor of the body text. He is much more advanced, but takes time to understand. This sample draws "Hello World!" using courier font.
- (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CFStringRef font_name = CFStringCreateWithCString(NULL, "Courier", kCFStringEncodingMacRoman); CTFontRef font = CTFontCreateWithName(font_name, 36.0, NULL); CFStringRef keys[] = { kCTFontAttributeName }; CFTypeRef values[] = { font }; CFDictionaryRef font_attributes = CFDictionaryCreate(kCFAllocatorDefault, (const void **)&keys, (const void **)&values, sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); CFRelease(font_name); CFRelease(font); int x = 10; int y = 10; const char *text = "Hello World!"; CFStringRef string = CFStringCreateWithCString(NULL, text, kCFStringEncodingMacRoman); CFAttributedStringRef attr_string = CFAttributedStringCreate(NULL, string, font_attributes); CTLineRef line = CTLineCreateWithAttributedString(attr_string); CGContextSetTextPosition(context, x, y);

source share