cocos2d-x 添加自定义字体---中文,英文

1: 找到字体   xxx.ttf

2: 在xcode工程的 Info.plist文件中添加key

  Fonts provided by application,   或者 UIAppFonts(raw key)

value写xxx.ttf

3:  使用代码

    CCLabelTTF* chnTLabel = CCLabelTTF::create(wordsStr->getCString(), xxx.ttf, );

PS:

字体文件的"文件名"很多时候不是真实的 "字体名", 这样是无法使用的.

要找出真实的"字体名"才行.

方法:  比较在 Info.plist添加字体前后的区别, 来辨别添加了哪些字体.(如果有更好的方法请留言).

- (void)listFonts
{
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=; indFamily<[familyNames count]; ++indFamily)
{
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]];
for (indFont=; indFont<[fontNames count]; ++indFont)
{
NSLog(@" Font name: %@", [fontNames objectAtIndex:indFont]);
}
[fontNames release];
} [familyNames release];
}

打印结果:

-- ::25.011 TestChnFonts[:c07] Family name: Thonburi
-- ::25.012 TestChnFonts[:c07] Font name: Thonburi-Bold
-- ::25.013 TestChnFonts[:c07] Font name: Thonburi
-- ::25.013 TestChnFonts[:c07] Family name: Snell Roundhand
-- ::25.013 TestChnFonts[:c07] Font name: SnellRoundhand-Bold
-- ::25.014 TestChnFonts[:c07] Font name: SnellRoundhand-Black
-- ::25.014 TestChnFonts[:c07] Font name: SnellRoundhand
-- ::25.015 TestChnFonts[:c07] Family name: Academy Engraved LET
-- ::25.015 TestChnFonts[:c07] Font name: AcademyEngravedLetPlain
-- ::25.016 TestChnFonts[:c07] Family name: Avenir
-- ::25.016 TestChnFonts[:c07] Font name: Avenir-LightOblique
-- ::25.016 TestChnFonts[:c07] Font name: Avenir-MediumOblique
-- ::25.017 TestChnFonts[:c07] Font name: Avenir-Medium
-- ::25.017 TestChnFonts[:c07] Font name: Avenir-HeavyOblique
-- ::25.018 TestChnFonts[:c07] Font name: Avenir-BlackOblique
-- ::25.018 TestChnFonts[:c07] Font name: Avenir-Oblique
-- ::25.019 TestChnFonts[:c07] Font name: Avenir-Book
-- ::25.019 TestChnFonts[:c07] Font name: Avenir-Roman
-- ::25.019 TestChnFonts[:c07] Font name: Avenir-BookOblique
-- ::25.020 TestChnFonts[:c07] Font name: Avenir-Light
-- ::25.020 TestChnFonts[:c07] Font name: Avenir-Heavy
-- ::25.021 TestChnFonts[:c07] Font name: Avenir-Black
-- ::25.021 TestChnFonts[:c07] Family name: Marker Felt
-- ::25.022 TestChnFonts[:c07] Font name: MarkerFelt-Wide
-- ::25.022 TestChnFonts[:c07] Font name: MarkerFelt-Thin
-- ::25.022 TestChnFonts[:c07] Family name: Geeza Pro
-- ::25.023 TestChnFonts[:c07] Font name: GeezaPro-Bold
-- ::25.023 TestChnFonts[:c07] Font name: GeezaPro
-- ::25.024 TestChnFonts[:c07] Family name: Arial Rounded MT Bold
-- ::25.024 TestChnFonts[:c07] Font name: ArialRoundedMTBold
-- ::25.025 TestChnFonts[:c07] Family name: Trebuchet MS
-- ::25.025 TestChnFonts[:c07] Font name: TrebuchetMS
-- ::25.026 TestChnFonts[:c07] Font name: TrebuchetMS-Bold
-- ::25.026 TestChnFonts[:c07] Font name: TrebuchetMS-Italic
-- ::25.027 TestChnFonts[:c07] Font name: Trebuchet-BoldItalic
-- ::25.027 TestChnFonts[:c07] Family name: Arial
-- ::25.028 TestChnFonts[:c07] Font name: Arial-BoldMT
-- ::25.028 TestChnFonts[:c07] Font name: ArialMT
-- ::25.028 TestChnFonts[:c07] Font name: Arial-ItalicMT
-- ::25.029 TestChnFonts[:c07] Font name: Arial-BoldItalicMT
-- ::25.029 TestChnFonts[:c07] Family name: Marion
-- ::25.030 TestChnFonts[:c07] Font name: Marion-Regular
-- ::25.030 TestChnFonts[:c07] Font name: Marion-Bold
-- ::25.031 TestChnFonts[:c07] Font name: Marion-Italic
-- ::25.031 TestChnFonts[:c07] Family name: Gurmukhi MN
-- ::25.031 TestChnFonts[:c07] Font name: GurmukhiMN
-- ::25.032 TestChnFonts[:c07] Font name: GurmukhiMN-Bold
-- ::25.033 TestChnFonts[:c07] Family name: Malayalam Sangam MN
-- ::25.033 TestChnFonts[:c07] Font name: MalayalamSangamMN-Bold
-- ::25.034 TestChnFonts[:c07] Font name: MalayalamSangamMN
-- ::25.034 TestChnFonts[:c07] Family name: Bradley Hand
-- ::25.035 TestChnFonts[:c07] Font name: BradleyHandITCTT-Bold
-- ::25.035 TestChnFonts[:c07] Family name: Kannada Sangam MN
-- ::25.036 TestChnFonts[:c07] Font name: KannadaSangamMN
-- ::25.036 TestChnFonts[:c07] Font name: KannadaSangamMN-Bold
-- ::25.037 TestChnFonts[:c07] Family name: Bodoni Oldstyle
-- ::25.037 TestChnFonts[:c07] Font name: BodoniSvtyTwoOSITCTT-Book
-- ::25.038 TestChnFonts[:c07] Font name: BodoniSvtyTwoOSITCTT-Bold
-- ::25.038 TestChnFonts[:c07] Font name: BodoniSvtyTwoOSITCTT-BookIt
-- ::25.039 TestChnFonts[:c07] Family name: A Damn Mess
-- ::25.039 TestChnFonts[:c07] Font name: A_Damn_Mess
-- ::25.039 TestChnFonts[:c07] Family name: Cochin
-- ::25.040 TestChnFonts[:c07] Font name: Cochin
-- ::25.040 TestChnFonts[:c07] Font name: Cochin-BoldItalic
-- ::25.041 TestChnFonts[:c07] Font name: Cochin-Italic
-- ::25.041 TestChnFonts[:c07] Font name: Cochin-Bold
-- ::25.042 TestChnFonts[:c07] Family name: Sinhala Sangam MN
-- ::25.042 TestChnFonts[:c07] Font name: SinhalaSangamMN
-- ::25.043 TestChnFonts[:c07] Font name: SinhalaSangamMN-Bold
-- ::25.043 TestChnFonts[:c07] Family name: Hiragino Kaku Gothic ProN
-- ::25.043 TestChnFonts[:c07] Font name: HiraKakuProN-W6
-- ::25.044 TestChnFonts[:c07] Font name: HiraKakuProN-W3
-- ::25.044 TestChnFonts[:c07] Family name: Papyrus
-- ::25.045 TestChnFonts[:c07] Font name: Papyrus-Condensed
-- ::25.045 TestChnFonts[:c07] Font name: Papyrus
-- ::25.046 TestChnFonts[:c07] Family name: Verdana
-- ::25.046 TestChnFonts[:c07] Font name: Verdana
-- ::25.047 TestChnFonts[:c07] Font name: Verdana-Bold
-- ::25.047 TestChnFonts[:c07] Font name: Verdana-BoldItalic
-- ::25.048 TestChnFonts[:c07] Font name: Verdana-Italic
-- ::25.048 TestChnFonts[:c07] Family name: Zapf Dingbats
-- ::25.049 TestChnFonts[:c07] Font name: ZapfDingbatsITC
-- ::25.049 TestChnFonts[:c07] Family name: Avenir Next Condensed
-- ::25.050 TestChnFonts[:c07] Font name: AvenirNextCondensed-HeavyItalic
-- ::25.050 TestChnFonts[:c07] Font name: AvenirNextCondensed-DemiBold
-- ::25.051 TestChnFonts[:c07] Font name: AvenirNextCondensed-Italic
-- ::25.051 TestChnFonts[:c07] Font name: AvenirNextCondensed-Heavy
-- ::25.051 TestChnFonts[:c07] Font name: AvenirNextCondensed-DemiBoldItalic
-- ::25.052 TestChnFonts[:c07] Font name: AvenirNextCondensed-Medium
-- ::25.052 TestChnFonts[:c07] Font name: AvenirNextCondensed-BoldItalic
-- ::25.053 TestChnFonts[:c07] Font name: AvenirNextCondensed-Bold
-- ::25.053 TestChnFonts[:c07] Font name: AvenirNextCondensed-UltraLightItalic
-- ::25.054 TestChnFonts[:c07] Font name: AvenirNextCondensed-UltraLight
-- ::25.054 TestChnFonts[:c07] Font name: AvenirNextCondensed-MediumItalic
-- ::25.054 TestChnFonts[:c07] Font name: AvenirNextCondensed-Regular
-- ::25.055 TestChnFonts[:c07] Family name: Courier
-- ::25.056 TestChnFonts[:c07] Font name: Courier-Bold
-- ::25.056 TestChnFonts[:c07] Font name: Courier
-- ::25.056 TestChnFonts[:c07] Font name: Courier-BoldOblique
-- ::25.057 TestChnFonts[:c07] Font name: Courier-Oblique
-- ::25.057 TestChnFonts[:c07] Family name: Hoefler Text
-- ::25.058 TestChnFonts[:c07] Font name: HoeflerText-Black
-- ::25.058 TestChnFonts[:c07] Font name: HoeflerText-Italic
-- ::25.059 TestChnFonts[:c07] Font name: HoeflerText-Regular
-- ::25.059 TestChnFonts[:c07] Font name: HoeflerText-BlackItalic
-- ::25.060 TestChnFonts[:c07] Family name: Helvetica
-- ::25.060 TestChnFonts[:c07] Font name: Helvetica-LightOblique
-- ::25.060 TestChnFonts[:c07] Font name: Helvetica
-- ::25.061 TestChnFonts[:c07] Font name: Helvetica-Oblique
-- ::25.061 TestChnFonts[:c07] Font name: Helvetica-BoldOblique
-- ::25.062 TestChnFonts[:c07] Font name: Helvetica-Bold
-- ::25.062 TestChnFonts[:c07] Font name: Helvetica-Light
-- ::25.063 TestChnFonts[:c07] Family name: Euphemia UCAS
-- ::25.063 TestChnFonts[:c07] Font name: EuphemiaUCAS-Bold
-- ::25.064 TestChnFonts[:c07] Font name: EuphemiaUCAS
-- ::25.064 TestChnFonts[:c07] Font name: EuphemiaUCAS-Italic
-- ::25.064 TestChnFonts[:c07] Family name: STKaiti
-- ::25.065 TestChnFonts[:c07] Font name: STKaiti
-- ::25.066 TestChnFonts[:c07] Family name: Hiragino Mincho ProN
-- ::25.066 TestChnFonts[:c07] Font name: HiraMinProN-W3
-- ::25.066 TestChnFonts[:c07] Font name: HiraMinProN-W6
-- ::25.067 TestChnFonts[:c07] Family name: Bodoni Ornaments
-- ::25.067 TestChnFonts[:c07] Font name: BodoniOrnamentsITCTT
-- ::25.068 TestChnFonts[:c07] Family name: Apple Color Emoji
-- ::25.068 TestChnFonts[:c07] Font name: AppleColorEmoji
-- ::25.069 TestChnFonts[:c07] Family name: Optima
-- ::25.069 TestChnFonts[:c07] Font name: Optima-ExtraBlack
-- ::25.069 TestChnFonts[:c07] Font name: Optima-Italic
-- ::25.070 TestChnFonts[:c07] Font name: Optima-Regular
-- ::25.070 TestChnFonts[:c07] Font name: Optima-BoldItalic
-- ::25.071 TestChnFonts[:c07] Font name: Optima-Bold
-- ::25.071 TestChnFonts[:c07] Family name: Gujarati Sangam MN
-- ::25.072 TestChnFonts[:c07] Font name: GujaratiSangamMN
-- ::25.072 TestChnFonts[:c07] Font name: GujaratiSangamMN-Bold
-- ::25.094 TestChnFonts[:c07] Family name: Devanagari Sangam MN
-- ::25.095 TestChnFonts[:c07] Font name: DevanagariSangamMN
-- ::25.095 TestChnFonts[:c07] Font name: DevanagariSangamMN-Bold
-- ::25.096 TestChnFonts[:c07] Family name: Times New Roman
-- ::25.097 TestChnFonts[:c07] Font name: TimesNewRomanPS-ItalicMT
-- ::25.097 TestChnFonts[:c07] Font name: TimesNewRomanPS-BoldMT
-- ::25.099 TestChnFonts[:c07] Font name: TimesNewRomanPSMT
-- ::25.100 TestChnFonts[:c07] Font name: TimesNewRomanPS-BoldItalicMT
-- ::25.101 TestChnFonts[:c07] Family name: Kailasa
-- ::25.102 TestChnFonts[:c07] Font name: Kailasa
-- ::25.103 TestChnFonts[:c07] Font name: Kailasa-Bold
-- ::25.103 TestChnFonts[:c07] Family name: Telugu Sangam MN
-- ::25.104 TestChnFonts[:c07] Font name: TeluguSangamMN-Bold
-- ::25.105 TestChnFonts[:c07] Font name: TeluguSangamMN
-- ::25.106 TestChnFonts[:c07] Family name: Heiti SC
-- ::25.106 TestChnFonts[:c07] Font name: STHeitiSC-Medium
-- ::25.107 TestChnFonts[:c07] Font name: STHeitiSC-Light
-- ::25.108 TestChnFonts[:c07] Family name: Apple SD Gothic Neo
-- ::25.109 TestChnFonts[:c07] Font name: AppleSDGothicNeo-Bold
-- ::25.109 TestChnFonts[:c07] Font name: AppleSDGothicNeo-Medium
-- ::25.110 TestChnFonts[:c07] Family name: Futura
-- ::25.111 TestChnFonts[:c07] Font name: Futura-Medium
-- ::25.112 TestChnFonts[:c07] Font name: Futura-CondensedExtraBold
-- ::25.112 TestChnFonts[:c07] Font name: Futura-CondensedMedium
-- ::25.113 TestChnFonts[:c07] Font name: Futura-MediumItalic
-- ::25.114 TestChnFonts[:c07] Family name: Bodoni
-- ::25.114 TestChnFonts[:c07] Font name: BodoniSvtyTwoITCTT-BookIta
-- ::25.116 TestChnFonts[:c07] Font name: BodoniSvtyTwoITCTT-Book
-- ::25.117 TestChnFonts[:c07] Font name: BodoniSvtyTwoITCTT-Bold
-- ::25.117 TestChnFonts[:c07] Family name: Baskerville
-- ::25.118 TestChnFonts[:c07] Font name: Baskerville-SemiBoldItalic
-- ::25.118 TestChnFonts[:c07] Font name: Baskerville-Bold
-- ::25.119 TestChnFonts[:c07] Font name: Baskerville-Italic
-- ::25.119 TestChnFonts[:c07] Font name: Baskerville-BoldItalic
-- ::25.119 TestChnFonts[:c07] Font name: Baskerville-SemiBold
-- ::25.120 TestChnFonts[:c07] Font name: Baskerville
-- ::25.120 TestChnFonts[:c07] Family name: Chalkboard SE
-- ::25.121 TestChnFonts[:c07] Font name: ChalkboardSE-Regular
-- ::25.121 TestChnFonts[:c07] Font name: ChalkboardSE-Bold
-- ::25.121 TestChnFonts[:c07] Font name: ChalkboardSE-Light
-- ::25.122 TestChnFonts[:c07] Family name: Heiti TC
-- ::25.130 TestChnFonts[:c07] Font name: STHeitiTC-Medium
-- ::25.131 TestChnFonts[:c07] Font name: STHeitiTC-Light
-- ::25.132 TestChnFonts[:c07] Family name: Copperplate
-- ::25.132 TestChnFonts[:c07] Font name: Copperplate
-- ::25.133 TestChnFonts[:c07] Font name: Copperplate-Light
-- ::25.133 TestChnFonts[:c07] Font name: Copperplate-Bold
-- ::25.134 TestChnFonts[:c07] Family name: Party LET
-- ::25.135 TestChnFonts[:c07] Font name: PartyLetPlain
-- ::25.135 TestChnFonts[:c07] Family name: American Typewriter
-- ::25.135 TestChnFonts[:c07] Font name: AmericanTypewriter-CondensedLight
-- ::25.136 TestChnFonts[:c07] Font name: AmericanTypewriter-Light
-- ::25.136 TestChnFonts[:c07] Font name: AmericanTypewriter-Bold
-- ::25.136 TestChnFonts[:c07] Font name: AmericanTypewriter
-- ::25.137 TestChnFonts[:c07] Font name: AmericanTypewriter-CondensedBold
-- ::25.137 TestChnFonts[:c07] Font name: AmericanTypewriter-Condensed
-- ::25.138 TestChnFonts[:c07] Family name: Symbol
-- ::25.138 TestChnFonts[:c07] Font name: Symbol
-- ::25.139 TestChnFonts[:c07] Family name: Avenir Next
-- ::25.139 TestChnFonts[:c07] Font name: AvenirNext-Heavy
-- ::25.140 TestChnFonts[:c07] Font name: AvenirNext-DemiBoldItalic
-- ::25.140 TestChnFonts[:c07] Font name: AvenirNext-UltraLightItalic
-- ::25.140 TestChnFonts[:c07] Font name: AvenirNext-HeavyItalic
-- ::25.141 TestChnFonts[:c07] Font name: AvenirNext-MediumItalic
-- ::25.141 TestChnFonts[:c07] Font name: AvenirNext-UltraLight
-- ::25.142 TestChnFonts[:c07] Font name: AvenirNext-BoldItalic
-- ::25.142 TestChnFonts[:c07] Font name: AvenirNext-DemiBold
-- ::25.143 TestChnFonts[:c07] Font name: AvenirNext-Bold
-- ::25.143 TestChnFonts[:c07] Font name: AvenirNext-Regular
-- ::25.144 TestChnFonts[:c07] Font name: AvenirNext-Medium
-- ::25.144 TestChnFonts[:c07] Font name: AvenirNext-Italic
-- ::25.145 TestChnFonts[:c07] Family name: Noteworthy
-- ::25.145 TestChnFonts[:c07] Font name: Noteworthy-Light
-- ::25.145 TestChnFonts[:c07] Font name: Noteworthy-Bold
-- ::25.146 TestChnFonts[:c07] Family name: Bangla Sangam MN
-- ::25.146 TestChnFonts[:c07] Font name: BanglaSangamMN-Bold
-- ::25.147 TestChnFonts[:c07] Font name: BanglaSangamMN
-- ::25.147 TestChnFonts[:c07] Family name: Zapfino
-- ::25.147 TestChnFonts[:c07] Font name: Zapfino
-- ::25.148 TestChnFonts[:c07] Family name: Tamil Sangam MN
-- ::25.148 TestChnFonts[:c07] Font name: TamilSangamMN
-- ::25.149 TestChnFonts[:c07] Font name: TamilSangamMN-Bold
-- ::25.149 TestChnFonts[:c07] Family name: Chalkduster
-- ::25.150 TestChnFonts[:c07] Font name: Chalkduster
-- ::25.164 TestChnFonts[:c07] Family name: Arial Hebrew
-- ::25.164 TestChnFonts[:c07] Font name: ArialHebrew
-- ::25.165 TestChnFonts[:c07] Font name: ArialHebrew-Bold
-- ::25.166 TestChnFonts[:c07] Family name: Georgia
-- ::25.166 TestChnFonts[:c07] Font name: Georgia-Italic
-- ::25.167 TestChnFonts[:c07] Font name: Georgia-BoldItalic
-- ::25.167 TestChnFonts[:c07] Font name: Georgia-Bold
-- ::25.168 TestChnFonts[:c07] Font name: Georgia
-- ::25.168 TestChnFonts[:c07] Family name: Helvetica Neue
-- ::25.169 TestChnFonts[:c07] Font name: HelveticaNeue-Bold
-- ::25.169 TestChnFonts[:c07] Font name: HelveticaNeue-CondensedBlack
-- ::25.170 TestChnFonts[:c07] Font name: HelveticaNeue-Medium
-- ::25.170 TestChnFonts[:c07] Font name: HelveticaNeue
-- ::25.171 TestChnFonts[:c07] Font name: HelveticaNeue-Light
-- ::25.171 TestChnFonts[:c07] Font name: HelveticaNeue-CondensedBold
-- ::25.172 TestChnFonts[:c07] Font name: HelveticaNeue-LightItalic
-- ::25.172 TestChnFonts[:c07] Font name: HelveticaNeue-UltraLightItalic
-- ::25.172 TestChnFonts[:c07] Font name: HelveticaNeue-UltraLight
-- ::25.173 TestChnFonts[:c07] Font name: HelveticaNeue-BoldItalic
-- ::25.173 TestChnFonts[:c07] Font name: HelveticaNeue-Italic
-- ::25.174 TestChnFonts[:c07] Family name: Gill Sans
-- ::25.174 TestChnFonts[:c07] Font name: GillSans-LightItalic
-- ::25.175 TestChnFonts[:c07] Font name: GillSans-BoldItalic
-- ::25.175 TestChnFonts[:c07] Font name: GillSans-Italic
-- ::25.176 TestChnFonts[:c07] Font name: GillSans
-- ::25.176 TestChnFonts[:c07] Font name: GillSans-Bold
-- ::25.177 TestChnFonts[:c07] Font name: GillSans-Light
-- ::25.177 TestChnFonts[:c07] Family name: Palatino
-- ::25.178 TestChnFonts[:c07] Font name: Palatino-Roman
-- ::25.178 TestChnFonts[:c07] Font name: Palatino-Bold
-- ::25.178 TestChnFonts[:c07] Font name: Palatino-BoldItalic
-- ::25.179 TestChnFonts[:c07] Font name: Palatino-Italic
-- ::25.179 TestChnFonts[:c07] Family name: Courier New
-- ::25.180 TestChnFonts[:c07] Font name: CourierNewPS-BoldMT
-- ::25.180 TestChnFonts[:c07] Font name: CourierNewPSMT
-- ::25.181 TestChnFonts[:c07] Font name: CourierNewPS-BoldItalicMT
-- ::25.181 TestChnFonts[:c07] Font name: CourierNewPS-ItalicMT
-- ::25.181 TestChnFonts[:c07] Family name: Oriya Sangam MN
-- ::25.182 TestChnFonts[:c07] Font name: OriyaSangamMN-Bold
-- ::25.182 TestChnFonts[:c07] Font name: OriyaSangamMN
-- ::25.183 TestChnFonts[:c07] Family name: Didot
-- ::25.183 TestChnFonts[:c07] Font name: Didot-Italic
-- ::25.184 TestChnFonts[:c07] Font name: Didot
-- ::25.184 TestChnFonts[:c07] Font name: Didot-Bold
-- ::25.185 TestChnFonts[:c07] Family name: Bodoni Smallcaps
-- ::25.186 TestChnFonts[:c07] Font name: BodoniSvtyTwoSCITCTT-Book
上一篇:重装系统必做之——更换Windows系统的默认临时文件的存储目录


下一篇:使用Let’s Encrypt轻松配置https站点