UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FSlateFontCache Class Reference

#include <FontCache.h>

+ Inheritance diagram for FSlateFontCache:

Public Member Functions

SLATECORE_API FSlateFontCache (TSharedRef< ISlateFontAtlasFactory > InFontAtlasFactory, ESlateTextureAtlasThreadId InOwningThread)
 
virtual SLATECORE_API ~FSlateFontCache ()
 
virtual SLATECORE_API int32 GetNumAtlasPages () const override
 
virtual SLATECORE_API FSlateShaderResourceGetAtlasPageResource (const int32 InIndex) const override
 
virtual SLATECORE_API bool IsAtlasPageResourceAlphaOnly (const int32 InIndex) const override
 
SLATECORE_API FShapedGlyphSequenceRef ShapeBidirectionalText (const FString &InText, const FSlateFontInfo &InFontInfo, const float InFontScale, const TextBiDi::ETextDirection InBaseDirection, const ETextShapingMethod InTextShapingMethod) const
 
SLATECORE_API FShapedGlyphSequenceRef ShapeBidirectionalText (const TCHAR *InText, const int32 InTextStart, const int32 InTextLen, const FSlateFontInfo &InFontInfo, const float InFontScale, const TextBiDi::ETextDirection InBaseDirection, const ETextShapingMethod InTextShapingMethod) const
 
SLATECORE_API FShapedGlyphSequenceRef ShapeUnidirectionalText (const FString &InText, const FSlateFontInfo &InFontInfo, const float InFontScale, const TextBiDi::ETextDirection InTextDirection, const ETextShapingMethod InTextShapingMethod) const
 
SLATECORE_API FShapedGlyphSequenceRef ShapeUnidirectionalText (const TCHAR *InText, const int32 InTextStart, const int32 InTextLen, const FSlateFontInfo &InFontInfo, const float InFontScale, const TextBiDi::ETextDirection InTextDirection, const ETextShapingMethod InTextShapingMethod) const
 
SLATECORE_API FShapedGlyphSequenceRef ShapeOverflowEllipsisText (const FSlateFontInfo &InFontInfo, const float InFontScale)
 
SLATECORE_API class FCharacterListGetCharacterList (const FSlateFontInfo &InFontInfo, float FontScale, const FFontOutlineSettings &InOutlineSettings=FFontOutlineSettings::NoOutline)
 
SLATECORE_API FShapedGlyphFontAtlasData GetShapedGlyphFontAtlasData (const FShapedGlyphEntry &InShapedGlyph, const FFontOutlineSettings &InOutlineSettings)
 
SLATECORE_API FSdfGlyphFontAtlasData GetSdfGlyphFontAtlasData (const FShapedGlyphEntry &InShapedGlyph, const FFontOutlineSettings &InOutlineSettings)
 
SLATECORE_API FShapedGlyphSequenceRef GetOverflowEllipsisText (const FSlateFontInfo &InFontInfo, const float InFontScale)
 
SLATECORE_API void FlushObject (const UObject *const InObject)
 
SLATECORE_API void FlushCompositeFont (const FCompositeFont &InCompositeFont)
 
SLATECORE_API bool ConditionalFlushCache ()
 
SLATECORE_API void UpdateCache ()
 
SLATECORE_API void ReleaseResources ()
 
FOnReleaseFontResourcesOnReleaseResources ()
 
ISlateFontTextureGetFontTexture (uint32 Index)
 
SLATECORE_API const FFontDataGetDefaultFontData (const FSlateFontInfo &InFontInfo) const
 
SLATECORE_API const FFontDataGetFontDataForCodepoint (const FSlateFontInfo &InFontInfo, const UTF32CHAR InCodepoint, float &OutScalingFactor) const
 
SLATECORE_API bool HasLoadedFontForCodepoint (const FSlateFontInfo &InFontInfo, const UTF32CHAR InCodepoint) const
 
SLATECORE_API uint16 GetMaxCharacterHeight (const FSlateFontInfo &InFontInfo, float FontScale) const
 
SLATECORE_API int16 GetBaseline (const FSlateFontInfo &InFontInfo, float FontScale) const
 
SLATECORE_API void GetUnderlineMetrics (const FSlateFontInfo &InFontInfo, const float FontScale, int16 &OutUnderlinePos, int16 &OutUnderlineThickness) const
 
SLATECORE_API void GetStrikeMetrics (const FSlateFontInfo &InFontInfo, const float FontScale, int16 &OutStrikeLinePos, int16 &OutStrikeLineThickness) const
 
SLATECORE_API int8 GetKerning (const FFontData &InFontData, const float InSize, TCHAR First, TCHAR Second, float Scale) const
 
SLATECORE_API bool HasKerning (const FFontData &InFontData) const
 
