简介
对于很多小型企业和开发人员,要想使用中文字体可能会涉及很多版权问题,苹果提供了很多系统中文字体,以供免费使用
使用
字体名称:代码中使用的字体名称为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;
});