UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Font.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
7#include "UObject/Object.h"
8#include "UObject/Class.h"
10#include "Fonts/SlateFontInfo.h"
13#include "Font.generated.h"
14
16UENUM()
18{
20 Offline,
21
23 Runtime,
24};
25
26UENUM()
35
37USTRUCT()
39{
41
42 UPROPERTY(EditAnywhere, Category=FontCharacter)
43 int32 StartU;
44
45 UPROPERTY(EditAnywhere, Category=FontCharacter)
46 int32 StartV;
47
48 UPROPERTY(EditAnywhere, Category=FontCharacter)
49 int32 USize;
50
51 UPROPERTY(EditAnywhere, Category=FontCharacter)
52 int32 VSize;
53
54 UPROPERTY(EditAnywhere, Category=FontCharacter)
55 uint8 TextureIndex;
56
57 UPROPERTY(EditAnywhere, Category=FontCharacter)
58 int32 VerticalOffset;
59
60
62 : StartU(0)
63 , StartV(0)
64 , USize(0)
65 , VSize(0)
66 , TextureIndex(0)
67 , VerticalOffset(0)
68 { }
69
75 bool Serialize( FArchive& Ar )
76 {
77 Ar << *this;
78 return true;
79 }
80
81 // Serializer.
83 {
84 Ar << Ch.StartU << Ch.StartV << Ch.USize << Ch.VSize << Ch.TextureIndex;
85 Ar << Ch.VerticalOffset;
86 return Ar;
87 }
88};
89
90
91template<>
100
101
109UCLASS(hidecategories=Object, autoexpandcategories=Font, MinimalAPI, BlueprintType)
111{
113
114
115 UPROPERTY(EditAnywhere, Category=Font)
116 EFontCacheType FontCacheType;
117
119 UPROPERTY(EditAnywhere, AdvancedDisplay, Category=RuntimeFont)
121
124 UPROPERTY(EditAnywhere, Category=OfflineFont)
126
128 //NOTE: Do not expose this to the editor as it has nasty crash potential
129 UPROPERTY()
131
134 UPROPERTY()
135 int32 IsRemapped;
136
138 UPROPERTY(EditAnywhere, Category=OfflineFont)
139 float EmScale;
140
142 UPROPERTY(EditAnywhere, Category=OfflineFont)
143 float Ascent;
144
146 UPROPERTY(EditAnywhere, Category=OfflineFont)
147 float Descent;
148
150 UPROPERTY(EditAnywhere, Category=OfflineFont)
151 float Leading;
152
154 UPROPERTY(EditAnywhere, Category=OfflineFont)
155 int32 Kerning;
156
158 UPROPERTY(EditAnywhere, Category=OfflineFont)
159 struct FFontImportOptionsData ImportOptions;
160
164 int32 NumCharacters;
165
170 TArray<int32> MaxCharHeight;
171
173 UPROPERTY(EditAnywhere, Category=OfflineFont)
174 float ScalingFactor;
175
177 UPROPERTY(EditAnywhere, Category=RuntimeFont, meta = (ClampMin = 1, ClampMax = 1000))
178 int32 LegacyFontSize;
179
181 UPROPERTY(EditAnywhere, Category=RuntimeFont)
182 FName LegacyFontName;
183
185 UE_DEPRECATED(5.7, "Public access to CompositeFont is deprecated. Use GetCompositeFont(), GetInternalCompositeFont(), or GetMutableInternalCompositeFont() instead.")
186 UPROPERTY(EditAnywhere, Category = RuntimeFont)
187 FCompositeFont CompositeFont;
188
189public:
190
192 static const TCHAR NULLCHARACTER = 127;
193
196
198 ENGINE_API virtual const FCompositeFont* GetCompositeFont() const override;
199
206
213
220
222 ENGINE_API FSlateFontInfo GetLegacySlateFontInfo() const;
223
229 virtual void GetResourceSizeEx(FResourceSizeEx& CumulativeResourceSize) override;
230
231 //~ Begin UFont Interface
232 ENGINE_API TCHAR RemapChar(TCHAR CharCode) const;
233
241 ENGINE_API void GetCharSize(TCHAR InCh, float& Width, float& Height) const;
242
251 ENGINE_API int8 GetCharKerning(TCHAR First, TCHAR Second) const;
252
260 ENGINE_API int16 GetCharHorizontalOffset(TCHAR InCh) const;
261
269 ENGINE_API int32 GetStringSize( const TCHAR *Text ) const;
270
278 ENGINE_API int32 GetStringHeightSize( const TCHAR *Text ) const;
279
280 //~ Begin UObject Interface
281 virtual void Serialize( FArchive& Ar ) override;
282 virtual void PostLoad() override;
283 virtual void BeginDestroy() override;
284 //~ End UObject interface
285
289 ENGINE_API void CacheCharacterCountAndMaxCharHeight();
290
297 {
298 ScalingFactor = InScalingFactor;
299 }
300
306 inline float GetFontScalingFactor() const
307 {
308 return ScalingFactor;
309 }
310
312 ENGINE_API float GetMaxCharHeight() const;
313
315 ENGINE_API void GetStringHeightAndWidth( const FString& InString, int32& Height, int32& Width ) const;
316 ENGINE_API void GetStringHeightAndWidth( const TCHAR *Text, int32& Height, int32& Width ) const;
317};
#define GET_MEMBER_NAME_CHECKED(ClassName, MemberName)
Definition AssertionMacros.h:493
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int16 int16
A 16-bit signed integer.
Definition Platform.h:1123
FPlatformTypes::int8 int8
An 8-bit signed integer.
Definition Platform.h:1121
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
ERuntimeFontSource
Definition Font.h:28
EFontCacheType
Definition Font.h:18
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
EPropertyObjectReferenceType
Definition ObjectMacros.h:533
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Archive.h:1208
Definition NameTypes.h:617
Definition FontProviderInterface.h:24
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition Font.h:111
static FName GetInternalCompositeFontPropertyName()
Definition Font.h:214
void SetFontScalingFactor(float InScalingFactor)
Definition Font.h:296
TMap< uint16, uint16 > CharRemap
Definition Font.h:195
float GetFontScalingFactor() const
Definition Font.h:306
const FCompositeFont & GetInternalCompositeFont() const
Definition Font.h:200
FCompositeFont & GetMutableInternalCompositeFont()
Definition Font.h:207
Definition Object.h:95
Definition CompositeFont.h:428
Definition Font.h:39
friend FArchive & operator<<(FArchive &Ar, FFontCharacter &Ch)
Definition Font.h:82
bool Serialize(FArchive &Ar)
Definition Font.h:75
Definition FontImportOptions.h:25
float Height
Definition FontImportOptions.h:34
Definition ResourceSize.h:31
Definition SlateFontInfo.h:147
Definition StructOpsTypeTraits.h:11
@ WithSerializer
Definition StructOpsTypeTraits.h:23
static constexpr EPropertyObjectReferenceType WithSerializerObjectReferences
Definition StructOpsTypeTraits.h:41
Definition StructOpsTypeTraits.h:46