Hi. I found a font that I am using in some of my graphics on an iOS app and wanted the labels to match this. I installed it on my machine, and this is now available when I use other apps, like Word, etc. Is there a way to make this available as a font in iOS apps? Just as a test, I created a new desktop app, and the font is available there for use. But can this be done for an iOS app?
You need to include the font in the App bundle by using a Copy Files Build Step to put it into the Resources folder and then add an info.plist file to the project navigator which looks like this:
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
Thank you Art. I’ve only had to make an info.plist for one other app some time ago, and I forget the steps. I know you can make it in TextEdit. Here are the steps I am performing
- Add the data you have above
- Save the text file as info in RTF
- Open the file
- Change to plain text under Format > Make Plain Text
- Save and close
- In Finder, change the name to info.plist
- Drag it to the Contents panel in Xojo
When I run the app, I get an error message about the info.plist file. I also compare the look of the icons in this new app and the older one I made with the info.plist, and the little icons next to each in the Contents look different. The one in the old app (works) looks like a little page with a pencil and maybe says “plist”. The one in the new app (throws error) looks like a little page with zeros and ones. This gets me thinking that I missed a step in the creation of the plist
Don’t know exactly why that doesn’t work. I probably made my plist originally in TextWrangler (now BBEdit).
You can also create a plist file in Xcode. When I double click on my plist file it opens in Xcode and shows something like this:
Exporting it in XML format works.
Ok, got it! I was also having Xcode open when I double-clicked the file. I just exported in XML in Xcode, and it saved it the correct way (now looks like the little page with pencil and “plist” in Xojo and no errors with the plist)
However, now how do I call it to change the font? In a canvas, I want to use this new font for the text and am using this:
g.TextFont = New iOSFont("Adumu", 12)
I don’t add the .tff after the font name, right? What is missing? Getting an InvalidArgumentException on the line above saying “invalid font name”
In my case the font is Bilanidin but the filename is Binanidi.ttf. Make sure you’re using the actual name of the font. I haven’t used it in a canvas.
Dim helptextfont As New iOSFont("Bilanidin", 12)
HelpTextArea.TextFont = helptextfont
Art, you’re wonderful! Thank you! Dummy me, I added the CopyFiles step, but never dragged the .tff file into it!
Thanks also for the help with creating the plist file. This time I made myself a little tutorial note. I appreciate the help!