My application has to use some custom font so I start to add the font by copy it to the application folder and create the "Fonts provided by application" in info.plist, everything work fine in my Mac but when I start to debug in my phone the font turn back to the system font, How can I fix this?
问题:
回答1:
This is pretty easy to do, actually. Firstly, you need to make sure that the font file is in your app file hierarchy:
you can see mine here "small_pixel.ttf"
Secondly you need to make sure that the info.plist
file has the EXACT file name as your custom font:
you can see that here.
Thirdly, you need to make sure that the font is included in bundle resources
you can navigate to it by going:
to add it to bundle resources
simply drag and drop the file into the hierarchy.
Finally you can see all of your fonts by doing...
for family: String in UIFont.familyNames()
{
print("\(family)")
for names: String in UIFont.fontNamesForFamilyName(family)
{
print("== \(names)")
}
}
...in some function that gets called when you launch your app. Simply scroll down through the Debug area until you find your font.
(ps. this is from my first really trashy game. If you want to check it out, search "Crappy Duck" on the AppStore)