SLATECORE_API bool CanLoadCodepoint (const FFontData &InFontData, const UTF32CHAR InCodepoint, EFontFallback MaxFallbackLevel=EFontFallback::FF_NoFallback) const
 
SLATECORE_API const TSet< FName > & GetFontAttributes (const FFontData &InFontData) const
 
SLATECORE_API TArray< FString > GetAvailableFontSubFaces (FFontFaceDataConstRef InMemory) const
 
SLATECORE_API TArray< FString > GetAvailableFontSubFaces (const FString &InFilename) const
 
SLATECORE_API void RequestFlushCache (const FString &FlushReason)
 
SLATECORE_API void FlushData ()
 
SLATECORE_API SIZE_T GetFontDataAssetResidentMemory (const UObject *FontDataAsset) const
 
- Public Member Functions inherited from ISlateAtlasProvider
virtual ~ISlateAtlasProvider ()
 
- Public Member Functions inherited from FSlateFlushableAtlasCache
 FSlateFlushableAtlasCache (const FAtlasFlushParams *InFlushParams)
 
virtual ~FSlateFlushableAtlasCache ()
 
void ResetFlushCounters ()
 
void UpdateFlushCounters (int32 NumGrayscale, int32 NumColor, int32 NumMsdf, int32 NumNonAtlased)
 

Detailed Description

Font caching implementation Caches characters into textures as needed

Constructor & Destructor Documentation

◆ FSlateFontCache()

FSlateFontCache::FSlateFontCache ( TSharedRef< ISlateFontAtlasFactory InFontAtlasFactory,
ESlateTextureAtlasThreadId  InOwningThread 
)

Constructor

Parameters
InTextureSizeThe size of the atlas texture
InFontAlasPlatform specific font atlas resource

◆ ~FSlateFontCache()

FSlateFontCache::~FSlateFontCache ( )
virtual

Member Function Documentation

◆ CanLoadCodepoint()

bool FSlateFontCache::CanLoadCodepoint ( const FFontData InFontData,
const UTF32CHAR  InCodepoint,
EFontFallback  MaxFallbackLevel = EFontFallback::FF_NoFallback 
) const

Whether or not the specified character, within the specified font, can be loaded with the specified maximum font fallback level

Parameters
InFontDataInformation about the font to load
InCodepointThe codepoint being loaded
MaxFallbackLevelThe maximum fallback level to try for the font
Returns
Whether or not the character can be loaded

◆ ConditionalFlushCache()

bool FSlateFontCache::ConditionalFlushCache ( )

Flush the cache if needed

◆ FlushCompositeFont()

void FSlateFontCache::FlushCompositeFont ( const FCompositeFont InCompositeFont)

Flush the given composite font out of the cache

◆ FlushData()

void FSlateFontCache::FlushData ( )

Clears just the cached font data, but leaves the atlases alone

◆ FlushObject()

void FSlateFontCache::FlushObject ( const UObject *const  InObject)

Flush the given object out of the cache

◆ GetAtlasPageResource()

FSlateShaderResource * FSlateFontCache::GetAtlasPageResource ( const int32  InIndex) const
overridevirtual

Get the page resource for the given index (verify with GetNumAtlasPages)

Implements ISlateAtlasProvider.

◆ GetAvailableFontSubFaces() [1/2]

TArray< FString > FSlateFontCache::GetAvailableFontSubFaces ( const FString &  InFilename) const

◆ GetAvailableFontSubFaces() [2/2]

TArray< FString > FSlateFontCache::GetAvailableFontSubFaces ( FFontFaceDataConstRef  InMemory) const

Get the available sub-face data from the given font. Typically there will only be one face unless this is a TTC/OTC font. The index of the returned entry can be passed as InFaceIndex to the FFreeTypeFace constructor.

◆ GetBaseline()

int16 FSlateFontCache::GetBaseline ( const FSlateFontInfo InFontInfo,
float  FontScale 
) const

Returns the baseline for the specified font.

Parameters
InFontInfoA descriptor of the font to get character size for
FontScaleThe scale to apply to the font
Returns
The offset from the bottom of the max character height to the baseline.

◆ GetCharacterList()

FCharacterList & FSlateFontCache::GetCharacterList ( const FSlateFontInfo InFontInfo,
float  FontScale,
const FFontOutlineSettings InOutlineSettings = FFontOutlineSettings::NoOutline 
)

Gets information for how to draw all non-shaped characters in the specified string. Caches characters as they are found

Parameters
InFontInfoInformation about the font that the string is drawn with
FontScaleThe scale to apply to the font
OutCharacterEntriesPopulated array of character entries. Indices of characters in Text match indices in this array

◆ GetDefaultFontData()

