Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIFont fontWithName font name

Tags:

ios5

uifont

Say you want a specific font for UIFont. How do you know what it's called?

E.g. if you wanted to use this code:

[someUILabelObject setFont:[UIFont fontWithName:@"American Typewriter" size:18]]; 

From where do you copy the exact phrase "American Typewriter". Is there a header file in Xcode?

UPDATE

Also found this handy.

like image 330
Snowcrash Avatar asked Jun 18 '12 13:06

Snowcrash


People also ask

What is a Ui font?

Overview. Use UIFont to access your font's characteristics within your app. It also provides the system with access to the glyph information, used during layout. Font objects are immutable, so it's safe to use them from multiple threads in your app.

How do I add fonts to Xcode?

Add the Font File to Your Xcode Project To add a font file to your Xcode project, select File > Add Files to “Your Project Name” from the menu bar, or drag the file from Finder and drop it into your Xcode project. You can add True Type Font (. ttf) and Open Type Font (. otf) files.


1 Answers

Might be interesting for you as Quick Win within the Debugger:

(lldb) po [UIFont fontNamesForFamilyName:@"Helvetica Neue"]  (id) $1 = 0x079d8670 <__NSCFArray 0x79d8670>( HelveticaNeue-Bold, HelveticaNeue-CondensedBlack, HelveticaNeue-Medium, HelveticaNeue, HelveticaNeue-Light, HelveticaNeue-CondensedBold, HelveticaNeue-LightItalic, HelveticaNeue-UltraLightItalic, HelveticaNeue-UltraLight, HelveticaNeue-BoldItalic, HelveticaNeue-Italic ) 

November 2018 - Update A new swift-y reference for "Custom Fonts with Xcode" - by Chris Ching. I had to update, as this is a great value posting for the new way combined with all missing parts to use custom fonts in a project.

like image 174
andreas-supersmart Avatar answered Oct 13 '22 11:10

andreas-supersmart