提问人:sivan 提问时间:12/8/2022 最后编辑:sivan 更新时间:12/8/2022 访问量:129
IOS:如何在我的应用中列出已安装的自定义字体
IOS: How to list an already installed custom font in my app
问:
我正在为 iPad 构建一个应用程序,并希望在我的 ipad 中使用已安装的自定义字体。我从Adobe Creative Cloud Suite下载了自定义字体(Cabin Sketch)。安装后,我能够在“常规>字体”中看到字体
在我的代码中,我尝试打印系统中所有可用的字体,但无法看到已安装的字体。
以下是我尝试打印字体系列的代码。
NSDictionary *descriptorOptions = @{(id)kCTFontDownloadedAttribute : @YES}; // tried kCTFontDownloadableAttribute too
CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)descriptorOptions);
CFArrayRef fontDescriptors = CTFontDescriptorCreateMatchingFontDescriptors(descriptor, NULL);
for(UIFontDescriptor *descriptor in (NSArray *)CFBridgingRelease(fontDescriptors)) {
NSString *fontFamilyName = [descriptor objectForKey:UIFontDescriptorFamilyAttribute];
NSLog(@"Font Family Name = %@", fontFamilyName);
}
NSArray *familyNames = [UIFont familyNames];
for (NSString *aFamilyName in familyNames) {
NSArray *fontNames = [UIFont fontNamesForFamilyName:aFamilyName];
for (NSString *aFontName in fontNames) {
NSLog(@"%@", aFontName);
}
}
QCFType<CFArrayRef> familyNames = CTFontManagerCopyAvailableFontFamilyNames();
for (NSString *familyName in familyNames.as<const NSArray *>())
NSLog(@"%@", familyName);
提前致谢。
答: 暂无答案
评论
UIFontPickerViewController