iOS 6:字体列表
了解 iOS 6 中所使用的字体。
iOS 6 随附安装了下列字体:
|
|
|
了解详情
App 也可以根据需要安装下列字体:
|
|
|
上次修改时间: 2015-2-21
简体中文对应的PostScript名称(下载时使用的名称)
报隶-简 STBaoli-SC-Regular
冬青黑体简体中文 HiraginoSansGB-W3 HiraginoSansGB-W6
黑体-简 STHeitiSC-Light STHeitiSC-Medium
华文仿宋 STFangsong
华文黑体 STXihei STHeiti
华文楷体 STKaiti
华文宋体 STSong
楷体-简 STKaiti-SC-Regular STKaiti-SC-Bold STKaiti-SC-Black
兰亭黑-简 FZLTXHK--GBK1-0 FZLTTHK--GBK1-0 FZLTZHK--GBK1-0
隶变-简 STLibian-SC-Regular
翩翩体-简 HanziPenSC-W3 HanziPenSC-W5
手札体-简 HannotateSC-W5 HannotateSC-W7
宋体-简 STSongti-SC-Regular STSongti-SC-Light STSongti-SC-Bold STSongti-SC-Black
娃娃体-简 DFWaWaSC-W5
魏碑-简 Weibei-SC-Bold
行楷-简 STXingkai-SC-Light STXingkai-SC-Bold
雅痞-简 YuppySC-Regular
圆体-简 STYuanti-SC-Regular STYuanti-SC-Light STYuanti-SC-Bold
例:下载并使用行楷-简(STXingkai-SC-Bold)(粗体)
#import <CoreText/CoreText.h>
textView = [[UITextView alloc] initWithFrame:CGRectMake(0, 0,WIDTH , HEIGHT - 64)];
textView.contentSize = CGSizeMake(WIDTH, 1500);
NSString *text = localizedStrng(@"FAQ_content");
textView.editable = NO;
[self.view addSubview:textView];
//fontName要用对应的PostScript名称,否则,无法下载,行楷-简对应的PostScript名称有两个:STXingkai-SC-Light(细体) 和 STXingkai-SC-Bold(粗体),下面用的是粗体。
NSString *fontName = @"STXingkai-SC-Bold";
// Create a dictionary with the font's PostScript name.
NSMutableDictionary *attrs = [NSMutableDictionary dictionaryWithObjectsAndKeys:fontName, kCTFontNameAttribute, nil];
// Create a new font descriptor reference from the attributes dictionary.
CTFontDescriptorRef desc = CTFontDescriptorCreateWithAttributes((__bridge CFDictionaryRef)attrs);
NSMutableArray *descs = [NSMutableArray arrayWithCapacity:0];
[descs addObject:(__bridge id)desc];
CFRelease(desc);
__block BOOL errorDuringDownload = NO;
// Start processing the font descriptor..
// This function returns immediately, but can potentially take long time to process.
// The progress is notified via the callback block of CTFontDescriptorProgressHandler type.
// See CTFontDescriptor.h for the list of progress states and keys for progressParameter dictionary.
CTFontDescriptorMatchFontDescriptorsWithProgressHandler( (__bridge CFArrayRef)descs, NULL, ^(CTFontDescriptorMatchingState state, CFDictionaryRef progressParameter) {
// NSLog( @"state %d - %@", state, progressParameter);
double progressValue = [[(__bridge NSDictionary *)progressParameter objectForKey:(id)kCTFontDescriptorMatchingPercentage] doubleValue];
if (state == kCTFontDescriptorMatchingDidBegin) {
dispatch_async( dispatch_get_main_queue(), ^ {
// Show something in the text view to indicate that we are downloading
textView.text= [NSString stringWithFormat:@"Downloading %@", fontName];
textView.font = [UIFont systemFontOfSize:16.];
NSLog(@"Begin Matching");
});
} else if (state == kCTFontDescriptorMatchingDidFinish) {
dispatch_async( dispatch_get_main_queue(), ^ {
// Display the sample text for the newly downloaded font
textView.text = text;
textView.font = [UIFont fontWithName:fontName size:16.];
// Log the font URL in the console
CTFontRef fontRef = CTFontCreateWithName((__bridge CFStringRef)fontName, 0., NULL);
CFStringRef fontURL = CTFontCopyAttribute(fontRef, kCTFontURLAttribute);
NSLog(@"%@", (__bridge NSURL*)(fontURL));
CFRelease(fontURL);
CFRelease(fontRef);
if (!errorDuringDownload) {
NSLog(@"%@ downloaded", fontName);
}
});
} else if (state == kCTFontDescriptorMatchingWillBeginDownloading) {
dispatch_async( dispatch_get_main_queue(), ^ {
NSLog(@"Begin Downloading");
});
} else if (state == kCTFontDescriptorMatchingDidFinishDownloading) {
dispatch_async( dispatch_get_main_queue(), ^ {
NSLog(@"Finish downloading");
});
} else if (state == kCTFontDescriptorMatchingDownloading) {
dispatch_async( dispatch_get_main_queue(), ^ {
textView.text= [NSString stringWithFormat:@"Downloading %@ %.0f%%", fontName,progressValue];
NSLog(@"Downloading %.0f%% complete", progressValue);
});
} else if (state == kCTFontDescriptorMatchingDidFailWithError) {
// An error has occurred.
// Get the error message
NSError *error = [(__bridge NSDictionary *)progressParameter objectForKey:(id)kCTFontDescriptorMatchingError];
if (error != nil) {
NSLog(@"Download error: %@", [error description]);
} else {
NSLog(@"ERROR MESSAGE IS NOT AVAILABLE!");
}
}
return (bool)YES;
});
效果如下: