Languages: English • français
UIFont is a class representing a font face and the font size. This class is built on top of GSFont.
Default font families
Family | Normal | Bold | Italic | Bold-Italic | Example |
---|---|---|---|---|---|
AppleGothic | AppleGothic | Korean-한국어-韓國語 | |||
Hiragino Kaku Gothic ProN | HiraKakuProN-W3 | HiraKakuProN-W6 | Japanese-にほんご-ニヒンゴ-日本語 | ||
Arial Unicode MS | ArialUnicodeMS | Unicode-AMZamz157½ßĽΔΩθφДЫжю | |||
Heiti K | STHeitiK-Light | STHeitiK-Medium | Korean-한국어-韓國語 | ||
DB LCD Temp | DBLCDTempBlack | 0123456789abcdef | |||
Helvetica | Helvetica | Helvetica-Bold | Helvetica-Oblique | Helvetica-BoldOblique | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Marker Felt | MarkerFelt-Thin | Latin-AMZamz157½ßĽΔΩθφДЫжю | |||
Times New Roman | TimesNewRomanPSMT | TimesNewRomanPS-BoldMT | TimesNewRomanPS-ItalicMT | TimesNewRomanPS-BoldItalicMT | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Verdana | Verdana | Verdana-Bold | Verdana-Italic | Verdana-BoldItalic | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Georgia | Georgia | Georgia-Bold | Georgia-Italic | Georgia-BoldItalic | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Arial Rounded MT Bold | ArialRoundedMTBold | Latin-AMZamz157½ßĽΔΩθφДЫжю | |||
Trebuchet MS | TrebuchetMS | TrebuchetMS-Bold | TrebuchetMS-Italic | Trebuchet-BoldItalic | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Heiti TC | STHeitiTC-Light | STHeitiTC-Medium | Traditional Chinese-繁體中文 | ||
Geeza Pro | GeezaPro | GeezaPro-Bold | Arabic-العربية/Farsi-فارسی | ||
Courier | Courier | Courier-Bold | Courier-Oblique | Courier-BoldOblique | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Arial | ArialMT | Arial-BoldMT | Arial-ItalicMT | Arial-BoldItalicMT | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Heiti J | STHeitiJ-Light | STHeitiJ-Medium | Japanese-にほんご-ニヒンゴ-日本語 | ||
Arial Hebrew | ArialHebrew | ArialHebrew-Bold | Hebrew-עִבְרִית | ||
Courier New | CourierNewPSMT | CourierNewPS-BoldMT | CourierNewPS-ItalicMT | CourierNewPS-BoldItalicMT | Latin-AMZamz157½ßĽΔΩθφДЫжю |
Zapfino | Zapfino | Latin-AMZamz157½ßĽΔΩθφДЫжю | |||
American Typewriter | AmericanTypewriter | AmericanTypewriter-Bold | Latin-AMZamz157½ßĽΔΩθφДЫжю | ||
Heiti SC | STHeitiSC-Light | STHeitiSC-Medium | Simplified Chinese-简体中文 | ||
Helvetica Neue | HelveticaNeue | HelveticaNeue-Bold | Latin-AMZamz157½ßĽΔΩθφДЫжю | ||
Thonburi | Thonburi | Thonburi-Bold | Thai-ภาษาไทย |
Default font sizes
There are 4 font sizes that can be obtained using +[UIFont someSize]. The last 2 are conventional values.
Name | Value |
---|---|
smallSystemFontSize | 12 |
systemFontSize | 14 |
labelFontSize | 17 |
buttonFontSize | 18 |
Default font size of UIButton | 15 |
Default font size of UITextField | 12 |
Undocumented methods
+fontWithFamilyName:traits:size:
Signature | +(UIFont*)fontWithFamilyName:(NSString*)familyName traits:(GSFontTraitMask)traits size:(CGFloat)fontSize;
|
---|---|
Available in | 2.0 – |
Returns a font with specific family name, traits (bold/italic) and font size. For example:
// Equivalent to [UIFont fontWithName:@"Arial-BoldMT" size:24]
UIFont* font = [UIFont fontWithFamilyName:@"Arial" traits:GSBoldFontMask size:24];
+fontWithMarkupDescription:
Signature | +(UIFont*)fontWithMarkupDescription:(NSString*)markupDescription;
|
---|---|
Available in | 2.0 — |
Create a font using a CSS font description, e.g.
// Equivalent to [UIFont fontWithName:@"Arial-BoldMT" size:24]
UIFont* font = [UIFont fontWithMarkupDescription:@"font-family: Arial; font-size: 24px; font-weight: bold;"];
Unlike real CSS rules there are heavy restrictions on the "markup description":
- The font-family rule must be exact. A list of fonts like Arial, Helvetica, sans-serif will not be supported by UIKit, and will always return nil regardless whether any font in the list is available.
- The unit of font-size will always be interpreted as px. Names such as font-size: large will be considered as 0px.
- font-weight can only be bold or not.
- font-style can only be italic or not. In particular, oblique is not recognized and treated as normal.
-traits
Signature | -(GSFontTraitMask)traits;
|
---|---|
Available in | 2.0 – |
Returns the traits (bold/italic) of the font.
-isFixedPitch
Signature | -(BOOL)isFixedPitch;
|
---|---|
Available in | 2.0 – |
Returns whether the font is monospaced or not.
-markupDescription
Signature | -(NSString*)markupDescription;
|
---|---|
Available in | 2.0 – |
Returns the CSS rules that can reproduce this font.
References
- Official documentation: http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIFont_Class/Reference/Reference.html
- Extra header: http://github.com/kennytm/iphone-private-frameworks/blob/master/UIKit/UIFont2.h
- Font samples: http://blog.backpackholic.tv/attach/1/1169354710.png[permanent dead link]