Created
December 2, 2009 03:40
-
-
Save jjgod/246909 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CTFontRef displayFont = CTFontCreateWithName(CFSTR("Andale Mono"), 18.0, NULL); | |
float charWidth = 18.0; | |
CFTypeRef keys[1]; | |
CFTypeRef values[1]; | |
keys[0] = kCTFontFixedAdvanceAttribute; | |
values[0] = CFNumberCreate(nil, kCFNumberFloatType, (void *)&charWidth); | |
CFDictionaryRef fontAttributes = CFDictionaryCreate(NULL, (const void **)keys, (const void **)values, 1, NULL, NULL); | |
CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithAttributes(fontAttributes); | |
CTFontRef displayFont2 = CTFontCreateCopyWithAttributes(displayFont, 0.0, NULL, fontDescriptor); | |
// use the font | |
CFAttributedStringSetAttribute(attrString, CFRangeMake(0, len), kCTFontAttributeName, displayFont2); | |
CFRelease(fontDescriptor); | |
CFRelease(fontAttributes); | |
CFRelease(displayFont2); | |
CFRelease(displayFont); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment