Modifier

Partager via


CTFontSymbolicTraits Enum

Definition

Describes the style of a font.

This enumeration supports a bitwise combination of its member values.

[System.Flags]
public enum CTFontSymbolicTraits
type CTFontSymbolicTraits = 
Inheritance
CTFontSymbolicTraits
Attributes

Fields

Name Value Description
None 0

Used when no values are set.

Italic 1

This is an italic font. If querying CTFontTraits you can get more information about the slant from the Slant property.

Bold 2

This is a bold font. If querying CTFontTraits you can get more information about the weight from the Weight property.

Expanded 32

This is an expanded font.

Condensed 64

This is a condensed font. If querying CTFontTraits you can get more information about the width from the Width property.

MonoSpace 1024

Use fixed fonts if available.

Vertical 2048

The font has vertical information for rendering.

UIOptimized 4096

The font is optimized for UI rendering.

ColorGlyphs 8192

This font contains glyphs with colors (for example, some Emoji fonts).

Composite 16384

The font is a composite font reference, and a cascade list is expected for the font.

Mask 4026531840

Mask used to extract trait values.

Remarks

You can use this to query trait information about a font.

void ShowInfo (CTFont font)
{
    var traits = font.GetTraits ();
    if (traits.Bold)
	Console.WriteLine ("Bold font, weight={0}", traits.Weight);
    if (traits.Italic)
	Console.WriteLine ("Italic font, slant={0}", traits.Slant);
    if (traits.Condensed || traits.Expanded)
	Console.WriteLine ("Condensed/Expanded font, width={0}", traits.Width);
    if (traits.ColorGlyphs)
	Console.WriteLine ("Font has colored glyphs");
    if (traits.MonoSpace)
	Console.WriteLine ("Font is monospaced");
    if (traits.Vertical)
	Console.WriteLine ("Font contains vertical metrics");
}

Applies to