Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add custom fonts with folder reference

Is it possible to add a custom font from a referenced folder (blue one)? My project structure Reference in my Info.plist PCH file
By doing this, my fonts are not recognized in the application. Did I miss something...? Thanks a lot!

EDIT: @Simon Degn: It doesn't work this way either.

I removed the path from Info.plist: My Info.plist without path reference

And from my PCH: PCH File

I have 6 exceptions rising without message when I launch my app: Exception

For your information I was previously with unreferenced folder (yellow one) and it was working nicely. I'd just like to switch to the referenced folder mode from now on. If that is possible.

like image 873
Tulleb Avatar asked Oct 31 '22 20:10

Tulleb


1 Answers

Not sure if it's too late to responsed but you're nearly there.

When specifying the font in the info.plist, you're correct in specifying it as the following (where Assets/Font/Averia_Sans_Libre is the folder reference prefix)

Assets/Font/Averia_Sans_Libre/*.ttf

When you load the app, if you run the following you can see if the font has been loaded:

NSLog(@"All fonts: %@", [UIFont familyNames].description);

Then to use the font, use the following with the FONT NAME, not the FONT FILE NAME (which is what you've done in your example above).

[UIFont fontWithName:@"Averia Sans Libre" size:@"15"];

You can find the name of the font using the example provided by Simon Degn (below)

like image 108
jklp Avatar answered Nov 11 '22 07:11

jklp