const FFontData & FSlateFontCache::GetDefaultFontData ( const FSlateFontInfo InFontInfo) const

Returns the font to use from the default typeface

Parameters
InFontInfoA descriptor of the font to get the default typeface for
Returns
The raw font data

◆ GetFontAttributes()

const TSet< FName > & FSlateFontCache::GetFontAttributes ( const FFontData InFontData) const

Returns the font attributes for the specified font.

Parameters
InFontDataThe font to get attributes for
Returns
The font attributes for the specified font.

◆ GetFontDataAssetResidentMemory()

SIZE_T FSlateFontCache::GetFontDataAssetResidentMemory ( const UObject FontDataAsset) const

Gets the allocated font face data for a font data asset

◆ GetFontDataForCodepoint()

const FFontData & FSlateFontCache::GetFontDataForCodepoint ( const FSlateFontInfo InFontInfo,
const UTF32CHAR  InCodepoint,
float OutScalingFactor 
) const

Returns the font to use from the typeface associated with the given codepoint

Parameters
InFontInfoA descriptor of the font to get the typeface for
InCodepointThe codepoint to get the typeface associated with
OutScalingFactorThe scaling factor applied to characters rendered with the given font
Returns
The raw font data

◆ GetFontTexture()

ISlateFontTexture * FSlateFontCache::GetFontTexture ( uint32  Index)
inline

Get the texture resource for a font atlas at a given index

Parameters
IndexThe index of the texture
Returns
Handle to the texture resource

◆ GetKerning()

int8 FSlateFontCache::GetKerning ( const FFontData InFontData,
const float  InSize,
TCHAR  First,
TCHAR  Second,
float  Scale 
) const

Calculates the kerning amount for a pair of characters

Parameters
InFontDataThe font that used to draw the string with the first and second characters
InSizeThe size of the font to draw
FirstThe first character in the pair
SecondThe second character in the pair
Returns
The kerning amount, 0 if no kerning

◆ GetMaxCharacterHeight()

uint16 FSlateFontCache::GetMaxCharacterHeight ( const FSlateFontInfo InFontInfo,
float  FontScale 
) const

Returns the height of the largest character in the font.

Parameters
InFontInfoA descriptor of the font to get character size for
FontScaleThe scale to apply to the font
Returns
The largest character height

◆ GetNumAtlasPages()

int32 FSlateFontCache::GetNumAtlasPages ( ) const
overridevirtual

◆ GetOverflowEllipsisText()

FShapedGlyphSequenceRef FSlateFontCache::GetOverflowEllipsisText ( const FSlateFontInfo InFontInfo,
const float  InFontScale 
)

Gets the overflow glyph sequence for a given font. The overflow sequence is used to replace characters that are clipped

◆ GetSdfGlyphFontAtlasData()

FSdfGlyphFontAtlasData FSlateFontCache::GetSdfGlyphFontAtlasData ( const FShapedGlyphEntry InShapedGlyph,
const FFontOutlineSettings InOutlineSettings 
)

Get the atlas information and the scaled metrics of a given shaped sdf glyph. This information will be cached if required.

◆ GetShapedGlyphFontAtlasData()

FShapedGlyphFontAtlasData FSlateFontCache::GetShapedGlyphFontAtlasData ( const FShapedGlyphEntry InShapedGlyph,
const FFontOutlineSettings InOutlineSettings 
)

Get the atlas information for the given shaped glyph. This information will be cached if required

◆ GetStrikeMetrics()

void FSlateFontCache::GetStrikeMetrics ( const FSlateFontInfo InFontInfo,
const float  FontScale,
int16 OutStrikeLinePos,
int16 OutStrikeLineThickness 
) const

Get the strike metrics for the specified font.

Parameters
InFontInfoA descriptor of the font to get character size for
FontScaleThe scale to apply to the font
OutStrikeLinePosThe offset from the baseline to the center of the strike bar
OutStrikeLineThicknessThe thickness of the strike bar

◆ GetUnderlineMetrics()

void FSlateFontCache::GetUnderlineMetrics ( const FSlateFontInfo InFontInfo,
const float  FontScale,
int16 OutUnderlinePos,
int16 OutUnderlineThickness 
) const

Get the underline metrics for the specified font.

Parameters
InFontInfoA descriptor of the font to get character size for
FontScaleThe scale to apply to the font
OutUnderlinePosThe offset from the baseline to the center of the underline bar
OutUnderlineThicknessThe thickness of the underline bar

◆ HasKerning()

bool FSlateFontCache::HasKerning ( const FFontData InFontData) const
Returns
Whether or not the font used has kerning information

◆ HasLoadedFontForCodepoint()

bool FSlateFontCache::HasLoadedFontForCodepoint ( const FSlateFontInfo InFontInfo,
const UTF32CHAR  InCodepoint 
) const

Returns true if the font to use from the typeface associated with the given codepoint is already loaded

Parameters
InFontInfoA descriptor of the font to get the typeface for
InCodepointThe codepoint to get the typeface associated with
Returns
FontData is already loaded

◆ IsAtlasPageResourceAlphaOnly()

bool FSlateFontCache::IsAtlasPageResourceAlphaOnly ( const int32  InIndex) const
overridevirtual

Does the page resources for the given index only contain alpha information? This affects how the atlas visualizer will sample them (verify with GetNumAtlasPages)

Implements ISlateAtlasProvider.

◆ OnReleaseResources()

FOnReleaseFontResources & FSlateFontCache::OnReleaseResources ( )
inline

Event called after releasing the rendering resources in ReleaseResources

◆ ReleaseResources()

void FSlateFontCache::ReleaseResources ( )

Releases rendering resources

◆ RequestFlushCache()

void FSlateFontCache::RequestFlushCache ( const FString &  FlushReason)
virtual

Issues a request to clear all cached data from the cache

Implements FSlateFlushableAtlasCache.

◆ ShapeBidirectionalText() [1/2]

FShapedGlyphSequenceRef FSlateFontCache::ShapeBidirectionalText ( const FString &  InText,
const FSlateFontInfo InFontInfo,
const float  InFontScale,
const TextBiDi::ETextDirection  InBaseDirection,
const ETextShapingMethod  InTextShapingMethod 
) const

Performs text shaping on the given string using the given font info. Returns you the shaped text sequence to use for text rendering via FSlateDrawElement::MakeShapedText. When using the version which takes a start point and length, the text outside of the given range won't be shaped, but will provide context information to allow the shaping to function correctly. ShapeBidirectionalText is used when you have text that may contain a mixture of LTR and RTL text runs.

Parameters
InTextThe string to shape
InTextStartThe start position of the text to shape
InTextLenThe length of the text to shape
InFontInfoInformation about the font that the string is drawn with
InFontScaleThe scale to apply to the font
InBaseDirectionThe overall reading direction of the text (see TextBiDi::ComputeBaseDirection). This will affect where some characters (such as brackets and quotes) are placed within the resultant shaped text
InTextShapingMethodThe text shaping method to use

◆ ShapeBidirectionalText() [2/2]

FShapedGlyphSequenceRef FSlateFontCache::ShapeBidirectionalText ( const TCHAR InText,
const int32  InTextStart,
const int32  InTextLen,
const FSlateFontInfo InFontInfo,
const float  InFontScale,
const TextBiDi::ETextDirection  InBaseDirection,
const ETextShapingMethod  InTextShapingMethod 
) const

◆ ShapeOverflowEllipsisText()

FShapedGlyphSequenceRef FSlateFontCache::ShapeOverflowEllipsisText ( const FSlateFontInfo InFontInfo,
const float  InFontScale 
)

Performs text shaping on the overflow glyph sequence for a given font. The overflow sequence is used to replace characters that are clipped

◆ ShapeUnidirectionalText() [1/2]

FShapedGlyphSequenceRef FSlateFontCache::ShapeUnidirectionalText ( const FString &  InText,
const FSlateFontInfo InFontInfo,
const float  InFontScale,
const TextBiDi::ETextDirection  InTextDirection,
const ETextShapingMethod  InTextShapingMethod 
) const

Performs text shaping on the given range of the string using the given font info. Returns you the shaped text sequence to use for text rendering via FSlateDrawElement::MakeShapedText. When using the version which takes a start point and length, the text outside of the given range won't be shaped, but will provide context information to allow the shaping to function correctly. ShapeUnidirectionalText is used when you have text that all reads in the same direction (either LTR or RTL).

Parameters
InTextThe string containing the sub-string to shape
InTextStartThe start position of the text to shape
InTextLenThe length of the text to shape
InFontInfoInformation about the font that the string is drawn with
InFontScaleThe scale to apply to the font
InTextDirectionThe reading direction of the text to shape (valid values are LeftToRight or RightToLeft)
InTextShapingMethodThe text shaping method to use

◆ ShapeUnidirectionalText() [2/2]

FShapedGlyphSequenceRef FSlateFontCache::ShapeUnidirectionalText ( const TCHAR InText,
const int32  InTextStart,
const int32  InTextLen,
const FSlateFontInfo InFontInfo,
const float  InFontScale,
const TextBiDi::ETextDirection  InTextDirection,
const ETextShapingMethod  InTextShapingMethod 
) const

◆ UpdateCache()

void FSlateFontCache::UpdateCache ( )

Updates the texture used for rendering


The documentation for this class was generated from the following files: