Table of Contents

Class SkiaFontManager

Namespace
DrawnUi.Draw
Assembly
DrawnUi.Maui.dll
public class SkiaFontManager
Inheritance
SkiaFontManager
Inherited Members
Extension Methods

Fields

ThrowIfFailedToCreateFont

public static bool ThrowIfFailedToCreateFont

Field Value

bool

Properties

DefaultTypeface

public static SKTypeface DefaultTypeface { get; }

Property Value

SKTypeface

FontRegistrar

public static IFontRegistrar FontRegistrar { get; }

Property Value

IFontRegistrar

Fonts

public Dictionary<string, SKTypeface> Fonts { get; set; }

Property Value

Dictionary<string, SKTypeface>

Initialized

public bool Initialized { get; set; }

Property Value

bool

Instance

public static SkiaFontManager Instance { get; }

Property Value

SkiaFontManager

Manager

public static SKFontManager Manager { get; }

Property Value

SKFontManager

Methods

CanRender(SKTypeface, int)

public bool CanRender(SKTypeface typeface, int character)

Parameters

typeface SKTypeface
character int

Returns

bool

ClearCharacterCache()

Clears the character-to-typeface cache. Call this if fonts are dynamically loaded/unloaded at runtime.

public static void ClearCharacterCache()

DetectUnicodeBlock(int)

Detects the Unicode block category for a given code point. This is cross-platform logic used to optimize font matching.

public static UnicodeBlock DetectUnicodeBlock(int codePoint)

Parameters

codePoint int

Unicode code point

Returns

UnicodeBlock

Unicode block category

FindBestTypefaceForString(string)

public static (SKTypeface, int) FindBestTypefaceForString(string text)

Parameters

text string

Returns

(SKTypeface, int)

GetAlias(string, FontWeight)

public static string GetAlias(string alias, FontWeight weight)

Parameters

alias string
weight FontWeight

Returns

string

GetAlias(string, int)

public static string GetAlias(string alias, int weight)

Parameters

alias string
weight int

Returns

string

GetCharacterCacheSize()

Gets the current size of the character cache for diagnostics.

public static int GetCharacterCacheSize()

Returns

int

GetEmbeddedResourceNames()

Get the list of all emdedded resources in the assembly.

public static string[] GetEmbeddedResourceNames()

Returns

string[]

An array of fully qualified resource names

GetEmbeddedResourceStream(Assembly, string)

public static Stream GetEmbeddedResourceStream(Assembly assembly, string resourceFileName)

Parameters

assembly Assembly
resourceFileName string

Returns

Stream

GetEmbeddedResourceStream(string)

Takes the full name of a resource and loads it in to a stream.

public static Stream GetEmbeddedResourceStream(string resourceName)

Parameters

resourceName string

Assuming an embedded resource is a file called info.png and is located in a folder called Resources, it will be compiled in to the assembly with this fully qualified name: Full.Assembly.Name.Resources.info.png. That is the string that you should pass to this method.

Returns

Stream

GetEmbeededFont(string, Assembly, string)

public SKTypeface GetEmbeededFont(string filename, Assembly assembly, string alias = null)

Parameters

filename string
assembly Assembly
alias string

Returns

SKTypeface

GetFont(string)

public SKTypeface GetFont(string alias)

Parameters

alias string

Returns

SKTypeface

GetFont(string, int)

public SKTypeface GetFont(string fontFamily, int fontWeight)

Parameters

fontFamily string
fontWeight int

Returns

SKTypeface

GetRegisteredAlias(string, int)

public static string GetRegisteredAlias(string alias, int weight)

Parameters

alias string
weight int

Returns

string

GetWeightEnum(int)

Gets the closest enum value to the given weight. Like 590 would return Semibold.

public static FontWeight GetWeightEnum(int weight)

Parameters

weight int

Returns

FontWeight

Initialize()

public void Initialize()

MatchCharacter(int)

Matches a Unicode character to an appropriate typeface with caching. This method is thread-safe and optimized for high-frequency calls.

public static SKTypeface MatchCharacter(int character)

Parameters

character int

Unicode code point to match

Returns

SKTypeface

SKTypeface that can render the character, or null if no match found

RegisterWeight(string, FontWeight)

public static void RegisterWeight(string alias, FontWeight weight)

Parameters

alias string
weight FontWeight

StringToUnicodeValues(string)

public static List<int> StringToUnicodeValues(string text)

Parameters

text string

Returns

List<int>