たとえば IB で Helvetica を選んで「ボールド・イタリック」を選択した場合、Font欄には『Helvetica Bold Oblique』と表示されます。
で、これを真に受けてプログラム側でフォントを指定したい場合に、
self.hogeLabel.font = [UIFont fontWithName:@"Helvetica Bold Oblique" size:10.0];
なんてやってしまったら、そんな名前のフォント名はないってことでデフォルトフォント、デフォルトサイズにされてしまいます。
(正しい名前は"Helvetica-BoldOblique")
UIFont に渡すべき fontName は UIFont のメソッドから取れるのですが、毎回それやるのも面倒なので、こちらに載せておきます。
(このようなコードでログにはかせただけのものです)
NSArray *familyNames = [UIFont familyNames]; for (NSString *aFamilyName in familyNames) { NSLog(@"family:%@", aFamilyName); NSLog(@"%@", [UIFont fontNamesForFamilyName:aFamilyName]); }
UIFont で扱うフォント名一覧
family:Arial Hebrew ( ArialHebrew, "ArialHebrew-Bold" ) family:Zapfino ( Zapfino ) family:Oriya Sangam MN ( "OriyaSangamMN-Bold", OriyaSangamMN ) family:Cochin ( "Cochin-BoldItalic", Cochin, "Cochin-Bold", "Cochin-Italic" ) family:Baskerville ( Baskerville, "Baskerville-Italic", "Baskerville-BoldItalic", "Baskerville-Bold" ) family:Palatino ( "Palatino-Roman", "Palatino-BoldItalic", "Palatino-Italic", "Palatino-Bold" ) family:Chalkboard SE ( "ChalkboardSE-Bold", "ChalkboardSE-Regular" ) family:Gurmukhi MN ( "GurmukhiMN-Bold", GurmukhiMN ) family:Verdana ( Verdana, "Verdana-Bold", "Verdana-BoldItalic", "Verdana-Italic" ) family:Tamil Sangam MN ( "TamilSangamMN-Bold", TamilSangamMN ) family:Marker Felt ( "MarkerFelt-Thin", "MarkerFelt-Wide" ) family:Courier New ( "CourierNewPS-BoldItalicMT", "CourierNewPS-BoldMT", "CourierNewPS-ItalicMT", CourierNewPSMT ) family:Courier ( "Courier-Bold", Courier, "Courier-BoldOblique", "Courier-Oblique" ) family:Trebuchet MS ( "TrebuchetMS-Italic", "TrebuchetMS-Bold", TrebuchetMS, "Trebuchet-BoldItalic" ) family:DB LCD Temp ( DBLCDTempBlack ) family:Apple Color Emoji ( AppleColorEmoji ) family:Arial Rounded MT Bold ( ArialRoundedMTBold ) family:Bangla Sangam MN ( "BanglaSangamMN-Bold", BanglaSangamMN ) family:Telugu Sangam MN ( TeluguSangamMN, "TeluguSangamMN-Bold" ) family:American Typewriter ( AmericanTypewriter, "AmericanTypewriter-Bold" ) family:Arial ( "Arial-ItalicMT", "Arial-BoldItalicMT", ArialMT, "Arial-BoldMT" ) family:Kailasa ( "Kailasa-Bold", Kailasa ) family:AppleGothic ( AppleGothic ) family:Hiragino Kaku Gothic ProN ( "HiraKakuProN-W6", "HiraKakuProN-W3" ) family:Heiti SC ( "STHeitiSC-Medium", "STHeitiSC-Light" ) family:Malayalam Sangam MN ( "MalayalamSangamMN-Bold", MalayalamSangamMN ) family:Thonburi ( "Thonburi-Bold", Thonburi ) family:Helvetica ( "Helvetica-BoldOblique", Helvetica, "Helvetica-Bold", "Helvetica-Oblique" ) family:Noteworthy ( "Noteworthy-Bold", "Noteworthy-Light" ) family:Gujarati Sangam MN ( GujaratiSangamMN, "GujaratiSangamMN-Bold" ) family:Heiti K ( "STHeitiK-Medium", "STHeitiK-Light" ) family:Futura ( "Futura-MediumItalic", "Futura-CondensedExtraBold", "Futura-Medium" ) family:Devanagari Sangam MN ( "DevanagariSangamMN-Bold", DevanagariSangamMN ) family:Heiti TC ( "STHeitiTC-Light", "STHeitiTC-Medium" ) family:Sinhala Sangam MN ( "SinhalaSangamMN-Bold", SinhalaSangamMN ) family:Kannada Sangam MN ( KannadaSangamMN, "KannadaSangamMN-Bold" ) family:Georgia ( "Georgia-BoldItalic", Georgia, "Georgia-Bold", "Georgia-Italic" ) family:Heiti J ( "STHeitiJ-Medium", "STHeitiJ-Light" ) family:Times New Roman ( "TimesNewRomanPS-BoldItalicMT", "TimesNewRomanPS-ItalicMT", TimesNewRomanPSMT, "TimesNewRomanPS-BoldMT" ) family:Snell Roundhand ( SnellRoundhand, "SnellRoundhand-Bold" ) family:Geeza Pro ( GeezaPro, "GeezaPro-Bold" ) family:Helvetica Neue ( "HelveticaNeue-Italic", "HelveticaNeue-Bold", "HelveticaNeue-BoldItalic", HelveticaNeue )