I have a UILabel that I've placed in IB. In the inspector I have changed the font to "Papyrus". When I launch the app in the simulator, the font is not Papyrus. How can I change the font?
You can add custom fonts but you need to add them into your .plist file under the key "Fonts provided by application" to a new row.
Fonts must be added to the Resources of the project and TTF and OpenType fonts are supported.
I believe this is only available in iOS 3.2 or later.
Thanks
Not all fonts listed in IB are available on the iPhone as standard. Papyrus is one of those not available on the iPhone.
More here:
http://ajnaware.wordpress.com/2008/10/24/list-of-fonts-available-on-the-iphone/
You can add custom fonts to the iPhone, but I'd think hard before doing that -- if you're putting a weird looking font onto normal UI items, ask yourself if it actually looks any good! I've seen some real eyesore apps where someone thought it would be cute to put some crime against typography on all the UI controls.
Related
I have my custom fonts working fine when they are running on the simulator, but is there any way to view custom fonts in the storyboard itself while I'm working? My text doesn't match the size of the default font so I have to keep compiling and running the code and eyeing the correct size by trial and error over and over.
I've seen a few questions hit on this, but it's just bringing up how to upload custom fonts.
You can't do it in Xcode 4, as it limits you to the preloaded fonts. Xcode 3 had the opposite problem (with .xib files anyway) of allowing you to use any font on your Mac, even if it would not be available to your app at runtime.
Hopefully a future version of Xcode will hit the useful middle ground of giving you exactly what it can determine will be available at runtime. This is actually difficult for Apple to do because the storyboards/nibs live in a project (which may have multiple targets) and the fonts exist in the targets. IMO they should let you use any font and add a build-time warning if a storyboard/nib is built into a target that does not have all the required fonts in it.
What may work is to edit the storyboard as text (available by right-clicking) and rewrite the font names in there to your custom font names. If it follows the pattern of other Apple products you will then see the custom fonts but it will "correct" them back to "legal" fonts if you access that element in the inspector. I haven't tried this.
My pragmatic technique is to find a system font which has roughly the same characteristics in terms of character dimensions and leading, and use that in the storyboard for layout purposes.
I used Mac OS Font Book to export fonts from it. I got 2 fonts files: Font Suitcase and PostScriptType.
Then I want to use these fonts in my iOS application, but to do that I need to convert them to, for example, ttf. But how?
May be someone faced this problem?
Important:
I don't need advices how to use custom fonts (such as ttf), I need advice how to use Font Suitcase and PostScriptType of fonts (may be how to convert it to ttf)
This solution doesn't require Fondu or Rosetta, but it does involve a little cut-and-paste into macOS's Terminal app.
Pretty simple, and free. And it works on macOS Mojave.
https://sittingduck.co.nz/2013/11/unpacking-the-suitcase/
Try to use these steps.
1) Add your custom font files into your project using Xcode as a resource
2) Add a key to your Info.plist file called "Fonts provided by application".
3) Make this key an array
4) For each font you have, enter the full name of your font file (including the extension) as items to the UIAppFonts array
5) Save Info.plist
6) Now in your application you can simply call [UIFont fontWithName:#"CustomFontName" size:12] to get the custom font to use with your UILabels etc…
Also: Make sure the fonts are in your Copy Bundle Resources.
I'm trying to use a custom font (Sassoon Infant) in Xcode. Despite looking at the numerous posts here on this issue, i haven't been able to resolve the problem.
These are the steps i have taken so far.
Added font to resources
Added font to Font Book
Added SassoonInfantCom-Regular.ttf to Fonts Provided by Application
Tried using fontWithName:#"Sassoon Infant Com", the name in Font Book
Also tried just #"Sassoon"
The font name is not showing up in IB either under the dropdown font menu. The above seems to work for most people but i can't get it working. Anyone have any ideas?
Remove the extension .otf / .ttf from the file and the plist.
Also make sure you are editing the correct plist file for the "Fonts provided by application property"! I spent two days trying everything to make some custom fonts work. Then I realised I was editing the APPTest-info.plist (which is in the resources folder of the Tests folder in XCODE) instead of editing the APP-info.plist file!
In my defence, both files are really close to each other in the files navigator in Xcode... ;-)
I just added it into the bundle and did this
myLabel.font = [UIFont fontWithName:#"MyCustomFont" size:19];
MyCustomFont being a .ttf file.
Hope this helps.
Make sure that the font is added to your target. Select the font and check the target membership in the left Xcode sidebar.
Make sure that you got the correct font name. Open the font in "Font Book" and see its name.
I've added a custom TTF font to my iOS universal app (put .ttf file into resources, add the font file name to the info.plist as indicated on other threads here and the Apple dev forum).
I see the font applied to the UILabel's where I set it to, but there's a spacing problem: it appears as if there is a space character typed in between each glyph. When I install the same .ttf file on my mac and use it in an app like TextEdit, there is no such spacing issue.
Any ideas? Could this be a .ttf problem? What parameter would I adjust? Can anyone recommend a TTF editor for the mac?
Or is this a iOS TTF issue perhaps? I really hope I don't have to delve into CoreText and subclass UILabel in order to get this to work (but if I do, any code samples would be appreciated).
thanks for any help!
Looks like it was just a widely-spaced font.
Is it possible to use UIButtons with my own true type font? I found the FontLabel open source that can use ttf with UILabels, but unfortunately I can't set my UIButton's titleLabel to a created FontLabel. Can someone offer a simple solution to this? Or should I just not be using UIButtons altogether and instead use something else? I feel like I'm missing something obvious because I can't imagine there wouldn't be some truetype functionality in some default button offering.
As of the 3.2 SDK, you can include your own ttf fonts in your app. Just include the font file in your bundle and add the UIAppFonts key to your info.plist. (http://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/iPhoneOSKeys.html#//apple_ref/doc/uid/TP40009252-SW18)
You should then be able to create the font as you would any built-in font and use it as the font for your button's label.
For those of you having this problem and looking for a workaround, this worked for me (link to a question I posed and later answered):
Advice on Debugging a UIAppFonts Issue on iPad