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;
});
效果如下:
Tags: Black Apple 動態
文章來源: