-
-
Save TimurAykutYildirim/51ee265e3a72febdd961662f30e9a20e to your computer and use it in GitHub Desktop.
How to list fonts in an iOS project with Objective-C
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Add following loop somewhere in your view. | |
| It will list all the fonts and type names (which you need to write properly or app will crash) | |
| In my case, i did presume like this: | |
| #define FONT_LIGHT @"SF-Pro-Text-Light" | |
| #define FONT_REGULAR @"SF-Pro-Text-Regular" | |
| #define FONT_MEDIUM @"SF-Pro-Text-Medium" | |
| #define FONT_BOLD @"SF-Pro-Text-Bold" | |
| #define FONT_BLACK @"SF-Pro-Text-Heavy" | |
| but when i run the code i see it like this: | |
| (myViewController.m:147) SF Pro Text | |
| (myViewController.m:151) SFProText-Heavy | |
| (myViewController.m:151) SFProText-Bold | |
| (myViewController.m:151) SFProText-Medium | |
| (myViewController.m:151) SFProText-Light | |
| (myViewController.m:151) SFProText-Regular | |
| source: https://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/ | |
| */ | |
| for (NSString* family in [UIFont familyNames]) | |
| { | |
| NSLog(@"%@", family); | |
| for (NSString* name in [UIFont fontNamesForFamilyName: family]) | |
| { | |
| NSLog(@" %@", name); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Swift: