UFont

A font object, for use by Slate, UMG, and Canvas.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Engine

Header

/Engine/Source/Runtime/Engine/Classes/Engine/Font.h

Include

#include "Engine/Font.h"

Syntax

class UFont :
    public UObject,
    public IFontProviderInterface

Remarks

A font object, for use by Slate, UMG, and Canvas.

A font can either be: Runtime cached - The font contains a series of TTF files that combine to form a composite font. The glyphs are cached on demand when required at runtime. Offline cached - The font contains a series of textures containing pre-baked cached glyphs and their associated texture coordinates.

Variables

Name Description

Public variable

float

 

Ascent

Public variable

TArray< struct ...

 

Characters

List of characters in the font.

Public variable

TMap< uint16, u...

 

CharRemap

When IsRemapped is true, this array maps unicode values to entries in the Characters array

Public variable

FCompositeFont

 

CompositeFont

Embedded composite font data

Public variable

float

 

Descent

Public variable

float

 

EmScale

Font metrics.

Public variable

EFontCacheType

 

FontCacheType

What kind of font caching should we use? This controls which options we see

Public variable

FFontImportOpti...

 

ImportOptions

Options used when importing this font

Public variable

int32

 

IsRemapped

True if font is 'remapped'.

Public variable

int32

 

Kerning

Default horizontal spacing between characters when rendering text with this font

Public variable

float

 

Leading

Public variable

FName

 

LegacyFontName

The default font name to use for legacy Canvas APIs that don't specify a font name

Public variable

int32

 

LegacyFontSize

The default size of the font used for legacy Canvas APIs that don't specify a font size

Public variable

TArray< int32 >

 

MaxCharHeight

The maximum height of a character in this font.

Public variable

int32

 

NumCharacters

Number of characters in the font, not including multiple instances of the same character (for multi-fonts).

Public variable

float

 

ScalingFactor

Scale to apply to the font.

Public variable

TArray< class U...

 

Textures

Textures that store this font's glyph image data

Constructors

Name Description

Public function

UFont

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function

void

 

CacheCharacterCountAndMaxCharHeight()

Caches the character count and maximum character height for this font (as well as sub-fonts, in the multi-font case)

Public function Const

int16

 

GetCharHorizontalOffset

(
    TCHAR InCh
)

Gets the horizontal distance from the origin to the left most border of the given character

Public function Const

int8

 

GetCharKerning

(
    TCHAR First,
    TCHAR Second
)

Gets the kerning value for a pair of characters

Public function Const

void

 

GetCharSize

(
    TCHAR InCh,
    float& Width,
    float& Height
)

Calculate the width and height of a single character using this font's default size and scale.

Public function

float

 

GetFontScalingFactor()

Get the scaling factor

Public function Const

FSlateFontIn...

 

GetLegacySlateFontInfo()

Get the info needed to use this UFont with Slate, using the fallback data for legacy Canvas APIs

Public function Const

float

 

GetMaxCharHeight()

Returns the maximum height for any character in this font using this font's default size and scale.

Public function Const

void

 

GetStringHeightAndWidth

(
    const FString& InString,
    int32& Height,
    int32& Width
)

Determines the height and width for the passed in string.

Public function Const

void

 

GetStringHeightAndWidth

(
    const TCHAR* Text,
    int32& Height,
    int32& Width
)

Determines the height and width for the passed in string.

Public function Const

int32

 

GetStringHeightSize

(
    const TCHAR* Text
)

Calculate the height of the string using this font's default size and scale.

Public function Const

int32

 

GetStringSize

(
    const TCHAR* Text
)

Calculate the width of the string using this font's default size and scale.

Public function Const

TCHAR

 

RemapChar

(
    TCHAR CharCode
)

Public function

void

 

SetFontScalingFactor

(
    float InScalingFactor
)

Set the scaling factor

Overridden from UObject

Name Description

Public function Virtual

void

 

BeginDestroy()

Called before destroying the object.

Public function Virtual

void

 

GetResourceSizeEx

(
    FResourceSizeEx& CumulativeResourc...
)

Returns the size of the object/ resource for display to artists/ LDs in the Editor.

Public function Virtual

void

 

PostLoad()

Do any object-specific cleanup required immediately after loading an object.

Public function Virtual

void

 

Serialize

(
    FArchive& Ar
)

Handles reading, writing, and reference collecting using FArchive.

Overridden from IFontProviderInterface

Name Description

Public function Virtual Const

const FCompo...

 

GetCompositeFont()

IFontProviderInterface

Constants

Name

Description

NULLCHARACTER

This is the character that RemapChar will return if the specified character doesn't exist in the font

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss