Custom Font in ios not working
Not only does the file needs to be added to the project, but it needs to be added to the target as well.
Sometimes (as in my case), when drag and dropping the ".ttf" file in Xcode, the "add to target" is not checked. This means the file is actually visible in your project, but it is not embedded in the app.
To make sure it is:
- Click on the project's name (left pane)
- Then on the target (middle pane)
- Then "Build Phases" (third tab on the right pane)
- Then "Copy Bundle Resources"
You should see the font file in that list.
XCode: custom font is not applied
In the case that the problem is only for LaunchScreen
, you can't use custom fonts on the LaunchScreen
. System will automatically replace your custom font to system font during runtime.
A quick workaround is to use an UIImageView
and have your text as UIImage
on it, literally a picture of your text as .png
/ .jpeg
or similar.
Note: It may take some time before you can see the image, sometimes you had to clean the Build Folder and reinstall the app a couple of times in order to see the image.
Custom Fonts not showing on Xcode 11 (macOS Catalina)
Unfortunately, the only solution for me was a fresh install of mac os catalina. Now everything works correctly in xCode interface builder.
Custom font not working on iOS even when using all formats possible
iOS and macOS both include Gill Sans as a system font, so you are probably getting the default Regular weight of that, rather than your hosted version.
One option would be to intentionally use the system version on platforms that have a font called Gill Sans installed:
@font-face {
font-family: 'Gill Sans';
src: local('GillSans-Light'),
url('../fonts/GillSans-Light.woff2') format('woff2'),
url('../fonts/GillSans-Light.woff') format('woff');
font-weight: 300;
font-style: normal;
}
A more predictable option, especially for a typeface like this where there are many different “cuts” or digital versions, is to change the font-family
name to something less likely to conflict with a system font. For example:
@font-face {
font-family: 'Example family name';
src: url('../fonts/GillSans-Light.woff2') format('woff2'),
url('../fonts/GillSans-Light.woff') format('woff');
font-weight: 300;
font-style: normal;
}
h1 {
font-family: 'Example family name', GillSans-Light, sans-serif;
font-weight: 300;
font-style: normal;
}
Obligatory further reading: https://en.wikipedia.org/wiki/Eric_Gill
Xcode custom font not showing in app
Check That fonts inside the proyect are part of the target.
Select fonts, verify the property Target Membership for your app is checked at the right in File Inspector.
That solved the problem for me:
Related Topics
How to Change Height of Grouped Uitableview Header
Differencebetween the App Id and the Bundle Id? Where Is the App Id in the Xcode Project
Swift Array Append Overwriting Other Array Values
Alamofire: Sending JSON as Request Parameter
Pod Install Displaying Error in Cocoapods Version 1.0.0.Beta.1
How to Dismiss Keyboard When Touching Anywhere Outside Uitextfield (In Swift)
How to Animate Add Uisearchbar on Top of Uinavigationbar
Opening a PDF Document When Clicking a Button
Waiting for Asynchronous Function Call to Complete
Swift:Non-Nil Optional Value Raising a Nil Exception
How to Manage Sessions with Afnetworking
Cocoapods Setup Stuck on Pod Setup Command on Terminal
How to Draw a Smooth Circle with Cashapelayer and Uibezierpath
Over the Air (Ota) iOS IPA File Distribution for Public
(Null) Libc++Abi.Dylib: Terminate Called Throwing an Exception