Class FontClient
Definition
- Assembly:
- Tizen.NUI.dll
FontClient provides access to font information and resources.
public class FontClient : BaseHandle, IDynamicResourceHandler, INameScope, System.IDisposable
- Inheritance
- Implements
-
System.IDisposable
Properties
View SourceInstance
Gets the singleton pattern of the FontClient object.
Declaration
public static FontClient Instance { get; }
Property Value
| Type | Description |
|---|---|
| FontClient |
Methods
View SourceAddCustomFontDirectory(string)
Adds custom fonts directory.
Declaration
public bool AddCustomFontDirectory(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | Path to the fonts directory. |
Returns
| Type | Description |
|---|---|
| bool | True if the fonts can be added. |
Dispose(bool)
Declaration
protected override void Dispose(bool disposing)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | disposing |
Overrides
View SourceEnableDesignCompatibility()
Enable font specific design compatibility mode globally.
note
This is a one-way switch. Once enabled, it cannot be disabled again during the lifetime of the process. This function must be called before any text is rendered.
Declaration
public static void EnableDesignCompatibility()
FindDefaultFont(uint, uint, bool)
Finds the default font for displaying a UTF-32 character.
Declaration
public uint FindDefaultFont(uint charcode, uint requestedPointSize, bool preferColor)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | charcode | The character for which a font is needed. |
| uint | requestedPointSize | The point size in 26.6 fractional points. The default point size is 12*64. |
| bool | preferColor | True if a color font is preferred. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
FindDefaultFont(uint, uint)
Find the default font for displaying a UTF-32 character.
Declaration
public uint FindDefaultFont(uint charcode, uint requestedPointSize)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | charcode | The character for which a font is needed. |
| uint | requestedPointSize | The point size in 26.6 fractional points. The default point size is 12*64. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
FindDefaultFont(uint)
Find the default font for displaying a UTF-32 character.
Declaration
public uint FindDefaultFont(uint charcode)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | charcode | The character for which a font is needed. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
FontPreLoad(List<string>, List<string>, bool, bool)
This is used to pre-load FreeType font face in order to improve the runtime performance of the application.
note
The fonts in the fontPathList perform FT_New_Face during pre-loading, which can provide some performace benefits.
The fonts in the memoryFontPathList read the font file and cache the buffer in memory during pre-load.
This enables the use of FT_New_Memory_Face during runtime and provides a performance boost.
It requires memory equivalent to the size of each font file.
Declaration
public static void FontPreLoad(List<string> fontPathList, List<string> memoryFontPathList, bool useThread, bool syncCreation = true)
Parameters
| Type | Name | Description |
|---|---|---|
| List<><string> | fontPathList | A list of font paths to be pre-loaded. |
| List<><string> | memoryFontPathList | A list of memory font paths to be pre-loaded. |
| bool | useThread | True if the font client should create thread and perform font pre-loading, false otherwise. |
| bool | syncCreation | True if thread creation guarantees syncronization with the main thread, false async creation. Optional, the default value is true. |
GetFontId(string, uint, uint)
Retrieve the unique identifier for a font.
Declaration
public uint GetFontId(string path, uint requestedPointSize, uint faceIndex)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to a font file. |
| uint | requestedPointSize | The point size in 26.6 fractional points. The default point size is 12*64. |
| uint | faceIndex | The index of the font face. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
GetFontId(string, uint)
Retrieve the unique identifier for a font.
Declaration
public uint GetFontId(string path, uint requestedPointSize)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to a font file. |
| uint | requestedPointSize | The point size in 26.6 fractional points. The default point size is 12*64. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
GetFontId(string)
Retrieve the unique identifier for a font.
Declaration
public uint GetFontId(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path to a font file. |
Returns
| Type | Description |
|---|---|
| uint | A valid font identifier. Zero if the font does not exist. |
GetPointSize(uint)
Retrieves the font point size of a given font id.
Declaration
public uint GetPointSize(uint id)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | id | The font identifier. |
Returns
| Type | Description |
|---|---|
| uint | The point size in 26.6 fractional points. |
GetSystemFonts()
Retrieve the list of font info supported by the system.
Declaration
public List<FontInfo> GetSystemFonts()
Returns
| Type | Description |
|---|---|
| List<><FontInfo> | The list of FontInfo |
Remarks
Examples
The following example demonstrates how to use the GetSystemFonts method.
var fontList = FontClient.Instance.GetSystemFonts();
foreach(Tizen.NUI.Text.FontInfo fontInfo in fontList)
{
string fontFamily = fontInfo.Family;
string fontPath = fontInfo.Path;
FontWidthType fontWidth = fontInfo.Style.Width;
FontWeightType fontWeight = fontInfo.Style.Weight;
FontSlantType fontSlant = fontInfo.Style.Slant;
}
View Source
IsCharacterSupportedByFont(uint, uint)
Whether the given character is supported by the font.
Declaration
public bool IsCharacterSupportedByFont(uint fontId, uint character)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | fontId | The id of the font. |
| uint | character | The character in a font. |
Returns
| Type | Description |
|---|---|
| bool | True if the character is supported by the font. |
IsScalable(string)
Check to see if a font is scalable.
Declaration
public bool IsScalable(string path)
Parameters
| Type | Name | Description |
|---|---|---|
| string | path | The path where the font file is located. |
Returns
| Type | Description |
|---|---|
| bool | True if scalable. |
PreCache(List<string>, List<string>, string, bool, bool)
This is used to pre-cache FontConfig in order to improve the runtime performance of the application.
Declaration
public static void PreCache(List<string> fallbackFamilyList, List<string> extraFamilyList, string localeFamily, bool useThread, bool syncCreation = true)
Parameters
| Type | Name | Description |
|---|---|---|
| List<><string> | fallbackFamilyList | A list of fallback font families to be pre-cached. |
| List<><string> | extraFamilyList | A list of additional font families to be pre-cached. |
| string | localeFamily | A locale font family to be pre-cached. |
| bool | useThread | True if the font client should create thread and perform pre-caching, false otherwise. |
| bool | syncCreation | True if thread creation guarantees syncronization with the main thread, false async creation. Optional, the default value is true. |
ResetSystemDefaults()
Called when the user changes the system defaults.
Declaration
public void ResetSystemDefaults()