2013年6月5日星期三

Using customized font in iOS, some thing to be noticed


1,add Font lib (.ttf or .odf) into Xcode Project,like FZKATJW.TTF (FangzhengKatong lib)。
2,add 'Fonts provided by application' in info.plist (and set item0's value as FZKATJW.TTF, add other font libs like this as well. Notice,suffix like .ttf or .otf should be added too).
3,Using the following code to print out the 'FontName' of the font we added in iOS runtime.
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
    NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
    fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]];
    for (indFont=0; indFont<[fontNames count]; ++indFont)
    {
        NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
    }
}
In my case the print info is like this:
2013-05-22 09:26:44.749 taobao4baby[502:c07] Family name: FZKaTong-M19S
2013-05-22 09:26:44.749 taobao4baby[502:c07] -Font name: FZKATJW--GB1-0
So we using the font with this code:
[UIFont fontWithName:@"FZKATJW--GB1-0" size:16]
Now you can using the new customized font freely~



------

My new business with my wife, wholesale meddle-to-high end men's seamless underwear in the Netherlands: https://ecosharelife.com

没有评论:

发表评论