Navigation
API > API/Runtime > API/Runtime/Engine
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.
| Name | UFont |
| Type | class |
| Header File | /Engine/Source/Runtime/Engine/Classes/Engine/Font.h |
| Include Path | #include "Engine/Font.h" |
Syntax
UCLASS (HideCategories=Object, AutoExpandCategories=Font, MinimalAPI, BlueprintType)
class UFont :
public UObject ,
public IFontProviderInterface
Inheritance Hierarchy
- UObjectBase → UObjectBaseUtility → UObject → UFont
Implements Interfaces
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
UFont
(
const FObjectInitializer& ObjectInitializer |
Engine/Font.h |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| NULLCHARACTER | const TCHAR | This is the character that RemapChar will return if the specified character doesn't exist in the font | Engine/Font.h |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Ascent | float | Engine/Font.h |
|
|
| Characters | TArray< struct FFontCharacter > | List of characters in the font. | Engine/Font.h |
|
| CharRemap | TMap< uint16, uint16 > | When IsRemapped is true, this array maps unicode values to entries in the Characters array | Engine/Font.h | |
| CompositeFont | FCompositeFont | Embedded composite font data | Engine/Font.h |
|
| Descent | float | Engine/Font.h |
|
|
| EmScale | float | Font metrics. | Engine/Font.h |
|
| FontCacheType | EFontCacheType | What kind of font caching should we use? This controls which options we see | Engine/Font.h |
|
| ImportOptions | FFontImportOptionsData | Options used when importing this font | Engine/Font.h |
|
| IsRemapped | int32 | True if font is 'remapped'. | Engine/Font.h | |
| Kerning | int32 | Default horizontal spacing between characters when rendering text with this font | Engine/Font.h |
|
| Leading | float | Engine/Font.h |
|
|
| LegacyFontName | FName | The default font name to use for legacy Canvas APIs that don't specify a font name | Engine/Font.h |
|
| LegacyFontSize | int32 | The default size of the font used for legacy Canvas APIs that don't specify a font size | Engine/Font.h |
|
| MaxCharHeight | TArray< int32 > | The maximum height of a character in this font. | Engine/Font.h |
|
| NumCharacters | int32 | Number of characters in the font, not including multiple instances of the same character (for multi-fonts). | Engine/Font.h |
|
| RuntimeFontSource | ERuntimeFontSource | Where is the runtime font data for this Font stored? | Engine/Font.h |
|
| ScalingFactor | float | Scale to apply to the font. | Engine/Font.h |
|
| Textures | TArray< TObjectPtr< class UTexture2D > > | NOTE: Do not expose this to the editor as it has nasty crash potential. | Engine/Font.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void CacheCharacterCountAndMaxCharHeight() |
Caches the character count and maximum character height for this font (as well as sub-fonts, in the multi-font case) | Engine/Font.h | |
int16 GetCharHorizontalOffset
(
TCHAR InCh |
Gets the horizontal distance from the origin to the left most border of the given character | Engine/Font.h | |
int8 GetCharKerning
(
TCHAR First, |
Gets the kerning value for a pair of characters | Engine/Font.h | |
void GetCharSize
(
TCHAR InCh, |
Calculate the width and height of a single character using this font's default size and scale. | Engine/Font.h | |
virtual const FCompositeFont * GetCompositeFont() |
IFontProviderInterface | Engine/Font.h | |
float GetFontScalingFactor() |
Get the scaling factor | Engine/Font.h | |
const FCompositeFont & GetInternalCompositeFont() |
Engine/Font.h | ||
FSlateFontInfo GetLegacySlateFontInfo() |
Get the info needed to use this UFont with Slate, using the fallback data for legacy Canvas APIs | Engine/Font.h | |
float GetMaxCharHeight() |
Returns the maximum height for any character in this font using this font's default size and scale. | Engine/Font.h | |
FCompositeFont & GetMutableInternalCompositeFont() |
Engine/Font.h | ||
void GetStringHeightAndWidth
(
const FString& InString, |
Determines the height and width for the passed in string. | Engine/Font.h | |
void GetStringHeightAndWidth
(
const TCHAR* Text, |
Engine/Font.h | ||
int32 GetStringHeightSize
(
const TCHAR* Text |
Calculate the height of the string using this font's default size and scale. | Engine/Font.h | |
int32 GetStringSize
(
const TCHAR* Text |
Calculate the width of the string using this font's default size and scale. | Engine/Font.h | |
TCHAR RemapChar
(
TCHAR CharCode |
Engine/Font.h | ||
void SetFontScalingFactor
(
float InScalingFactor |
Set the scaling factor | Engine/Font.h |
Overridden from UObject
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual void BeginDestroy() |
Engine/Font.h | ||
virtual void GetResourceSizeEx
(
FResourceSizeEx& CumulativeResourceSize |
Returns the size of the object/ resource for display to artists/ LDs in the Editor. | Engine/Font.h | |
virtual void PostLoad() |
Engine/Font.h | ||
virtual void Serialize
(
FArchive& Ar |
Engine/Font.h |
Static
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
static FName GetInternalCompositeFontPropertyName() |
Engine/Font.h |