Custom font importation - ios

I'm having trouble adding a custom front on my IOS project on Xcode 9...
I tried everything proposed on this toppic: Xcode 9 custom fonts not working
but nothing worked out.
On my project, I got my FugazOne-Regular.ttf file, his target membership is set to my app. My Info.plist has Front provided by application and Item 0 is set to FugazOne-Regular.ttf. FugazOne-Regular.ttf is also in Copy bundle resources, in Build phases.
If I try to print every font name with something like this:
for family in UIFont.familyNames.sorted() {
let names = UIFont.fontNames(forFamilyName: family)
print("Family: \(family) Font names: \(names)")
}
I can see all the defaults fonts but no FugazOne-Regular or anything similar,
I tried deleting the font, cleaning the project but nothing changed...
(it is my first time posting here so tell me if I am doing anything wrong)
UPDATE: I thing this might be an Xcode bug, I'm using Xcode 9.4.1 but un macOS Mojave.

Repeat the following steps:
Import the font to the project by dragging it to Xcode and check Copy items if needed and your desired targets
Add into your .plist file (careful with spelling)
Drag the imported font from the project inside Xcode, NOT from Finder into Build Phases > Copy Bundle Resources

Related

Xcode does not detect custom font

I added custom font in xcode, target membership is checked but it does not seen in custom fonts menu.
target membership
location
info.plist
copy bundle resources
You should add your custom font to info.plist too. did you do that ?
you should add a row with Fonts provided by application and enter your font names in that array
Project Name > Build Phases > Copy Bundle Resources.
You should see all font_name.ttf files listed. if you can't see that add your fonts files here. that should solve the problem.
I tried all the suggestions but it didn't work. Hardware reset resolved my issue

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

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.

How to add a localization to a settings.bundle?

My app supports two languages. When I add a settings-bundle, it´s only in english. In Xcode 6.1 I found no way to add a localization to Settings.bundle. Did I miss something?
Nevertheless I found a working solution.
1) open Settings.bundle package
2) create new folder de.lproj (dont´t duplicate en.lproj - Finder don´t likes this)
3) copy Root.strings from en.lproj-folder to de.lproj-folder
4) now you can edit the new language in Xcode
It seems not working in Simulator. I am using Xcode 8.2.1.
OK. I find out the issue. In my Xcode project, the file Root.plist in Settings.bundle, there is one item missing: Strings Filename. I added this entry and set its value to Root, which is for language localization. With this missing item added, my app settings are working as expected in Simulator!
See my blog on this for more information.

Resources