From dc7170c51e0e8d6d0d6d505197052b47033a2798 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Fri, 10 Nov 2023 21:32:18 +0200 Subject: [PATCH] Expose Freetype font style flags in `FontAsset` --- Source/Engine/Render2D/FontAsset.cpp | 10 ++++++++++ Source/Engine/Render2D/FontAsset.h | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/Source/Engine/Render2D/FontAsset.cpp b/Source/Engine/Render2D/FontAsset.cpp index f000eb3c6..a477e5f4d 100644 --- a/Source/Engine/Render2D/FontAsset.cpp +++ b/Source/Engine/Render2D/FontAsset.cpp @@ -87,6 +87,16 @@ bool FontAsset::Init() return error; } +FontFlags FontAsset::GetStyle() const +{ + FontFlags flags = FontFlags::None; + if ((_face->style_flags & FT_STYLE_FLAG_ITALIC) != 0) + flags |= FontFlags::Italic; + if ((_face->style_flags & FT_STYLE_FLAG_BOLD) != 0) + flags |= FontFlags::Bold; + return flags; +} + void FontAsset::SetOptions(const FontOptions& value) { _options = value; diff --git a/Source/Engine/Render2D/FontAsset.h b/Source/Engine/Render2D/FontAsset.h index 17839d49b..4dea84a5b 100644 --- a/Source/Engine/Render2D/FontAsset.h +++ b/Source/Engine/Render2D/FontAsset.h @@ -128,6 +128,11 @@ public: return _options; } + /// + /// Gets the font style flags. + /// + API_PROPERTY() FontFlags GetStyle() const; + /// /// Sets the font options. ///