Slate.FlushFontCache
Slate.FlushFontCache
#Overview
name: Slate.FlushFontCache
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Flush the font cache.
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.FlushFontCache is to provide a way to flush the Slate font cache on demand. This setting variable is part of the Slate UI framework in Unreal Engine 5, specifically related to font rendering and caching.
The Slate subsystem, which is responsible for the user interface rendering in Unreal Engine, relies on this setting variable. It is primarily used in the SlateCore module, as evident from the file path “Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp”.
The value of this variable is set through the console variable system in Unreal Engine. It is declared as an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.
This variable interacts directly with the associated boolean variable ‘bFlushFontCache’. They share the same value, and ‘bFlushFontCache’ is used in the actual code logic to determine when to flush the font cache.
Developers must be aware that this variable is only active in non-shipping builds (#if !UE_BUILD_SHIPPING). This means it’s intended for development and debugging purposes, not for use in final, released versions of the game.
Best practices when using this variable include:
- Use it sparingly, as flushing the font cache can impact performance.
- Utilize it for debugging font-related issues during development.
- Remember that it won’t have any effect in shipping builds.
Regarding the associated variable ‘bFlushFontCache’:
The purpose of ‘bFlushFontCache’ is to act as the actual boolean flag that controls whether the font cache should be flushed. It is directly manipulated by the Slate.FlushFontCache console variable.
This variable is used within the FSlateFontCache::ConditionalFlushCache function to determine if a cache flush should occur. When set to true, it triggers a font cache flush, which can be useful for debugging or resetting the font state during development.
The value of ‘bFlushFontCache’ is set by the console variable system when Slate.FlushFontCache is modified.
Developers should be aware that this variable is also only checked in non-shipping builds. It’s important to note that frequent flushing of the font cache could negatively impact performance, so it should be used judiciously during development and debugging sessions.
Best practices for ‘bFlushFontCache’ include:
- Use it in conjunction with Slate.FlushFontCache for debugging font issues.
- Be prepared for potential performance impacts when the cache is flushed.
- Remember to reset it to false after debugging to ensure normal font caching behavior.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:66
Scope: file
Source code excerpt:
static bool bFlushFontCache = false;
FAutoConsoleVariableRef CVarFlushFontCache(
TEXT("Slate.FlushFontCache"),
bFlushFontCache,
TEXT("Flush the font cache."));
#endif
static TAutoConsoleVariable<bool> CVarSlateSdfTextEnable(TEXT("SlateSdfText.Enable"), false, TEXT("Enables MSDF-based text rendering in Slate"));
#Associated Variable and Callsites
This variable is associated with another variable named bFlushFontCache
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:64
Scope: file
Source code excerpt:
TEXT("Dump statistics about font cache usage."));
static bool bFlushFontCache = false;
FAutoConsoleVariableRef CVarFlushFontCache(
TEXT("Slate.FlushFontCache"),
bFlushFontCache,
TEXT("Flush the font cache."));
#endif
static TAutoConsoleVariable<bool> CVarSlateSdfTextEnable(TEXT("SlateSdfText.Enable"), false, TEXT("Enables MSDF-based text rendering in Slate"));
bool IsSlateSdfTextFeatureEnabled()
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:1685
Scope (from outer to inner):
file
function bool FSlateFontCache::ConditionalFlushCache
Source code excerpt:
if (bFlushRequested
#if !UE_BUILD_SHIPPING
|| bFlushFontCache
#endif
)
{
if (FlushCache())
{
bFlushRequested = false;
#if !UE_BUILD_SHIPPING
bFlushFontCache = false;
#endif
bFlushed = true;
}
}
if (!bFlushed && IsInGameThread())