CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns
CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns
#Overview
name: CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable the mobile scale on the text when it gets created. It is off by default because it can result its scale being applied twice in tagged text.\n0: Disable (default), 1: Enable
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns is to control whether the mobile scale is applied to text runs in the CommonRichTextBlock component. This setting is primarily related to the text rendering system, specifically for mobile platforms.
This setting variable is used within the CommonUI plugin, which is part of the Unreal Engine’s UI system. It’s specifically utilized in the CommonRichTextBlock component, which is likely an enhanced version of the standard RichTextBlock for common UI implementations.
The value of this variable is set through the console variable system in Unreal Engine. It’s initialized to 0 (disabled) by default, but can be changed at runtime using console commands or through configuration files.
The associated variable bApplyMobileScaleOnTextRuns directly interacts with this console variable. They share the same value, with bApplyMobileScaleOnTextRuns being used in the actual code logic.
Developers must be aware that enabling this variable (setting it to 1) can potentially result in the scale being applied twice for tagged text. This is why it’s disabled by default. It’s important to test thoroughly on mobile devices when enabling this feature to ensure text appears as expected.
Best practices when using this variable include:
- Leave it disabled (0) unless you specifically need to apply mobile scaling to text runs.
- If enabled, thoroughly test on various mobile devices to ensure text rendering is correct.
- Be cautious when using tagged text in combination with this setting.
- Consider the performance implications of enabling this feature, especially on lower-end mobile devices.
Regarding the associated variable bApplyMobileScaleOnTextRuns:
The purpose of bApplyMobileScaleOnTextRuns is to act as an internal flag within the CommonUI module to determine whether mobile scaling should be applied to text runs.
This variable is used in the CommonUI plugin, specifically within the CommonRichTextBlock component’s text decorator creation process.
The value of this variable is set by the console variable CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns.
It interacts directly with the CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns console variable, essentially serving as its in-code representation.
Developers should be aware that this variable is checked in combination with CommonUIUtils::ShouldDisplayMobileUISizes() to determine whether to apply mobile scaling to text.
Best practices for this variable include:
- Do not modify this variable directly in code; instead, use the console variable to control its value.
- When implementing custom text decorators or modifying the CommonRichTextBlock, be aware of this flag’s existence and its impact on text scaling.
- Consider exposing this setting in your game’s options menu if you want to give users control over mobile text scaling.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonRichTextBlock.cpp:28
Scope (from outer to inner):
file
namespace UE::CommonUI::CommonRichTextBlock
Source code excerpt:
int32 bApplyMobileScaleOnTextRuns = 0;
FAutoConsoleVariableRef CVarApplyMobileScaleOnTextRuns(
TEXT("CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns"),
bApplyMobileScaleOnTextRuns,
TEXT("Enable the mobile scale on the text when it gets created. It is off by default because it can result its scale being applied twice in tagged text.\n0: Disable (default), 1: Enable"),
ECVF_Default);
}
namespace SupportedMarkupKeys
#Associated Variable and Callsites
This variable is associated with another variable named bApplyMobileScaleOnTextRuns
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonRichTextBlock.cpp:26
Scope (from outer to inner):
file
namespace UE::CommonUI::CommonRichTextBlock
Source code excerpt:
namespace UE::CommonUI::CommonRichTextBlock
{
int32 bApplyMobileScaleOnTextRuns = 0;
FAutoConsoleVariableRef CVarApplyMobileScaleOnTextRuns(
TEXT("CommonRichTextBlock.CVarApplyMobileScaleOnTextRuns"),
bApplyMobileScaleOnTextRuns,
TEXT("Enable the mobile scale on the text when it gets created. It is off by default because it can result its scale being applied twice in tagged text.\n0: Disable (default), 1: Enable"),
ECVF_Default);
}
namespace SupportedMarkupKeys
{
#Loc: <Workspace>/Engine/Plugins/Runtime/CommonUI/Source/CommonUI/Private/CommonRichTextBlock.cpp:125
Scope (from outer to inner):
file
class class FCommonRichTextDecorator : public ITextDecorator
function virtual TSharedRef<ISlateRun> Create
Source code excerpt:
}
if (CommonUIUtils::ShouldDisplayMobileUISizes() && UE::CommonUI::CommonRichTextBlock::bApplyMobileScaleOnTextRuns)
{
TextStyle.SetFontSize(TextStyle.Font.Size * Owner->GetMobileTextBlockScale());
}
TSharedPtr<ISlateRun> SlateRun;
TSharedPtr<SWidget> DecoratorWidget = CreateDecoratorWidget(RunInfo, TextStyle);