Slate.OutlineFontRenderMethod

Slate.OutlineFontRenderMethod

#Overview

name: Slate.OutlineFontRenderMethod

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

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of Slate.OutlineFontRenderMethod is to control the rendering method for outline fonts in Unreal Engine’s Slate UI system. It is primarily used for the font rendering subsystem within the SlateCore module.

This setting variable is relied upon by the SlateCore module, specifically within the font rendering system. It’s used in the SlateFontRenderer class, which is responsible for rendering text in the Slate UI framework.

The value of this variable is set through a console variable (CVar) system. It’s initialized to 0 by default, but can be changed at runtime through console commands or configuration files.

The associated variable OutlineFontRenderMethod directly interacts with Slate.OutlineFontRenderMethod. They share the same value, with OutlineFontRenderMethod being the actual integer variable used in the code, while Slate.OutlineFontRenderMethod is the console variable name used for external access and configuration.

Developers must be aware that changing this variable affects how outline fonts are rendered. There are two modes: 0 (default): FreeType handles everything and generates a bitmap for the base glyph. 1: The Unreal Engine overrides the FreeType rasterizer, which can help with rendering anomalies on complicated fonts.

Best practices when using this variable include:

  1. Only change it if you’re experiencing issues with font rendering, particularly with complex fonts or outline effects.
  2. Be aware that changing this value may require flushing the font cache for changes to take effect.
  3. Test thoroughly after changing this value, as it can affect the appearance of all outline fonts in your UI.

Regarding the associated variable OutlineFontRenderMethod: This is the actual integer variable used in the code to determine the outline font render method. It’s directly linked to the Slate.OutlineFontRenderMethod console variable.

The OutlineFontRenderMethod variable is used in the GetRenderDataInternal function of the FSlateFontRenderer class to determine how to render outline fonts. When set to 1, it triggers a custom rasterization process that overrides the default FreeType behavior.

Developers should be aware that this variable is checked during the font rendering process, so changing it at runtime will affect subsequent text rendering operations. However, existing rendered text may not update until the font cache is flushed or the text is re-rendered.

When working with OutlineFontRenderMethod, developers should:

  1. Consider it in conjunction with the ScaledOutlineSize when dealing with outline fonts.
  2. Be prepared to implement custom rasterization logic if setting it to 1, as this overrides the default FreeType behavior.
  3. Profile and test thoroughly when changing this value, as it can have performance and visual implications for text rendering across the entire application.

#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:25

Scope: file

Source code excerpt:

static int32 OutlineFontRenderMethod = 0;
FAutoConsoleVariableRef CVarOutlineFontRenderMethod(
	TEXT("Slate.OutlineFontRenderMethod"),
	OutlineFontRenderMethod,
	TEXT("Changes the render method for outline fonts.  0 = freetype does everything and generates a bitmap for the base glyph (default).  1 = We override the freetype rasterizer.  Can help with some rendering anomalies on complicated fonts."));

/**
 * Enable or disable anti-aliasing for font rendering.
 * Note: The font cache must be flushed if changing this in the middle of a running instance

#Associated Variable and Callsites

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

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

Scope: file

Source code excerpt:

 * Note: The font cache must be flushed if changing this in the middle of a running instance
 */ 
static int32 OutlineFontRenderMethod = 0;
FAutoConsoleVariableRef CVarOutlineFontRenderMethod(
	TEXT("Slate.OutlineFontRenderMethod"),
	OutlineFontRenderMethod,
	TEXT("Changes the render method for outline fonts.  0 = freetype does everything and generates a bitmap for the base glyph (default).  1 = We override the freetype rasterizer.  Can help with some rendering anomalies on complicated fonts."));

/**
 * Enable or disable anti-aliasing for font rendering.
 * Note: The font cache must be flushed if changing this in the middle of a running instance
 */ 

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

Scope (from outer to inner):

file
function     bool FSlateFontRenderer::GetRenderDataInternal

Source code excerpt:

	int32 OutlineYOffset = 0;

	if((ScaledOutlineSize > 0.0f || OutlineFontRenderMethod == 1) && Slot->format == FT_GLYPH_FORMAT_OUTLINE)
	{
		// Render the filled area first
		FRasterizerSpanList FillSpans;
		RenderOutlineRows(FTLibrary->GetLibrary(), &Slot->outline, FillSpans);

		FRasterizerSpanList OutlineSpans;