UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
SlateFontInfo.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/Class.h"
10#include "SlateFontInfo.generated.h"
11
13{
15 inline const uint32 RenderDPI = 96;
16}
17
31
35USTRUCT(BlueprintType)
37{
39
40
41 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=OutlineSettings, meta=(ClampMin="0", ClampMax="1024"))
42 int32 OutlineSize;
43
45 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OutlineSettings, meta = (DisplayName="Mitered Corners"))
46 bool bMiteredCorners;
47
52 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OutlineSettings)
53 bool bSeparateFillAlpha;
54
58 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = OutlineSettings)
59 bool bApplyOutlineToDropShadows;
60
62 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(AllowedClasses="/Script/Engine.MaterialInterface"))
63 TObjectPtr<UObject> OutlineMaterial;
64
66 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=OutlineSettings)
67 FLinearColor OutlineColor;
68
70 : OutlineSize(0)
71 , bMiteredCorners(false)
72 , bSeparateFillAlpha(false)
73 , bApplyOutlineToDropShadows(false)
74 , OutlineMaterial(nullptr)
75 , OutlineColor(FLinearColor::Black)
76 {}
77
79 : OutlineSize(InOutlineSize)
80 , bMiteredCorners(false)
81 , bSeparateFillAlpha(false)
82 , bApplyOutlineToDropShadows(false)
83 , OutlineMaterial(nullptr)
84 , OutlineColor(InColor)
85 {}
86
88 {
89 // Ignore OutlineMaterial && OutlineColor because they do not affect the cached glyph.
90 return OutlineSize == Other.OutlineSize
91 && bMiteredCorners == Other.bMiteredCorners
92 && bSeparateFillAlpha == Other.bSeparateFillAlpha;
93 }
94
95 inline bool IsIdenticalTo(const FFontOutlineSettings& Other) const
96 {
97 return
98 OutlineSize == Other.OutlineSize &&
99 bMiteredCorners == Other.bMiteredCorners &&
100 bSeparateFillAlpha == Other.bSeparateFillAlpha &&
101 bApplyOutlineToDropShadows == Other.bApplyOutlineToDropShadows &&
102 OutlineMaterial == Other.OutlineMaterial &&
103 OutlineColor == Other.OutlineColor;
104 }
105
106 friend inline uint32 GetTypeHash(const FFontOutlineSettings& OutlineSettings)
107 {
108 uint32 Hash = 0;
109 // Ignore OutlineMaterial && OutlineColor because they do not affect the cached glyph.
110 Hash = HashCombine(Hash, GetTypeHash(OutlineSettings.OutlineSize));
111 Hash = HashCombine(Hash, GetTypeHash(OutlineSettings.bMiteredCorners));
112 Hash = HashCombine(Hash, GetTypeHash(OutlineSettings.bSeparateFillAlpha));
113 return Hash;
114 }
115
116 bool IsVisible() const
117 {
118 return OutlineSize > 0 && OutlineColor.A > 0;
119 }
120
121#if WITH_EDITORONLY_DATA
122 bool Serialize(FArchive& Ar);
123 void PostSerialize(const FArchive& Ar);
124#endif
125
127};
128
129#if WITH_EDITORONLY_DATA
130template<>
132 : public TStructOpsTypeTraitsBase2<FFontOutlineSettings>
133{
134 enum
135 {
136 WithSerializer = true,
137 WithPostSerialize = true,
138 };
139};
140#endif
141
145USTRUCT(BlueprintType, meta = (HasNativeMake = "/Script/SlateRHIRenderer.SlateFontBlueprintLibrary.MakeSlateFontInfo"))
147{
149
150
151 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(AllowedClasses="/Script/Engine.Font", DisplayName="Font Family"))
152 TObjectPtr<const UObject> FontObject;
153
155 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(AllowedClasses="/Script/Engine.MaterialInterface"))
156 TObjectPtr<UObject> FontMaterial;
157
159 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules)
160 FFontOutlineSettings OutlineSettings;
161
163 TSharedPtr<const FCompositeFont> CompositeFont;
164
166 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(DisplayName="Typeface", EditCondition="FontObject"))
167 FName TypefaceFontName;
168
174 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(ClampMin=1, ClampMax=1000))
175 float Size;
176
178 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(ClampMin=-1000, ClampMax=10000))
179 int32 LetterSpacing = 0;
180
182 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(ClampMin=-5, ClampMax=5))
183 float SkewAmount = 0.0f;
184
186 EFontFallback FontFallback;
187
189 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(DisplayName="Monospacing"))
190 bool bForceMonospaced = false;
191
193 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules)
194 bool bMaterialIsStencil = false;
195
197 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category=SlateStyleRules, meta=(ClampMin=0, EditCondition = "bForceMonospaced==true", EditConditionHides))
198 float MonospacedWidth = 1.0f;
199
200#if WITH_EDITORONLY_DATA
201private:
202
204 UPROPERTY()
206
208 UPROPERTY()
210#endif
211
212public:
213
216
219
228
237
245 UE_DEPRECATED(5.6, "Use constructor with FCompositeFont instead.")
247
255 UE_DEPRECATED(5.6, "Use constructor with FCompositeFont instead.")
257
265 UE_DEPRECATED(5.6, "Use constructor with FCompositeFont instead.")
267
275 UE_DEPRECATED(5.6, "Use constructor with FCompositeFont instead.")
277
278public:
283 inline bool IsLegacyIdenticalTo(const FSlateFontInfo& Other) const
284 {
285 return FontObject == Other.FontObject
286 && OutlineSettings.IsIdenticalToForCaching(Other.OutlineSettings)
287 && CompositeFont == Other.CompositeFont
288 && TypefaceFontName == Other.TypefaceFontName
289 && GetClampSize() == Other.GetClampSize();
290 }
291
292 inline bool IsIdenticalTo(const FSlateFontInfo& Other) const
293 {
294 return FontObject == Other.FontObject
295 && FontMaterial == Other.FontMaterial
296 && OutlineSettings.IsIdenticalTo(Other.OutlineSettings)
297 && CompositeFont == Other.CompositeFont
298 && TypefaceFontName == Other.TypefaceFontName
299 && Size == Other.Size
300 && LetterSpacing == Other.LetterSpacing
301 && SkewAmount == Other.SkewAmount
302 && bForceMonospaced == Other.bForceMonospaced
303 && (bForceMonospaced ? MonospacedWidth == Other.MonospacedWidth : true);
304 }
305
306 inline bool operator==(const FSlateFontInfo& Other) const
307 {
308 return IsIdenticalTo(Other);
309 }
310
314 SLATECORE_API bool HasValidFont() const;
315
320 SLATECORE_API const FCompositeFont* GetCompositeFont() const;
321
323 SLATECORE_API float GetClampSize() const;
324
326 SLATECORE_API float GetClampSkew() const;
327
332 friend inline uint32 GetLegacyTypeHash(const FSlateFontInfo& FontInfo)
333 {
334 uint32 Hash = 0;
335 Hash = HashCombine(Hash, GetTypeHash(FontInfo.FontObject));
336 Hash = HashCombine(Hash, GetTypeHash(FontInfo.CompositeFont));
337 Hash = HashCombine(Hash, GetTypeHash(FontInfo.TypefaceFontName));
338 Hash = HashCombine(Hash, GetTypeHash(FontInfo.GetClampSize()));
339 return Hash;
340 }
341
350 friend inline uint32 GetTypeHash( const FSlateFontInfo& FontInfo )
351 {
352 uint32 Hash = 0;
353 Hash = HashCombine(Hash, GetTypeHash(FontInfo.FontObject));
354 Hash = HashCombine(Hash, GetTypeHash(FontInfo.CompositeFont));
355 Hash = HashCombine(Hash, GetTypeHash(FontInfo.FontMaterial));
356 Hash = HashCombine(Hash, GetTypeHash(FontInfo.TypefaceFontName));
357 Hash = HashCombine(Hash, GetTypeHash(FontInfo.GetClampSize()));
358 Hash = HashCombine(Hash, GetTypeHash(FontInfo.LetterSpacing));
359 Hash = HashCombine(Hash, GetTypeHash(FontInfo.GetClampSkew()));
360 Hash = HashCombine(Hash, GetTypeHash(FontInfo.OutlineSettings));
361 return Hash;
362 }
363
364#if WITH_EDITORONLY_DATA
368 SLATECORE_API void PostSerialize(const FArchive& Ar);
369#endif
370
371 SLATECORE_API void AddReferencedObjects(FReferenceCollector& Collector);
372
373private:
374
378 void UpgradeLegacyFontInfo(FName LegacyFontName, EFontHinting LegacyHinting);
379};
380
381#if WITH_EDITORONLY_DATA
382template<>
384 : public TStructOpsTypeTraitsBase2<FSlateFontInfo>
385{
386 enum
387 {
388 WithPostSerialize = true,
389 };
390};
391#endif
EFontHinting
Definition CompositeFont.h:25
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::WIDECHAR WIDECHAR
A wide character. Normally a signed type.
Definition Platform.h:1133
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::ANSICHAR ANSICHAR
An ANSI character. Normally a signed type.
Definition Platform.h:1131
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
EFontFallback
Definition SlateFontInfo.h:23
constexpr uint32 HashCombine(uint32 A, uint32 C)
Definition TypeHash.h:36
uint32 Size
Definition VulkanMemory.cpp:4034
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Engine.Build.cs:7
Definition Archive.h:1208
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition UObjectGlobals.h:2492
Definition SharedPointer.h:692
Definition Object.h:95
Definition SlateFontInfo.h:13
const uint32 RenderDPI
Definition SlateFontInfo.h:15
@ false
Definition radaudio_common.h:23
Definition CompositeFont.h:428
Definition SlateFontInfo.h:37
bool bMiteredCorners
Definition SlateFontInfo.h:46
bool IsIdenticalToForCaching(const FFontOutlineSettings &Other) const
Definition SlateFontInfo.h:87
bool IsVisible() const
Definition SlateFontInfo.h:116
static SLATECORE_API FFontOutlineSettings NoOutline
Definition SlateFontInfo.h:126
friend uint32 GetTypeHash(const FFontOutlineSettings &OutlineSettings)
Definition SlateFontInfo.h:106
bool bSeparateFillAlpha
Definition SlateFontInfo.h:53
FFontOutlineSettings(int32 InOutlineSize, FLinearColor InColor=FLinearColor::Black)
Definition SlateFontInfo.h:78
bool IsIdenticalTo(const FFontOutlineSettings &Other) const
Definition SlateFontInfo.h:95
int32 OutlineSize
Definition SlateFontInfo.h:42
Definition Color.h:48
static CORE_API const FLinearColor Black
Definition Color.h:458
Definition SlateFontInfo.h:147
~FSlateFontInfo()
Definition SlateFontInfo.h:218
int32 LetterSpacing
Definition SlateFontInfo.h:179
SLATECORE_API float GetClampSkew() const
Definition SlateFontInfo.cpp:242
SLATECORE_API float GetClampSize() const
Definition SlateFontInfo.cpp:237
TObjectPtr< const UObject > FontObject
Definition SlateFontInfo.h:152
TObjectPtr< UObject > FontMaterial
Definition SlateFontInfo.h:156
FFontOutlineSettings OutlineSettings
Definition SlateFontInfo.h:160
bool IsIdenticalTo(const FSlateFontInfo &Other) const
Definition SlateFontInfo.h:292
FName TypefaceFontName
Definition SlateFontInfo.h:167
friend uint32 GetLegacyTypeHash(const FSlateFontInfo &FontInfo)
Definition SlateFontInfo.h:332
TSharedPtr< const FCompositeFont > CompositeFont
Definition SlateFontInfo.h:163
bool operator==(const FSlateFontInfo &Other) const
Definition SlateFontInfo.h:306
friend uint32 GetTypeHash(const FSlateFontInfo &FontInfo)
Definition SlateFontInfo.h:350
Definition ObjectPtr.h:488
Definition StructOpsTypeTraits.h:11
@ WithSerializer
Definition StructOpsTypeTraits.h:23
@ WithPostSerialize
Definition StructOpsTypeTraits.h:25
Definition StructOpsTypeTraits.h:46