Slate.UnloadFreeTypeDataOnFlush

Slate.UnloadFreeTypeDataOnFlush

#Overview

name: Slate.UnloadFreeTypeDataOnFlush

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.UnloadFreeTypeDataOnFlush is to control whether the FreeType data is released when the font cache is flushed in the Slate UI system of Unreal Engine.

This setting variable is primarily used in the SlateCore module, specifically within the font caching system. It’s part of the Slate UI framework, which is responsible for rendering user interfaces in Unreal Engine.

The value of this variable is set through the Unreal Engine console variable system. It’s declared as an FAutoConsoleVariableRef, which means it can be modified at runtime through console commands or configuration files.

The associated variable UnloadFreeTypeDataOnFlush directly interacts with Slate.UnloadFreeTypeDataOnFlush. They share the same value and are used interchangeably in the code.

Developers should be aware that this variable affects memory management and performance. When set to 1 (default), it releases FreeType data when the font cache is flushed, which can free up memory but might impact performance if the data needs to be reloaded frequently.

Best practices for using this variable include:

  1. Leave it at the default value (1) unless there’s a specific need to keep FreeType data in memory.
  2. If frequent font cache flushes are occurring and causing performance issues, consider setting it to 0 to keep the FreeType data in memory.
  3. Monitor memory usage when modifying this value, especially on memory-constrained platforms.

Regarding the associated variable UnloadFreeTypeDataOnFlush:

The purpose of UnloadFreeTypeDataOnFlush is the same as Slate.UnloadFreeTypeDataOnFlush - it controls the release of FreeType data when the font cache is flushed.

This variable is used directly in the FSlateFontCache::FlushData function to determine whether to flush the FTCacheDirectory and CompositeFontCache. It’s checked along with the GIsEditor global variable, which suggests that this behavior might be different in the editor compared to a packaged game.

The value of UnloadFreeTypeDataOnFlush is set by the console variable system through Slate.UnloadFreeTypeDataOnFlush.

Developers should be aware that this variable directly affects the behavior of the font cache flushing process. When true (1), it causes more aggressive memory cleanup but potentially more frequent data reloading.

Best practices for UnloadFreeTypeDataOnFlush are the same as for Slate.UnloadFreeTypeDataOnFlush, as they are essentially the same variable. The choice of whether to unload FreeType data should be based on the specific needs of the project, balancing memory usage against potential performance impacts from data reloading.

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

Scope: file

Source code excerpt:

static int32 UnloadFreeTypeDataOnFlush = 1;
FAutoConsoleVariableRef CVarUnloadFreeTypeDataOnFlush(
	TEXT("Slate.UnloadFreeTypeDataOnFlush"),
	UnloadFreeTypeDataOnFlush,
	TEXT("Releases the free type data when the font cache is flushed"));

static TAutoConsoleVariable<int32> CVarDefaultTextShapingMethod(
	TEXT("Slate.DefaultTextShapingMethod"),
	static_cast<int32>(ETextShapingMethod::Auto),

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:44

Scope: file

Source code excerpt:

	TEXT("The number of frames within the large font glyph pool will resize rather than flush."));

static int32 UnloadFreeTypeDataOnFlush = 1;
FAutoConsoleVariableRef CVarUnloadFreeTypeDataOnFlush(
	TEXT("Slate.UnloadFreeTypeDataOnFlush"),
	UnloadFreeTypeDataOnFlush,
	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."),

#Loc: <Workspace>/Engine/Source/Runtime/SlateCore/Private/Fonts/FontCache.cpp:1820

Scope (from outer to inner):

file
function     void FSlateFontCache::FlushData

Source code excerpt:

	}

	if (GIsEditor || UnloadFreeTypeDataOnFlush)
	{
		FTCacheDirectory->FlushCache();
		CompositeFontCache->FlushCache();
	}

	FontToCharacterListCache.Empty();