iphone - Can't add custom font to application -
i having trouble using custom font in application.
the following describes steps took
1 - add .ttf font application
2 - modify info.plist file.
3 - add key "fonts provided application" new row
4 - , add each .ttf file (of font) each line.
so have array of fonts, each of has .ttf extension.
and try add font
uilabel *lblname = [[uilabel alloc] initwithframe:cgrectmake(25, 65, 230, 33)]; lblname.backgroundcolor = [uicolor clearcolor]; [lblname setfont: [uifont fontwithname:@"acmesab" size:32]]; // acmesab custom "font" name. lblname.textalignment = nstextalignmentleft; lblname.text = @"name:"; [simapleview addsubview:lblname];
open project -> targeta -> build phase -> copy bundle resources. check files shows in list or not? if not add them , run application again.it should work.
use following code check whether font added or not , add appropriate font name listing.
nsarray *familynames = [[nsarray alloc] initwitharray:[uifont familynames]]; nsarray *fontnames; nsinteger indfamily, indfont; (indfamily=0; indfamily<[familynames count]; ++indfamily) { nslog(@"family name: %@", [familynames objectatindex:indfamily]); fontnames = [[nsarray alloc] initwitharray: [uifont fontnamesforfamilyname: [familynames objectatindex:indfamily]]]; (indfont=0; indfont<[fontnames count]; ++indfont) { nslog(@" font name: %@", [fontnames objectatindex:indfont]); } [fontnames release]; } [familynames release];
Comments
Post a Comment