iOS Guides | Samples

MonoTouch.UIKit.UIFontDescriptor Class

Describes properties of a font, use to create fonts with certain features. Provides ways of finding fonts matching a description as well.

See Also: UIFontDescriptor

Syntax

[MonoTouch.Foundation.Register("UIFontDescriptor", true)]
[MonoTouch.ObjCRuntime.Introduced(MonoTouch.ObjCRuntime.PlatformName.iOS, 7, 0, MonoTouch.ObjCRuntime.PlatformArchitecture.None, null)]
public class UIFontDescriptor : NSObject, INSCopying, INSSecureCoding, IDisposable

Remarks

Developers create UIFontDescriptors with a set of parameters they are interested in (font faces, font families, font attributes, fallbacks). You can consider these descriptors queries, which you can later use to create a concrete UIFont wit by using the UIFont.FromDescriptor method.

These objects are immutable, once created, they can not be changed. But given a UIFontDescriptor, you can create a more precise font descriptor instance with new information. You can create a new UIFontDescriptor with more detailed font attributes using the UIFontDescriptor.CreateWithAttributes method, extend one by explicitly setting a font face or font family using the UIFontDescriptor.CreateWithFace and UIFontDescriptor.CreateWithFamily methods, specify a desired font size or a transformation matrix with the UIFontDescriptor.CreateWithSize and UIFontDescriptor.CreateWithMatrix methods, or request that certain stylistic traits be present with UIFontDescriptor.CreateWithTraits.

This class exposes various static properties that return the UIFontDescriptor that matches the user's global preferences (font sizes) as well as the system font. These properties are: UIFontDescriptor.PreferredHeadline, UIFontDescriptor.PreferredBody, UIFontDescriptor.PreferredSubheadline, UIFontDescriptor.PreferredFootnote, UIFontDescriptor.PreferredCaption1 and UIFontDescriptor.PreferredCaption2.

You can use the UIFontDescriptor.GetMatchingFontDescriptors method to get a set of UIFontDescriptors that match your font explicitly, or you can use UIFontDescriptor.CreateWithTraits and FromDescriptor methods to match implicitly.

The following example shows how to create two fonts: one with the preferred font for body text, and then a bold version of the same font:

C# Example


// Creates a UIFont for the body text
var bodyDescriptor = UIFontDescriptor.PreferredBody;
UIFont bodyFont = UIFont.FromDescriptor (bodyDescriptor, 0);
	  
// Creates a bold version of it:
var boldDescriptor = bodyDescriptor.CreateWithTraits (UIFontDescriptorSymbolicTraits.Bold);
UIFont boldBodyFont = UIFont.FromDescriptor (boldDescriptor, 0);

The members of this class can be used from a background thread.

Related content

Requirements

Namespace: MonoTouch.UIKit
Assembly: monotouch (in monotouch.dll)
Assembly Versions: 0.0.0.0

The members of MonoTouch.UIKit.UIFontDescriptor are listed below.

See Also: NSObject

Public Constructors

Default constructor, initializes a new instance of this class.
A constructor that initializes the object from the data stored in the unarchiver object.
Creates a UIFontDescriptor using a set of attributes contained in the dictionary.
Constructor to call on derived classes to skip initialization and merely allocate the object.
Creates a font descriptor using the specified font attributes.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
CascadeListUIFontDescriptor[]. Specifies the list of sub descriptors to be used before the system default fallbacks.
[read-only]
CharacterSetNSCharacterSet. Describes the character set supported by the specified font.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
[read-only]
FaceString. The font face.
[read-only]
FamilyString. The font family.
[read-only]
FeatureSettingsUIFontFeature[]. Typographic and layout feature settings.
[read-only]
FixedAdvanceNullable<float>. Override for font's fixed advance for individual glyphs.
[read-only]
FontAttributesUIFontAttributes. The font attributes.
[read-only]
MatrixCGAffineTransform. Transformation matrix for the descriptor.
[read-only]
NameString. Name of the descriptor.
[read-only]
PointSizeSingle. Point size in the descriptor.
[read-only]
PostscriptNameString. The font's PostScript name.
[read-only]
static
PreferredBodyUIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for body text.
[read-only]
static
PreferredCalloutUIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for callouts.
[read-only]
static
PreferredCaption1UIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for captions.
[read-only]
static
PreferredCaption2UIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for 'caption 2'.
[read-only]
static
PreferredFootnoteUIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for footnotes.
[read-only]
static
PreferredHeadlineUIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for headlines.
[read-only]
static
PreferredSubheadlineUIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for subheadings.
[read-only]
static
PreferredTitle1UIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for titles ('Title 1').
[read-only]
static
PreferredTitle2UIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for level 2 titles ('Title 2').
[read-only]
static
PreferredTitle3UIFontDescriptor. Gets the UIFontDescriptor describing the preferred font for level 3 titles ('Title 3').
[read-only]
SizeNullable<float>. Font size (if set).
[read-only]
SymbolicTraitsUIFontDescriptorSymbolicTraits. Font's Symbolic traits
[read-only]
TextStyleNSString. Name of the style to use for text.
[read-only]
TraitsUIFontTraits. Font's traits.
[read-only]
VariationNSDictionary.
[read-only]
VisibleNameString. The visible name for this descriptor.
[read-only]
WeakFeatureSettingsNSDictionary[]. Weakly typed version of the feature settings.
[read-only]
WeakFontAttributesNSDictionary. (Weak) font attributes.

Public Methods

Copy(NSZone) : NSObject
Performs a copy of the underlying Objective-C object.
CreateWithAttributes(NSDictionary) : UIFontDescriptor
Creates a new UIFontDescriptor based on adding the provided attributes to the current descriptor.
CreateWithAttributes(UIFontAttributes) : UIFontDescriptor
Creates a new UIFontDescriptor based on adding the provided attributes to the current descriptor.
CreateWithFace(String) : UIFontDescriptor
Creates a new UIFontDescriptor based on setting a font face to the current descriptor.
CreateWithFamily(String) : UIFontDescriptor
Creates a new UIFontDescriptor based on setting a font family to the current descriptor.
CreateWithMatrix(CGAffineTransform) : UIFontDescriptor
Creates a new UIFontDescriptor based on setting a new transformation matrix to the current descriptor.
CreateWithSize(Single) : UIFontDescriptor
Creates a new UIFontDescriptor based on setting a new font size to the current descriptor.
CreateWithTraits(UIFontDescriptorSymbolicTraits) : UIFontDescriptor
Creates a new UIFontDescriptor based on setting a new symbolic traits to the current descriptor.
static
FromAttributes(NSDictionary) : UIFontDescriptor
(Weak) Creates a UIFontDescriptor using a set of attributes contained in the dictionary.
static
FromAttributes(UIFontAttributes) : UIFontDescriptor
Creates a UIFontDescriptor using a set of attributes contained in the dictionary.
static
FromName(String, CGAffineTransform) : UIFontDescriptor
Creates a UIFontDescriptor using the specified name and transformation matrix.
static
FromName(String, Single) : UIFontDescriptor
Creates a UIFontDescriptor using the specified name and font size.
GetMatchingFontDescriptors(NSSet) : UIFontDescriptor[]
Retrieve a UIFontDescriptor with an explicit set of features.
GetMatchingFontDescriptors(params UIFontDescriptorAttribute[]) : UIFontDescriptor[]
Retrieve a UIFontDescriptor with an explicit set of features.
GetObject(NSString) : NSObject
Low-level/weak API to retrieve properties from the UIFontDescriptor.
static
GetPreferredDescriptorForTextStyle(NSString) : UIFontDescriptor
Weakly-typed version of an API used to retrieve the user's desired font size.
static
GetPreferredDescriptorForTextStyle(NSString, UITraitCollection) : UIFontDescriptor