簡介
對于很多小型企業和開發人員,要想使用中文字體可能會涉及很多版權問題,蘋果提供了很多系統中文字體,以供免費使用
使用
字體名稱:代碼中使用的字體名稱為PostScript,我們可以在Mac字體冊中查看
NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithCapacity:0];
[dict setValue:@"DFWaWaSC-W5" forKey:NSFontAttributeName];
CTFontDescriptorRef def = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)dict);
NSMutableArray *arr = [[NSMutableArray alloc] initWithObjects:(__bridge id)def, nil];
CFRelease(def);
__block BOOL down = NO;
CTFontDescriptorMatchFontDescriptorsWithProgressHandler((__bridge CFArrayRef)arr, NULL, ^bool(CTFontDescriptorMatchingState state, CFDictionaryRef _Nonnull progressParameter) {
NSDictionary *process = (__bridge NSDictionary *)progressParameter;
double percent = [[process objectForKey:(__bridge id)kCTFontDescriptorMatchingPercentage] doubleValue];
switch (state)
{
case kCTFontDescriptorMatchingDidBegin:
{
}
break;
case kCTFontDescriptorMatchingDidFinish:
{
down = YES;
}
break;
case kCTFontDescriptorMatchingWillBeginQuerying:
{
}
break;
case kCTFontDescriptorMatchingStalled:
{
}
break;
case kCTFontDescriptorMatchingWillBeginDownloading:
{
}
break;
case kCTFontDescriptorMatchingDownloading:
{
}
break;
case kCTFontDescriptorMatchingDidFinishDownloading:
{
}
break;
case kCTFontDescriptorMatchingDidMatch:
{
}
break;
case kCTFontDescriptorMatchingDidFailWithError:
{
}
break;
default:
break;
}
return YES;
});