GlyphTypeface Class
Definition
Represents a glyph typeface, providing access to font metrics, glyph mappings, and other font-related properties.
public class GlyphTypeface
Remarks
The Avalonia.Media.GlyphTypeface class is used to encapsulate font data, including metrics, character-to-glyph mappings, and supported OpenType features. It supports platform-specific typefaces and applies optional font simulations such as bold or oblique. This class is typically used in text rendering and shaping scenarios.
Constructors
| Name | Description |
|---|---|
| GlyphTypeface | Initializes a new instance of the Avalonia.Media.GlyphTypeface class with the specified platform typeface and font simulations. |
GlyphTypeface Constructor
Initializes a new instance of the Avalonia.Media.GlyphTypeface class with the specified platform typeface and font simulations.
public GlyphTypeface(Avalonia.Media.IPlatformTypeface typeface, Avalonia.Media.FontSimulations fontSimulations)
Parameters
typeface Avalonia.Media.IPlatformTypeface
The platform-specific typeface to be used for this Avalonia.Media.GlyphTypeface instance. This parameter
cannot be null.
fontSimulations Avalonia.Media.FontSimulations
The font simulations to apply, such as bold or oblique. The default is Avalonia.Media.FontSimulations.None.
Remarks
This constructor initializes the glyph typeface by loading various font tables, including OS/2, CMAP, and metrics tables, to calculate font metrics and other properties. It also determines font characteristics such as weight, style, stretch, and family names based on the provided typeface and font simulations.
Exceptions
Methods
| Name | Description |
|---|---|
| Dispose | No summary available. |
| TryGetGlyphMetrics (2 overloads) | No summary available. |
| TryGetHorizontalGlyphAdvance | No summary available. |
| TryGetHorizontalGlyphAdvances | No summary available. |
Dispose Method
public void Dispose()
TryGetGlyphMetrics overloads
TryGetGlyphMetrics Method
public bool TryGetGlyphMetrics(ReadOnlySpan<ushort> glyphIds, Span<Avalonia.Media.GlyphMetrics> metrics)
Parameters
glyphIds ReadOnlySpan<ushort>
metrics Span<Avalonia.Media.GlyphMetrics>
Returns
bool
TryGetGlyphMetrics Method
public bool TryGetGlyphMetrics(ushort glyph, Avalonia.Media.GlyphMetrics& metrics)
Parameters
glyph ushort
metrics Avalonia.Media.GlyphMetrics&
Returns
bool
TryGetHorizontalGlyphAdvance Method
public bool TryGetHorizontalGlyphAdvance(ushort glyphId, ushort& advance)
Parameters
glyphId ushort
advance ushort&
Returns
bool
TryGetHorizontalGlyphAdvances Method
public bool TryGetHorizontalGlyphAdvances(ReadOnlySpan<ushort> glyphIds, Span<ushort> advances)
Parameters
glyphIds ReadOnlySpan<ushort>
advances Span<ushort>
Returns
bool
Properties
| Name | Description |
|---|---|
| CharacterToGlyphMap | Gets a read-only mapping of Unicode character codes to glyph indices for the font. |
| FaceNames | Gets a read-only mapping of culture-specific face names. |
| FamilyName | Gets the family name of the font. |
| FamilyNames | Gets a read-only mapping of localized culture-specific family names. |
| FontSimulations | Gets the font simulation settings applied to the Avalonia.Media.GlyphTypeface. |
| GlyphCount | Gets the number of glyphs held by this font. |
| Metrics | Gets the font metrics associated with this font. |
| PlatformTypeface | Gets the platform-specific typeface associated with this font. |
| Stretch | Gets the font stretch. |
| Style | Gets the font style. |
| SupportedFeatures | Gets the list of OpenType feature tags supported by the font. |
| TextShaperTypeface | Gets the typeface information used by the text shaper for this font. |
| TypographicFamilyName | Gets the typographic family name of the font. |
| Weight | Gets the font weight. |
CharacterToGlyphMap Property
Gets a read-only mapping of Unicode character codes to glyph indices for the font.
public Avalonia.Media.Fonts.Tables.Cmap.CharacterToGlyphMap CharacterToGlyphMap { get; set; }
Remarks
This dictionary provides the correspondence between Unicode code points and the glyphs defined in the font. The mapping can be used to look up the glyph index for a given character when rendering or processing text. The set of mapped characters depends on the font's supported character set.
FaceNames Property
Gets a read-only mapping of culture-specific face names.
public System.Collections.Generic.IReadOnlyDictionary<System.Globalization.CultureInfo, string> FaceNames { get; set; }
Remarks
Each entry in the dictionary maps a System.Globalization.CultureInfo to the corresponding localized face name. The dictionary is empty if no face names are defined.
FamilyName Property
Gets the family name of the font.
public string FamilyName { get; set; }
FamilyNames Property
Gets a read-only mapping of localized culture-specific family names.
public System.Collections.Generic.IReadOnlyDictionary<System.Globalization.CultureInfo, string> FamilyNames { get; set; }
Remarks
The dictionary contains entries for each supported culture, where the key is a System.Globalization.CultureInfo representing the culture, and the value is the corresponding localized family name. The dictionary may be empty if no family names are available.
FontSimulations Property
Gets the font simulation settings applied to the Avalonia.Media.GlyphTypeface.
public Avalonia.Media.FontSimulations FontSimulations { get; set; }
GlyphCount Property
Gets the number of glyphs held by this font.
public int GlyphCount { get; set; }
Metrics Property
Gets the font metrics associated with this font.
public Avalonia.Media.FontMetrics Metrics { get; set; }
PlatformTypeface Property
Gets the platform-specific typeface associated with this font.
public Avalonia.Media.IPlatformTypeface PlatformTypeface { get; set; }
Stretch Property
Gets the font stretch.
public Avalonia.Media.FontStretch Stretch { get; set; }
Style Property
Gets the font style.
public Avalonia.Media.FontStyle Style { get; set; }
SupportedFeatures Property
Gets the list of OpenType feature tags supported by the font.
public System.Collections.Generic.IReadOnlyList<Avalonia.Media.Fonts.OpenTypeTag> SupportedFeatures { get; set; }
Remarks
The returned list reflects the features available in the underlying font and is read-only. The order of features in the list is not guaranteed. This property does not return null; if the font does not support any features, the list will be empty.
TextShaperTypeface Property
Gets the typeface information used by the text shaper for this font.
public Avalonia.Media.ITextShaperTypeface TextShaperTypeface { get; set; }
Remarks
The returned typeface is created on demand and cached for subsequent accesses. This property is typically used by text rendering components that require low-level font shaping details.
TypographicFamilyName Property
Gets the typographic family name of the font.
public string TypographicFamilyName { get; set; }
Weight Property
Gets the font weight.
public Avalonia.Media.FontWeight Weight { get; set; }