Skip to content

Instantly share code, notes, and snippets.

@cxa
Created April 21, 2012 14:17
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cxa/2437310 to your computer and use it in GitHub Desktop.
Save cxa/2437310 to your computer and use it in GitHub Desktop.
CTFont with kCTFontCascadeListAttribute
CGFloat pointSize = 17.0;
CTFontDescriptorRef descLatin = CTFontDescriptorCreateWithNameAndSize(CFSTR("TimesNewRomanPSMT"), pointSize);
CTFontDescriptorRef descZh = CTFontDescriptorCreateWithNameAndSize(CFSTR("STHeitiSC-Light"), pointSize);
NSArray *cascade = [NSArray arrayWithObjects:(id)descLatin, (id)descZh, nil];
NSDictionary *attrs = [NSDictionary dictionaryWithObject:cascade forKey:(id)kCTFontCascadeListAttribute];
CTFontDescriptorRef desc = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)attrs);
CTFontRef font = CTFontCreateWithFontDescriptor(desc, pointSize, NULL);
// use the font
...
CFRelease(descLatin);
CFRelease(descZh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment