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 Members

Syntax

[MonoTouch.Foundation.Register("UIFontDescriptor", true)]
[MonoTouch.ObjCRuntime.Availability(Introduced=MonoTouch.ObjCRuntime.Platform.iOS_7_0)]
public class UIFontDescriptor : NSObject, INSCoding, INSCopying, 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: Inherited members from MonoTouch.Foundation.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]
PointSizefloat. Point size in the descriptor.
[read-only]
PostscriptNamestring. The font's PostScript name.
[read-only]
static
PreferredBodyUIFontDescriptor. The preferred UIFontDescriptor for the Body dynamic type.
[read-only]
static
PreferredCaption1UIFontDescriptor. The preferred UIFontDescriptor for the Caption1 dynamic type.
[read-only]
static
PreferredCaption2UIFontDescriptor. The preferred UIFontDescriptor for the Caption2 dynamic type.
[read-only]
static
PreferredFootnoteUIFontDescriptor. The preferred UIFontDescriptor for the Footnote dynamic type.
[read-only]
static
PreferredHeadlineUIFontDescriptor. The preferred UIFontDescriptor for the Headline dynamic type.
[read-only]
static
PreferredSubheadlineUIFontDescriptor. The preferred UIFontDescriptor for the Subheadline dynamic type.
[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(float) : 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, float) : 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.

Protected Methods

override
Dispose(bool)
Releases the resources used by the UIFontDescriptor object.