Language:
Discover
By Skill Level
By Category

UFont

Choose your OS:

Inheritance Hierarchy

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

NOTE: Do not expose this to the editor as it has nasty crash potential.

Constructors

Name Description

Public function

UFont

(
    const FObjectInitializer & ObjectIn...
)

Functions

Name Description

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API) v...

 

CacheCharacterCountAndMaxCharHeight()

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API)in ...

 

GetCharHorizontalOffset

(
    TCHAR InCh
)

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API)in ...

 

GetCharKerning

(
    TCHAR First,
    TCHAR Second
)

Gets the kerning value for a pair of characters

The kerning value

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API) v...

 

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

float The scaling factor currently set

Public function

FSlateFontIn ...

 

GetLegacySlateFontInfo()

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API) f...

 

GetMaxCharHeight()

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API) v...

 

GetStringHeightAndWidth

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

Determines the height and width for the passed in string.

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API) v...

 

GetStringHeightAndWidth

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API)in ...

 

GetStringHeightSize

(
    const TCHAR * Text
)

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API)in ...

 

GetStringSize

(
    const TCHAR * Text
)

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

Public function

[ENGINE_API](API\Runtime\Engine\AI\Navigation\ENGINE_API)TC ...

 

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, and immediately after any undo/redo.

Public function Virtual

void

 

Serialize

(
    FArchive & Ar
)

UObject serializer.

Overridden from IFontProviderInterface

Name Description

Public function Virtual

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

References

Module

Engine

Header

Runtime/Engine/Classes/Engine/Font.h