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
Related
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
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
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.
I am attempting to make a TTF font file available to my main application and also in my photo editing extension. But the font isn't found when I attempt to access it by name in the extension, although it works in the main app.
I've selected the TTF file and in the File inspector I've checked AppName and AppNameExtension to add them both targets. I ensured the font shows up in Extension > Build Phase > Copy Bundle Resources. The font name and extension exists as the first index of an array for the “Fonts provided by application” in the extension's Info.plist. And I am calling it in code by its proper name. Again, it is working in the main app but not the extension.
Did I do something wrong in order for that resource to be available in the extension, is this not possible in the extension, or is this a bug I should report?
It seems you have everything correct and it is possible I had some issues trying to get it to work as well but it turned out I had thoughtlessly selected the font I wanted to use in Interface Builder before I created the "new" font for the extension and it seemed to be trying to reference the font in the container app, I removed that reference and set it programmatically.
You have to be a little more careful debugging with iOS extensions as Xcode doesn't seem to be as "helpful" as it is in the container app in regards to debugging messages, at least in my opinion currently.
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.