Slate.DefaultTextShapingMethod
Slate.DefaultTextShapingMethod
#Overview
name: Slate.DefaultTextShapingMethod
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Auto (default), 1: KerningOnly, 2: FullShaping.
It is referenced in 5
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.DefaultTextShapingMethod is to control the default text shaping method used in the Slate UI framework of Unreal Engine 5. This setting variable is part of the text rendering system within Slate.
This setting variable is primarily used by the SlateCore module, which is a core component of Unreal Engine’s UI system. It’s specifically utilized in the font caching and text shaping subsystems.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable in the FontCache.cpp file, allowing it to be changed at runtime via console commands or configuration files.
The Slate.DefaultTextShapingMethod interacts closely with the CVarDefaultTextShapingMethod variable. They essentially represent the same setting, with CVarDefaultTextShapingMethod being the actual console variable implementation.
Developers should be aware that this variable affects the text rendering performance and appearance across the entire Slate UI system. The chosen method can impact both the speed of text rendering and the accuracy of complex text layouts, especially for right-to-left languages.
Best practices when using this variable include:
- Leave it at the default “Auto” setting unless there’s a specific need to change it.
- If changing, test thoroughly with various text content, especially if your application supports multiple languages.
- Be aware of the performance implications, particularly when dealing with large amounts of text.
Regarding the associated variable CVarDefaultTextShapingMethod:
The purpose of CVarDefaultTextShapingMethod is to provide a programmatic interface to the Slate.DefaultTextShapingMethod setting. It’s the actual console variable that stores and manages the value of the text shaping method.
This variable is used directly in the SlateCore module, specifically in the font caching and text shaping systems. It’s defined and used in the FontCache.cpp file.
The value of CVarDefaultTextShapingMethod is set when the console variable is initialized, but it can be changed at runtime through console commands or configuration files.
CVarDefaultTextShapingMethod interacts directly with the ETextShapingMethod enum, which defines the available text shaping methods (Auto, KerningOnly, FullShaping).
Developers should be aware that changes to CVarDefaultTextShapingMethod will immediately affect text rendering across the Slate UI system. It’s important to use the correct integer values corresponding to the ETextShapingMethod enum when setting this variable.
Best practices for CVarDefaultTextShapingMethod include:
- Use the GetDefaultTextShapingMethod() function to retrieve the current value, rather than accessing the CVar directly.
- When setting the value, use the defined enum values rather than raw integers to ensure correctness.
- Consider exposing this setting in your game’s options menu if you want to allow users to adjust text rendering for performance or visual quality.
#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:51
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDefaultTextShapingMethod(
TEXT("Slate.DefaultTextShapingMethod"),
static_cast<int32>(ETextShapingMethod::Auto),
TEXT("0: Auto (default), 1: KerningOnly, 2: FullShaping."),
ECVF_Default
);
#if !UE_BUILD_SHIPPING
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Public/Fonts/FontCache.h:69
Scope: file
Source code excerpt:
};
/** Get the default shaping method (from the "Slate.DefaultTextShapingMethod" CVar) */
SLATECORE_API ETextShapingMethod GetDefaultTextShapingMethod();
/** The font atlas data for a single glyph in a shaped text sequence */
struct FShapedGlyphFontAtlasData
{
/** The vertical distance from the baseline to the topmost border of the glyph bitmap */
#Associated Variable and Callsites
This variable is associated with another variable named CVarDefaultTextShapingMethod
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:50
Scope: file
Source code excerpt:
TEXT("Releases the free type data when the font cache is flushed"));
static TAutoConsoleVariable<int32> CVarDefaultTextShapingMethod(
TEXT("Slate.DefaultTextShapingMethod"),
static_cast<int32>(ETextShapingMethod::Auto),
TEXT("0: Auto (default), 1: KerningOnly, 2: FullShaping."),
ECVF_Default
);
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:80
Scope (from outer to inner):
file
function ETextShapingMethod GetDefaultTextShapingMethod
Source code excerpt:
ETextShapingMethod GetDefaultTextShapingMethod()
{
const int32 DefaultTextShapingMethodAsInt = CVarDefaultTextShapingMethod.AsVariable()->GetInt();
if (DefaultTextShapingMethodAsInt >= static_cast<int32>(ETextShapingMethod::Auto) && DefaultTextShapingMethodAsInt <= static_cast<int32>(ETextShapingMethod::FullShaping))
{
return static_cast<ETextShapingMethod>(DefaultTextShapingMethodAsInt);
}
return ETextShapingMethod::Auto;
}
#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Public/Fonts/FontCache.h:44
Scope: file
Source code excerpt:
/**
* Methods that can be used to shape text.
* @note If you change this enum, make sure and update CVarDefaultTextShapingMethod and GetDefaultTextShapingMethod.
*/
UENUM(BlueprintType)
enum class ETextShapingMethod : uint8
{
/**
* Automatically picks the fastest possible shaping method (either KerningOnly or FullShaping) based on the reading direction of the text.
* Left-to-right text uses the KerningOnly method, and right-to-left text uses the FullShaping method.
*/
Auto = 0,