Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom font not showing on device, but does on simulator

I've been playing around with custom fonts in iOS and have got most of it figured out apart from the custom font won't show on any of my devices.

  1. I have added the font to the root of the project file.
  2. Added it to the info.plist file under the array or "Fonts provided by application"
  3. Checked that the case sensitivity of both the original file and what I added to the info.plist file are the same.
  4. Used [playMenuBtn.titleLabel setFont:[UIFont fontWithName:@"fontname" size:40]]; to make the font work.

When I run my app in the Simulator it all appears fine and works. However as soon as I run it on a physical device, it displays the default font with the default size.

If I use:
UIFont *font = [UIFont fontWithName:@"VINCASTENCIL" size:20]; NSLog(@"Font:%@", font);

Then the simulator returns: 2012-04-07 01:10:41.544 AppName[47412:f803] Font:<UICFFont: 0x683e040> font-family: "VINCA STENCIL"; font-weight: normal; font-style: normal; font-size: 20px

Where as the device returns: 2012-04-07 00:42:56.358 AppName[5079:707] Font:(null)

I have tried everything, including trying all the names that FontBook tells me the font could be named. I know it's free and there isn't a licence on it.

Any help would be greatly appreciated as it's driving me nuts and I really don't want to use images for al of these as localisation would then be a pain!

like image 209
Baza207 Avatar asked Apr 07 '12 00:04

Baza207


People also ask

Why are my custom fonts not displaying on iOS devices?

If custom fonts are not displaying on iOS devices for example, please ensure you have uploaded all font variations, including .ttf .svg .woff .woff2 and .eot If any variations are missing, in some cases, a default font will be displayed, however, in other cases, the text will be completely gone and invisible on the website.

Why is my custom font not showing in the browser console?

If your custom font is not showing and you receive a CORS error in your browser’s console, you need to contact your host, as they will need to modify the server’s CORS policy. In order to resolve this, changes must be made to your server.

Why is the default font missing from my website?

If any variations are missing, in some cases, a default font will be displayed, however, in other cases, the text will be completely gone and invisible on the website. This can happen because different browsers render fonts differently, so to prevent any inconsistencies, it is important to add all font variations to maintain full browser support.

How do I add custom fonts to Elementor?

Go to Elementor > Custom Fonts. If the URLs listed do not begin with https, click the DELETE button next to each, and then click UPLOAD buttons to re-upload the files. The URLs should now begin with https and your fonts should appear on the front end.


1 Answers

Right, I've just managed to get this working. Everything I was doing was correct but for some reason it wasn't adding my font file to 'Targets' -> 'Build Phases' -> 'Copy Bundle Resources'. By manually adding it to this list, the font then shows on the device.

This is the second time this project has not added a file here automatically (it's done it previously with a class I added, and it didn't) so I think it's something wrong with my project, or a bug in Xcode.

Thanks to everyone for your suggestions and help. :-D

like image 118
Baza207 Avatar answered Oct 12 '22 12:10

Baza207