OK, so I've done a lot of reading, followed several tutorials, and I still cannot add a custom font to my iOS app.
I've (1) added and copied the fonts to xcode.
I've (2) added them to the correct target.
I've (3) made sure they are included as resources in the bundle.
I've (4) included them in my info.plist.
I've (5) tried to find them in my list of fonts by inserting this code.
Yet the fonts STILL do not appear. I recognize that the font name is not the same as the file name, but I compared the list of font family names and font names from before and after, and they are the exact same, proving no fonts were added. I've followed SO and these tutorials to a T but nothing is working.
You inadvertently added them to the wrong (Test) Info.plist.
Related
I've been working on the launch screen of an app and I ran across a problem. The custom font that I was using (grand hotel) shows up in the storyboard but is replaced by a default font in the simulator. It should be like this, but instead this happens. I've tried everything online: added it to the plist, set the target, put it in Copy Bundle Resources. I've looked everywhere but I can't seem to find a solution that solves my problem. Is there any way for me to fix this issue? Could it be because it is a launch screen?
Follow the below steps.
(1) Remove your custom fonts.
(2) Re-add your font like, Right click on your project --> add files --> select your custom font. (Make sure option copy items if needed is checked).
(3) Clean(⌘+shift+K) + Build(⌘+shift+B) your project.
To check if the custom fonts are availabel on runtime add this code:
print(UIFont.fontNames(forFamilyName: "Your_Custom_font_name")) // if it returns empty array it means fonts are not available on runtime and it is not added correctly.
Please check this... may any step you miss
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
Did you somewhere set the font programmatically by name?
I figured out, that the name of a certain font is not necessarily the name, which is shown in Xcode. You can check out the real font names in Xcode by putting the following somewhere in your code:
for family: String in UIFont.familyNames {
print("\(family)")
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
I added my two fonts to my project folder:
I added them to info.plist:
I can not see them in my custom font list in the storyboard:
What have i done wrong?
I know this is a pretty old question, but I ran into the same issue. And the above tips didn't work for me. Apart from the standard checks (present in bundle, restarting XCode, the thing that fixed my issue was that my label text type was marked as "Plain" and hence some fonts were not showing in the dropdown in the Storyboard. As soon as I changed the text type to "Attributed", all the fonts appeared in the dropdown.
Hope this'll help someone stuck with the same issue.
This drop-down box shows the system-wide installed fonts. So you need to install your custom font on your system first so it's appearing in that drop-down box. You can do that by double-clicking it, the FontBook.app opens and asks you whether you want to install the font.
This was a huge headache for me but I simply fixed it by:
I fixed the issue by restarting my Mac.
Then restarting Xcode.
I Installed the font in the system as per DarkDust solution and i am able to see the font in attributed type.
Then i changed the type to plain and i able to see the Custom font in the font types drop down.
Had the same problem but this SO answer by user Saranjith solved it while the other solutions in this thread didn't: Xcode 8 custom font doesn't show up in interface builder
Basically in Font Book select "Computer Fonts" and then hit the + button and re add the Fonts.
This is happened to me after moving to Xcode 11 in Catalina from Xcode 10 in Mojave.
Well, silly mistake on my part, but I didn't realize my font was named something way different from the file name.
Double-clicking the actual font file opened it in the font book, and that showed the actual font name. It was in the dropdown all along.
I solved my problem when i used font name. Do not use file name. I was used like this [UIFont fontWithName:#"appFont" size:17] but it is wrong.
Upload your font file to https://fontdrop.info/ and use the name
My font file name is appFont.ttf but when i uploaded i saw Roboto Regular.
[UIFont fontWithName:#"Roboto Regular" size:17]
Sometime I go to another file and come back, then my custom fonts are arrived. I think this is an issue of Xcode and will be solved in following version.
In my case I just turn the text from plain to attributed then turn it back again to plain then it showed up., hope this help anyone.
I ran into the same issue and fixed with below steps
Closed storyboard
Cleared derived data
Cleaned the project and open the story board
If this is not working then restart the Xcode.
Thanks
For me it was case sensitive issue with the font file name. Not sure if it's always for this reason...
In my case my fonts were in woff2 formats. Although woff2 is supported in iOS, the fonts don't appear or get rendered in Storyboards.
If Xcode showed your custom font before but stopped to do it at some moment, try to readd font files to your project. It solved the problem for me. Other answers weren't helpful.
I've added a custom font TTF file to an app I'm making.
I've also added the UIAppFonts key to the plist, as required.
Now, when I launch the app, it hits the "app is crashing in AppDelegate" breakpoint we all know so well.
I can't figure out a way to inspect the exception, but what's stranger is that if I play it through, the app continues just fine -- even allows me to debug. On top of that, the font in question is actually loaded, so there doesn't seem to be any issue there either. Not sure where to start looking for this one.
The font file is probably not added to the target.
Please remove the white spaces from the font file name. And change name in info.plist file.
And Use the same font name which in in the .ttf file. For more information you can check NSGOD's Answer here
Do you have a symbolic breakpoint set for "objc_exception_throw"? It will break on all exceptions, including the ones that will be caught by some code's try/catch frame.
Since you are seeing it show the break at UIApplicationMain, it is likely this is the closest source code to the problem. Check the stack frames in the left column to see if there are Apple internal methods being called.
Change the slider at the bottom of the left column in Xcode to show more of the stack frames if some are hidden.
I am trying to install my custom font for my app. I alreayd donde this many of times, but with this font I don't know why it doesn't work
Note: My info.plist its correct with the file Geometry Soft Pro.ttf
Font file:
Geometry Soft Pro.ttf
I already try the code with:
Geometry Soft Pro
GeometrySoftPro
GeometrySoftPro-BoldN
GeometrySoftPro-Bold N
Geometry Soft Pro-Bold N
Geometry Soft Pro Bold N
My code:
[nivel.titleLabel setFont:[UIFont fontWithName:#"Geometry Soft Pro" size:42]];
Font info:
Here is my info.plist
Please remove the white spaces from the font file name. And change name in info.plist file. Thats all. Happy Coding :)
I had the same issue but none of this helped me, i change the Fonts provided by application with UIAppFonts and it works , even if the .ttf file name is different from the font name.
Check if font file is added in "Copy bundle resources" under project settings-> Build phases.
Also install the font in MAC & use the same name (with / without spaces in between) in your iOS code. Let me know if it works for you.
I have a weird issue here... An app uses some custom font (Roboto Condensed for instance).
I added my font to my project. They are associated with the target. They are declared in the info.plist and the typo is right (copy/paste from the original files) and they contain the extension of course. They are in the "Copy ressources" of the build phase, they are part of the Font Family when I log them but enumerating fonts, they work through IB, and they are not set when the app is running... The fonts were download from the latest version on the Google website.
Weirdest thing : I have other custom font, and they are working.
Even weirder : if I set the font programmatically, it works...
It seems that it is related to IB (font name, family?)
I'm running out of options here. Have you encountered this kind of behavior?
Thanks.
I did not find any solution. The only workaround is to have outlets for every font specific view and set it into code :-/