How do I get the font name from an otf or ttf file?

前端 未结 15 1684
-上瘾入骨i
-上瘾入骨i 2020-11-28 03:44

I have used a custom font in my previous app.

The file name was \"ProximaNova-Regular.otf\" and to load the font I just used...

[UIFont fontWithName:         


        
15条回答
  •  佛祖请我去吃肉
    2020-11-28 03:58

    After you've added your fonts to your project/app, add this code (probably just in app delegate didFinishLaunchingWithOptions method) in order to print out all the available fonts for your app. From with-in that list you should be able to identify the font you're after. Don't forget to remove the unnecessary code after.

    for (NSString *fontFamilyName in [UIFont familyNames]) {
        for (NSString *fontName in [UIFont fontNamesForFamilyName:fontFamilyName]) {
            NSLog(@"Family: %@    Font: %@", fontFamilyName, fontName);
        }
    }
    

提交回复
热议问题