iOS 5 Custom Fonts - ios

I have added custom fonts to my resources and bundle resources and also to my plist. Everything works fine in iOS5 but when I try the iOS 4.3 simulator, none of the custom fonts work.
Any idea why?
Here is a sample of how I am accessing the fonts:
lblWait.font = [UIFont fontWithName:#"AvenirNextLTPro-Medium" size:22];

The names in that NSString in the first parameter have to be spot on and what's weird is that it's not consistent. It depends on if it's a .otf file or a .ttf file. I've found that a .otf file uses the postscript name and .ttf uses the full name. A good way to find these is to open the font file in Font Book and find it's information (cmd-I). I would try either to see what sticks.
Edit:
It's not always that the TTF uses the FULLNAME and the OTF uses the POSTSCRIPT name, you should try both.

Many times the source of this problem is that the font file is added to the project but not to the target.
Click on the font and make sure it's ticked in "Target Membership", in the right hand column.

Related

Font (Marion font) not displaying inside Font Family in XCode

I included Marion.otf format in XCode.
Its copied and included to target also as showing in this image:
Rest other fonts otf format is properly visible & all fonts are included in Build Phases, info.plist too. I also tried to add ttf formats but those are too not visible.
Image Depicting Fonts are installed on machine :
Btw, While trying to print the font family in debugger, I am unable to saw these included fonts there. Used this code to print fonts:
for family: String in UIFont.familyNames
{
print("\(family)")
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
Also whenever i tried to open Size Inspector Marion Font is not displayed there. What could be the possible reasons?
Add your newly added font in your project .plist also like following key:
Fonts provided by application
Install fonts on your machine.
Add the fonts in Info.plist file.
Make sure that they’re included in the target
Double check that your fonts are included as Resources in your bundle
The font will be available in File Inspector.
If you are still facing an issue then close xcode and delete derived data and restart xcode again. This trick worked for me.
Marion font is not supported properly by MacOS High Sierra. As Indicated in this doc

Custom font seen in Interface builder but not in code in iOS project

I added a custom font called "Quicksand_Dash.otf", "Quicksand-Bold.otf" to an iOS project. I can see it in Interface builder but can't see when I list fonts in code.
"Fonts provided by application" and relevant name added to plist file.
I checked If font file is in copy bundle resources.
How I list the font;
for family in UIFont.familyNames {
let sName: String = family as String
print("family: \(sName)")
for name in UIFont.fontNames(forFamilyName: sName) {
print("name: \(name as String)")
}
}
I checked probably every answer in stack overflow but I think I have a different problem.
How To Use Custom Fonts in iPhone SDK
Custom Fonts Not Working
EDIT: If I add a label in storyboard and make its font Quicksand. Font is also listed in code. However, I don't wanna user storyboard. I'm creating controllers in code.
EDIT2: If I delete label in storyboard. It started to not seen again.
This is the same problem I'm facing but I applied the solutions in that post already;
Custom Font only available in Interface Builder
You're going to kick yourself...
In your plist info file, you have:
`Quicksand-Dash.otf`
but the file you added is named:
`Quicksand_Dash.otf`
underscore not hyphen
Either rename your file, or edit the plist entry, and you'll see your font.
Debug console output:
family: Quicksand
name: Quicksand-BoldItalic
name: QuicksandDash-Regular
name: Quicksand-Bold
Here is a plain single-view project that works fine for me - on both Simulator and Device. (I have not added the fonts to OS X, only to my project):
https://github.com/DonMag/Quicksand
Just for setup reference:
I also stuck to this issue and given solutions don't work for me. In my case ttf file's "Target Membership" block is uncheck. So when I click on it, the respected ttf font listed in font family list.
Happy Coding!!
From reference of #Donmag answer. I download his example project from GitHub and copy fonts from his project to my project then copy "Fonts provided by application" area from plist to my plist. Interestingly, It copied as "UIAppFonts". However, It started to work now.
To use custom fonts in application
Add fonts to your project folder
add it in plist file
check if its added in copy bundle resource
add font to your font book
Check the below link for more reference.
https://stackoverflow.com/a/28843547/9332509

Vector Font on iOS

I want to include a vector font file instead of a .ttf file to my application (not Bitmap based).
Unfortunately, I do only see hints regarding an import of .ttf files. The common approach does not work for .svg.
Add Font file to build target
Add Key to Info.plist file: Fonts provided by application
Add each Font file to the array
Has anyone made experience with embedding a such in an iOS application or is aware, whether this feature even exists / is being about to be implemented?

Can't add custom font to Xcode

I'm trying to add a downloaded font to Xcode and I've folowed every single step based on this link: http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
I added the font to my Xcode Project,
included it in Copy Bundle Resources (Build Phases),
and typed it in Fonts Provided by Application (in Info.plist).
Then I typed this in GameScene.swift inside didMoveToView
It has worked with other fonts but not with this one. This is really frustrating me and I've got no idea what the problem is, thanks.
The name of the font is not always the name of the file. Try looking for the file and then opening in. It should automatically pull it up in font book, and the name of the font is located on the top bar. Simply enter that instead of the file name and it should work.

Cannot include custom font into xcode project

i am trying to include a custom font into my project but i just cannot appear to do that. I was able to do it in my pervious projects without a problem.
First of all, when i include a font in to xCode project it appears like this:
I have tried alots of things, and I know the guidelines when adding a new font,I have read a lot of articles like this (Common Mistakes With Adding Custom Fonts to Your iOS App) and done that several times with success, but now it just wont work.
Fonts are included in the project, they are in copy bundle resources and in the .plist file.
Also I have tried cleaning the project, deleting derivated data, I actually created the whole project from scratch, with no success...
xCode version is 6.4
Font in question is Roboto but i couldn't include any other.
Font type is .ttf but i have tried with .otf also.
Any help here?
Does your project name have any special characters in the name? That can cause problems. E.g. question marks...

Resources