SF UI Text-Light(New san francisco) font doesn't work
Solution 1
That's happens because you use the wrong System name for the font. Try to use
labelname.font = [UIFont fontWithName:@"SFUIText-Light" size:12];
How to find System font names see here Adding custom fonts to iOS app finding their real names
Solution 2
I try to log the system font and find the font name is ".SFUIText-Light" ,so
labelname.font = [UIFont fontWithName:@".SFUIText-Light" size:12];
this is work.
Solution 3
Adding an update: you should be using the system font APIs in UIFont. For example:
UIFont.systemFont(ofSize: 12, weight: .light)
Apple specifically tells developers to no longer rely on a font name or file system representation for the system font.
As an aside, I made up a library for using many of the special features of the SF font in your app. Feel free to check it out: https://github.com/djfitz/SFFontFeatures
Solution 4
IMPORTANT, really.
Use this code, it is very, very useful. With it you can know the real name of the font.
let fontFamilyNames = UIFont.familyNames
for familyName in fontFamilyNames {
print("------------------------------")
print("Font Family Name = [\(familyName)]")
let names = UIFont.fontNames(forFamilyName: familyName)
print("Font Names = [\(names)]")
}
I show you an example.
The Font file (you must add it into your project, as any other file):
The Font file name in "Info.plist" (exactly the same name with the file extension):
Finally, the output in the log Debug (created by the code)
So, you can write this font name:
headerLabel.font = UIFont(name:"SFProDisplay-Heavy", size:30)
Use this code. It has saved me time. It is very useful (I think)!
Mathi Arasan
Updated on July 09, 2022Comments
-
Mathi Arasan almost 2 years
I am try to change font for a label but it's doesn't work font name:new New san francisco.
Import that font into project and add in info.plist and this is my code
labelname.font = [UIFont fontWithName:@"SF UI Text-Light" size:12];
If I use that's work fine
labelname.font = [UIFont fontWithName:@"HelveticaNeue" size:12];
But New san francisco font doesn't work. I don't know what I miss :(