Slate.DefaultTextFlowDirection
Slate.DefaultTextFlowDirection
#Overview
name: Slate.DefaultTextFlowDirection
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
0: Auto (default), 1: LeftToRight, 2: RightToLeft.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of Slate.DefaultTextFlowDirection is to control the default text flow direction in the Slate UI framework of Unreal Engine 5. It determines how text is laid out and read, which is particularly important for supporting different languages and writing systems.
This setting variable is primarily used by the Slate subsystem, which is responsible for Unreal Engine’s user interface framework. Based on the callsites, it’s evident that this variable is utilized in the text layout functionality of Slate.
The value of this variable is set through a console variable (CVar) system. It’s defined using TAutoConsoleVariable, which allows it to be changed at runtime through console commands or configuration files.
The associated variable CVarDefaultTextFlowDirection directly interacts with Slate.DefaultTextFlowDirection. They essentially represent the same setting, with CVarDefaultTextFlowDirection being the actual CVar object used in the code.
Developers must be aware that this variable accepts three possible values: 0: Auto (default) 1: LeftToRight 2: RightToLeft
When using this variable, developers should consider the following:
- The default value is “Auto”, which attempts to detect the appropriate flow direction based on the text content.
- This setting affects all text rendered using the Slate framework unless overridden locally.
- Changing this value can have a significant impact on text readability, especially for right-to-left languages.
Best practices when using this variable include:
- Use “Auto” unless there’s a specific reason to force a direction.
- When developing for multiple languages, test thoroughly with this setting to ensure proper text rendering for all supported languages.
- Consider providing an in-game option for users to change this setting if your game supports multiple languages with different text flow directions.
Regarding the associated variable CVarDefaultTextFlowDirection: Its purpose is to provide a programmatic interface to the Slate.DefaultTextFlowDirection setting. It’s defined as a TAutoConsoleVariable, which allows for runtime modification and querying of the value.
The CVarDefaultTextFlowDirection variable is used directly in the GetDefaultTextFlowDirection() function to retrieve the current setting value. This function also includes validation to ensure the returned value is within the valid range of the ETextFlowDirection enum.
Developers should be aware that modifying CVarDefaultTextFlowDirection directly will affect the Slate.DefaultTextFlowDirection setting. It’s generally better to use the console variable system to modify this setting rather than changing the CVarDefaultTextFlowDirection variable directly in code.
Best practices for CVarDefaultTextFlowDirection include using the GetDefaultTextFlowDirection() function to retrieve the current value, rather than accessing the CVar directly, as this function includes proper validation and type conversion.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Text/TextLayout.cpp:17
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarDefaultTextFlowDirection(
TEXT("Slate.DefaultTextFlowDirection"),
static_cast<int32>(ETextFlowDirection::Auto),
TEXT("0: Auto (default), 1: LeftToRight, 2: RightToLeft."),
ECVF_Default
);
ETextFlowDirection GetDefaultTextFlowDirection()
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Public/Framework/Text/TextLayout.h:92
Scope: file
Source code excerpt:
};
/** Get the default text flow direction (from the "Slate.DefaultTextFlowDirection" CVar) */
SLATE_API ETextFlowDirection GetDefaultTextFlowDirection();
/** Location within the text model. */
struct FTextLocation
{
public:
#Associated Variable and Callsites
This variable is associated with another variable named CVarDefaultTextFlowDirection
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Private/Framework/Text/TextLayout.cpp:16
Scope: file
Source code excerpt:
DECLARE_CYCLE_STAT(TEXT("Text Layout"), STAT_SlateTextLayout, STATGROUP_Slate);
static TAutoConsoleVariable<int32> CVarDefaultTextFlowDirection(
TEXT("Slate.DefaultTextFlowDirection"),
static_cast<int32>(ETextFlowDirection::Auto),
TEXT("0: Auto (default), 1: LeftToRight, 2: RightToLeft."),
ECVF_Default
);
ETextFlowDirection GetDefaultTextFlowDirection()
{
const int32 DefaultTextFlowDirectionAsInt = CVarDefaultTextFlowDirection.AsVariable()->GetInt();
if (DefaultTextFlowDirectionAsInt >= static_cast<int32>(ETextFlowDirection::Auto) && DefaultTextFlowDirectionAsInt <= static_cast<int32>(ETextFlowDirection::RightToLeft))
{
return static_cast<ETextFlowDirection>(DefaultTextFlowDirectionAsInt);
}
return ETextFlowDirection::Auto;
}
#Loc: <Workspace>/Engine/Source/Runtime/Slate/Public/Framework/Text/TextLayout.h:74
Scope: file
Source code excerpt:
/**
* The different directions that text can flow within a paragraph of text.
* @note If you change this enum, make sure and update CVarDefaultTextFlowDirection and GetDefaultTextFlowDirection.
*/
UENUM( BlueprintType )
enum class ETextFlowDirection : uint8
{
/** Automatically detect the flow direction for each paragraph from its text */
Auto = 0,
/** Force text to be flowed left-to-right */
LeftToRight,