Class Font
Represents font object that can be using during text rendering (it uses Font Asset but with pre-cached data for chosen font properties).
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Render2D/Font.h
Syntax
public class Font : public ManagedScriptingObject
Constructors
~Font()
Font(FontAsset* parentAsset, float size)
Initializes a new instance of the Font class.
Declaration
public Font(FontAsset* parentAsset, float size)
Parameters
|
FontAsset
parentAsset
The parent asset. |
|
float
size
The size. |
Fields
FallbackFonts
The active fallback fonts.
Declaration
public static Array<AssetReference<FontAsset>, HeapAllocation> FallbackFonts
Field Value
|
Array<AssetReference<FontAsset>, HeapAllocation>
|
Methods
CacheText(const StringView& text)
Caches the given text to prepared for the rendering.
Declaration
public void CacheText(const StringView& text)
Parameters
|
StringView
text
The text witch characters to cache. |
FlushFaceSize()
Flushes the size of the face with the Free Type library backend.
Declaration
public void FlushFaceSize() const
GetAscender()
Gets the largest vertical distance above the baseline for any character in the font.
Declaration
public int32 GetAscender() const
Returns
|
int32
|
GetAsset()
Gets parent font asset that contains font family used by this font.
Declaration
public FontAsset* GetAsset() const
Returns
|
FontAsset
|
GetCharacter(Char c, FontCharacterEntry& result, bool enableFallback=true)
Gets character entry.
Declaration
public void GetCharacter(Char c, FontCharacterEntry& result, bool enableFallback=true)
Parameters
|
Char
c
The character. |
|
FontCharacterEntry
result
The output character entry. |
|
bool
enableFallback
True if fallback to secondary font when the primary font doesn't contains this character. |
GetCharPosition(const StringView& text, const TextRange& textRange, int32 index)
Calculates character position for given text and character index
Declaration
public Float2 GetCharPosition(const StringView& text, const TextRange& textRange, int32 index)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
int32
index
The text position to get coordinates of. |
Returns
|
Float2
The character position (upper left corner which can be used for a caret position). |
GetCharPosition(const StringView& text, const TextRange& textRange, int32 index, const TextLayoutOptions& layout)
Calculates character position for given text and character index.
Declaration
public Float2 GetCharPosition(const StringView& text, const TextRange& textRange, int32 index, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
int32
index
The text position to get coordinates of. |
|
TextLayoutOptions
layout
The text layout properties. |
Returns
|
Float2
The character position (upper left corner which can be used for a caret position). |
GetCharPosition(const StringView& text, int32 index)
Calculates character position for given text and character index
Declaration
public Float2 GetCharPosition(const StringView& text, int32 index)
Parameters
|
StringView
text
The input text to test. |
|
int32
index
The text position to get coordinates of. |
Returns
|
Float2
The character position (upper left corner which can be used for a caret position). |
GetCharPosition(const StringView& text, int32 index, const TextLayoutOptions& layout)
Calculates character position for given text and character index.
Declaration
public Float2 GetCharPosition(const StringView& text, int32 index, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
int32
index
The text position to get coordinates of. |
|
TextLayoutOptions
layout
The text layout properties. |
Returns
|
Float2
The character position (upper left corner which can be used for a caret position). |
GetDescender()
Gets the largest vertical distance below the baseline for any character in the font.
Declaration
public int32 GetDescender() const
Returns
|
int32
|
GetHeight()
Gets characters height.
Declaration
public int32 GetHeight() const
Returns
|
int32
|
GetKerning(Char first, Char second)
Gets the kerning amount for a pair of characters.
Declaration
public int32 GetKerning(Char first, Char second) const
Parameters
|
Char
first
The first character in the pair. |
|
Char
second
The second character in the pair. |
Returns
|
int32
The kerning amount or 0 if no kerning. |
GetLineGap()
Gets the line gap property.
Declaration
public int32 GetLineGap() const
Returns
|
int32
|
GetSize()
Gets font size.
Declaration
public float GetSize() const
Returns
|
float
|
HitTestText(const StringView& text, const Float2& location)
Calculates hit character index at given location.
Declaration
public int32 HitTestText(const StringView& text, const Float2& location)
Parameters
|
StringView
text
The input text to test. |
|
Float2
location
The input location to test. |
Returns
|
int32
The selected character position index (can be equal to text length if location is outside of the layout rectangle). |
HitTestText(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
Calculates hit character index at given location.
Declaration
public int32 HitTestText(const StringView& text, const Float2& location, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
Float2
location
The input location to test. |
|
TextLayoutOptions
layout
The text layout properties. |
Returns
|
int32
The selected character position index (can be equal to text length if location is outside of the layout rectangle). |
HitTestText(const StringView& text, const TextRange& textRange, const Float2& location)
Calculates hit character index at given location.
Declaration
public int32 HitTestText(const StringView& text, const TextRange& textRange, const Float2& location)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
Float2
location
The input location to test. |
Returns
|
int32
The selected character position index (can be equal to text length if location is outside of the layout rectangle). |
HitTestText(const StringView& text, const TextRange& textRange, const Float2& location, const TextLayoutOptions& layout)
Calculates hit character index at given location.
Declaration
public int32 HitTestText(const StringView& text, const TextRange& textRange, const Float2& location, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
Float2
location
The input location to test. |
|
TextLayoutOptions
layout
The text layout properties. |
Returns
|
int32
The selected character position index (can be equal to text length if location is outside of the layout rectangle). |
Invalidate()
Invalidates all cached dynamic font atlases using this font. Can be used to reload font characters after changing font asset options.
Declaration
public void Invalidate()
MeasureText(const StringView& text)
Measures minimum size of the rectangle that will be needed to draw given text
Declaration
public Float2 MeasureText(const StringView& text)
Parameters
|
StringView
text
The input text to test. |
Returns
|
Float2
The minimum size for that text and font to render properly. |
MeasureText(const StringView& text, const TextLayoutOptions& layout)
Measures minimum size of the rectangle that will be needed to draw given text.
Declaration
public Float2 MeasureText(const StringView& text, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
TextLayoutOptions
layout
The layout properties. |
Returns
|
Float2
The minimum size for that text and font to render properly. |
MeasureText(const StringView& text, const TextRange& textRange)
Measures minimum size of the rectangle that will be needed to draw given text
Declaration
public Float2 MeasureText(const StringView& text, const TextRange& textRange)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
Returns
|
Float2
The minimum size for that text and font to render properly. |
MeasureText(const StringView& text, const TextRange& textRange, const TextLayoutOptions& layout)
Measures minimum size of the rectangle that will be needed to draw given text.
Declaration
public Float2 MeasureText(const StringView& text, const TextRange& textRange, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text to test. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
TextLayoutOptions
layout
The layout properties. |
Returns
|
Float2
The minimum size for that text and font to render properly. |
ProcessText(const StringView& text)
Processes text to get cached lines for rendering.
Declaration
public Array<FontLineCache, InlinedAllocation<8>> ProcessText(const StringView& text)
Parameters
|
StringView
text
The input text. |
Returns
|
Array<FontLineCache, InlinedAllocation<8>>
The output lines list. |
ProcessText(const StringView& text, Array<FontLineCache, InlinedAllocation<8>>& outputLines, const TextLayoutOptions& layout)
Processes text to get cached lines for rendering.
Declaration
public void ProcessText(const StringView& text, Array<FontLineCache, InlinedAllocation<8>>& outputLines, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text. |
|
Array<FontLineCache, InlinedAllocation<8>>
outputLines
The output lines list. |
|
TextLayoutOptions
layout
The layout properties. |
ProcessText(const StringView& text, const TextLayoutOptions& layout)
Processes text to get cached lines for rendering.
Declaration
public Array<FontLineCache, InlinedAllocation<8>> ProcessText(const StringView& text, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text. |
|
TextLayoutOptions
layout
The layout properties. |
Returns
|
Array<FontLineCache, InlinedAllocation<8>>
The output lines list. |
ProcessText(const StringView& text, const TextRange& textRange)
Processes text to get cached lines for rendering.
Declaration
public Array<FontLineCache, InlinedAllocation<8>> ProcessText(const StringView& text, const TextRange& textRange)
Parameters
|
StringView
text
The input text. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
Returns
|
Array<FontLineCache, InlinedAllocation<8>>
The output lines list. |
ProcessText(const StringView& text, const TextRange& textRange, const TextLayoutOptions& layout)
Processes text to get cached lines for rendering.
Declaration
public Array<FontLineCache, InlinedAllocation<8>> ProcessText(const StringView& text, const TextRange& textRange, const TextLayoutOptions& layout)
Parameters
|
StringView
text
The input text. |
|
TextRange
textRange
The input text range (substring range of the input text parameter). |
|
TextLayoutOptions
layout
The layout properties. |
Returns
|
Array<FontLineCache, InlinedAllocation<8>>
The output lines list. |
ToString()
Gets the string representation of this object.
Declaration
public virtual String ToString() const override
Returns
|
String
|