Slate.EnableFontAntiAliasing

Slate.EnableFontAntiAliasing

#Overview

name: Slate.EnableFontAntiAliasing

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.EnableFontAntiAliasing is to control whether font anti-aliasing is enabled or disabled in the Slate UI system of Unreal Engine 5. This setting variable is specifically related to the font rendering subsystem within Slate.

Based on the details in the Callsites section, this setting variable is primarily used in the SlateCore module, specifically within the font rendering system. It’s referenced in the SlateFontRenderer.cpp file, which is part of the Slate font rendering implementation.

The value of this variable is set through a console variable (CVar) system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime using the console command system.

The Slate.EnableFontAntiAliasing CVar is directly associated with the EnableFontAntiAliasing static variable. They share the same value, and the CVar acts as an interface to modify the static variable.

Developers should be aware of several important aspects when using this variable:

  1. Changing this variable affects the visual quality of text rendering in the Slate UI system.
  2. The font cache must be flushed if this setting is changed during runtime to see the effects.
  3. It impacts performance, as anti-aliasing requires additional processing.

Best practices when using this variable include:

  1. Consider performance implications when enabling or disabling anti-aliasing, especially on lower-end devices.
  2. If changing the value at runtime, ensure to flush the font cache for the changes to take effect.
  3. Use it in conjunction with other font rendering settings for optimal visual quality and performance.

Regarding the associated variable EnableFontAntiAliasing:

The purpose of EnableFontAntiAliasing is to serve as the actual storage for the anti-aliasing setting within the code. It’s a static integer variable that directly controls whether font anti-aliasing is applied in the rendering process.

This variable is used in the SlateFontRendererUtils namespace to determine how fonts should be rendered. It affects the glyph flags used in font rendering and determines whether monochrome rendering is used.

The value of EnableFontAntiAliasing is set through the Slate.EnableFontAntiAliasing console variable, allowing for runtime configuration.

Developers should be aware that this variable directly impacts the font rendering process, affecting both visual quality and performance. It’s used in critical font rendering functions, so changes to its value can have immediate effects on the appearance of text in the UI.

Best practices for using EnableFontAntiAliasing include:

  1. Avoid directly modifying this variable; instead, use the Slate.EnableFontAntiAliasing console variable to ensure proper synchronization.
  2. Consider the performance impact when enabling or disabling anti-aliasing, especially for text-heavy UIs or on performance-constrained platforms.
  3. Test the visual quality and performance with both enabled and disabled states to find the optimal setting for your specific use case.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateFontRenderer.cpp:35

Scope: file

Source code excerpt:

static int32 EnableFontAntiAliasing = 1;
FAutoConsoleVariableRef CVarEnableFontAntiAliasing(
	TEXT("Slate.EnableFontAntiAliasing"),
	EnableFontAntiAliasing,
	TEXT("Enable or disable anti-aliasing for font rendering (0 = off, 1 = on). Enabled by default."));

namespace SlateFontRendererUtils
{

#Associated Variable and Callsites

This variable is associated with another variable named EnableFontAntiAliasing. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateFontRenderer.cpp:33

Scope: file

Source code excerpt:

 * Note: The font cache must be flushed if changing this in the middle of a running instance
 */ 
static int32 EnableFontAntiAliasing = 1;
FAutoConsoleVariableRef CVarEnableFontAntiAliasing(
	TEXT("Slate.EnableFontAntiAliasing"),
	EnableFontAntiAliasing,
	TEXT("Enable or disable anti-aliasing for font rendering (0 = off, 1 = on). Enabled by default."));

namespace SlateFontRendererUtils
{

#if WITH_FREETYPE

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateFontRenderer.cpp:55

Scope (from outer to inner):

file
namespace    SlateFontRendererUtils
function     void AppendGlyphFlags

Source code excerpt:

	}

	if (EnableFontAntiAliasing)
	{
		switch (InFontData.GetHinting())
		{
		case EFontHinting::Auto:		InOutGlyphFlags |= FT_LOAD_FORCE_AUTOHINT; break;
		case EFontHinting::AutoLight:	InOutGlyphFlags |= FT_LOAD_TARGET_LIGHT; break;
		case EFontHinting::Monochrome:	InOutGlyphFlags |= FT_LOAD_TARGET_MONO | FT_LOAD_FORCE_AUTOHINT; break;

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/SlateFontRenderer.cpp:532

Scope (from outer to inner):

file
function     bool FSlateFontRenderer::GetRenderDataInternal

Source code excerpt:

	SCOPE_CYCLE_COUNTER(STAT_FreetypeRenderGlyph);

	bool bIsMonochromeRendered = !EnableFontAntiAliasing;

	FT_Face Face = InFaceGlyphData.FaceAndMemory->GetFace();

	// Get the lot for the glyph.  This contains measurement info
	FT_GlyphSlot Slot = Face->glyph;