Click or drag to resize
CanvasTextAnalyzerGetFonts Method (CanvasTextFormat)
Gets a font for each span of text contained within this text analyzer.

Namespace:  Microsoft.Graphics.Canvas.Text
Assembly:  Microsoft.Graphics.Canvas (in Microsoft.Graphics.Canvas.dll) Version: 0.0.0.0
Syntax
C#
public IReadOnlyList<KeyValuePair<CanvasCharacterRange, CanvasScaledFont>> GetFonts(
	CanvasTextFormat textFormat
)

Parameters

textFormat
Type: Microsoft.Graphics.Canvas.TextCanvasTextFormat

Return Value

Type: IReadOnlyListKeyValuePairCanvasCharacterRange, CanvasScaledFont
Remarks

This method chooses fonts from the system font set.

While a CanvasTextFormat contains a font family name and some other properties, it's not an explicit reference to a font, nor does it guarantee that a piece of text can be drawn with that exact font family. An application needs to apply font fallbacks to match a piece of text to an actual font that will support it. When drawing a CanvasTextLayout constructed with a particular CanvasTextFormat, for example, Win2D performs that matching automatically. Here, an application can perform the same matching.

If glyphs in the text aren't supported by the text format's font family or aren't compatible with its other properties, this method will try to return another similar font which is compatible.

This method only uses the locale, font family, font weight, stretch, and style from the passed-in text format. It doesn't use its other properties.

It can happen that there are some glyphs that don't match any available font. When that's the case, there won't be a CanvasCharacterRangeFont which spans that character. For glyphs not supported by any font, an app may choose to display nothing, or draw another glyph instead.

See Also