You can use this to query trait information about a font.
c# Example
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");
}
| Member Name | Description |
|---|---|
| Bold | This is a bold font. If querying MonoMac.CoreText.CTFontTraits you can get more information about the weight from the CTFontTraits.Weight property. |
| ColorGlyphs | This font contains glyphs with colors (for example, some Emoji fonts). |
| Composite | The font is a composite font reference, and a cascade list is expected for the font. |
| Condensed | This is a condensed font. If querying MonoMac.CoreText.CTFontTraits you can get more information about the width from the CTFontTraits.Width property. |
| Expanded | This is an expanded font. |
| Italic | This is an italic font. If querying MonoMac.CoreText.CTFontTraits you can get more information about the slant from the CTFontTraits.Slant property. |
| Mask | Mask used to extract trait values. |
| MonoSpace | Use fixed fonts if available. |
| None | Used when no values are set. |
| UIOptimized | The font is optimized for UI rendering. |
| Vertical | The font has vertical information for rendering. |