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.
[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!
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.
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.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With