Cant find custom font - iOS
Look at all the available fonts
Objective-C:
for(NSString* family in [UIFont familyNames]) {
NSLog(@"%@", family);
for(NSString* name in [UIFont fontNamesForFamilyName: family]) {
NSLog(@" %@", name);
}
}
Swift:
for family: String in UIFont.familyNames() {
print("%@", family)
for name: String in UIFont.fontNamesForFamilyName(family) {
print(" %@", name)
}
}
..if it's not there, install again
Copy the
.ttf
file into your project (i.e. drag it to the resource folder in the Project navigator).In your
Info.plist
add an entry with the keyFonts provided by application
with an Array type. As Item 0, add a String value corresponding to the font file name (e.g.OpenSans-ExtraBoldItalic.ttf
).Make sure the font file is included in the
copy bundle resources
list under the project settings.
Xcode does not detect custom font
I tried all the suggestions but it didn't work. Hardware reset resolved my issue
can't find the name of custom font added to xcode 7
Did you try something like:
[yourlabel setFont:[UIFont fontWithName:@"PT Sans" size:20]];
Xcode 8 custom font doesn't show up in interface builder
Try Below Steps: Code tested in Swift 3
.
Step 1: Add Your custom font into your project( Make sure Add to Target
ticked).I am using "PermanentMarker.ttf","Pecita.otf" and "AROLY.ttf" font as a test font.
Note: Supporting font Type ttf and otf (Both font types should work)
Step 2: Modify the application-info.plist file.
Add the key "Fonts provided by application" in a new row and add "PermanentMarker.ttf" as new item in the Array "Fonts provided by application".
Your plist should looks like this
Now the font will be available in Interface Builder. To use the custom font in code we need to refer to it by name, but the name often isn’t the same as the font’s filename
Now, You can access the Custom Font from your viewController. I am testing the font by placing a UIlabel to the Storyboard like below.
Update 2: Working Solution
After, imported your custom font and updated your plist
.selectlabel
from your storyBoard
,goto Attributes Inspector
under Label
>Text type
> select to Attributed
and choose your custom font
from the list.
Output:
Update 1
If your custom font still not listed in Xcode font list
.check the related link to your issue
http://codewithchris.com/common-mistakes-with-adding-custom-fonts-to-your-ios-app/
custom font not displaying on some simulator
Note: Still,You can assign BebasNeue
or custom font
programatically to your label or button etc. even its not showing in your interface Builder
.If you having trouble setting font to your object programatically.try below method.
Assign font to UILabel:
label?.font = UIFont(name: "BebasNeue", size: 35) // Set to any size
Assign font to UIButton:
button.titleLabel?.font = UIFont(name: "BebasNeue", size: 35)
Assign font to UITextField:
textField.font = UIFont(name: "BebasNeue", size: 25)
Assign font to UINavigationBar:
navigationController?.navigationBar.titleTextAttributes = [NSFontAttributeName: UIFont(name: "BebasNeue", size: 25)!, NSForegroundColorAttributeName: UIColor.red]
Assign font to UIToolBar:
UIBarButtonItem.appearance().setTitleTextAttributes([NSFontAttributeName: UIFont(name: "BebasNeue", size: 25.0)!], for: UIControlState.normal)
Output:
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.
Can't add custom font to Xcode
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.
Custom Font in IOS Not Reflected On Device
Thank you @Andrey Chernuka and @jcaron. I solved the problem by setting the target membership to my project and then exiting the project (cleaning did not work for some reason) and reopening the project and everything was set. the font name was appearing when i printed print (UIFont.familyNames())
Related Topics
iOS 8 Nsinternalinconsistencyexception
Importing Swift Framework into a Objective-C Project
How to Migrate an Old Xcode Project to Use Swiftui
Firebase Create User with Email, Password, Display Name and Photo Url
Tab Bar Background Is Missing on iOS 7.1 After Presenting and Dismissing a View Controller
iOS Input Focused Inside Fixed Parent Stops Position Update of Fixed Elements
How to Disable User Interaction on Mkmapview
Google Objective-C API 'Gtl' with Swift
Schedule Number of Local Notifications
Uitableview Invoke Swipe Actions Programmatically
Swift How to Modify Exif Info in Images Taken from Mobile Camera
Endless Scrolling Background in Spritekit
Is There a Practical Way to Compress Nsdata
How to Make Camera Follow Sknode in Sprite Kit
Lock iOS App in Single App Mode Programmatically
How to Use Uiactivityitemprovider to Send an Email with Attachment with Uiactivityviewcontroller
Is the Function 'Dlopen()' Private API
Can Swift Closures Be Set to a Default Value When Used as a Parameter in a Function