From 84ce9238507f21d8f595e1c58b2a221636aee43c Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Thu, 23 Sep 2021 19:43:55 -0400 Subject: [PATCH] LibGfx: Make BitmapFont::variant() report a complete typeface --- Userland/Libraries/LibGfx/BitmapFont.cpp | 15 +++++++++++++++ Userland/Libraries/LibGfx/BitmapFont.h | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibGfx/BitmapFont.cpp b/Userland/Libraries/LibGfx/BitmapFont.cpp index 0f00086fc6..010d7c48d3 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.cpp +++ b/Userland/Libraries/LibGfx/BitmapFont.cpp @@ -10,6 +10,7 @@ #include #include #include +#include namespace Gfx { @@ -348,6 +349,20 @@ String BitmapFont::qualified_name() const return String::formatted("{} {} {}", family(), presentation_size(), weight()); } +String BitmapFont::variant() const +{ + StringBuilder builder; + builder.append(weight_to_name(weight())); + if (slope()) { + if (builder.string_view() == "Regular"sv) + builder.clear(); + else + builder.append(" "); + builder.append(slope_to_name(slope())); + } + return builder.to_string(); +} + Font const& Font::bold_variant() const { if (m_bold_variant) diff --git a/Userland/Libraries/LibGfx/BitmapFont.h b/Userland/Libraries/LibGfx/BitmapFont.h index 99594b5ff0..ab70bd9db6 100644 --- a/Userland/Libraries/LibGfx/BitmapFont.h +++ b/Userland/Libraries/LibGfx/BitmapFont.h @@ -100,7 +100,7 @@ public: String family() const override { return m_family; } void set_family(String family) { m_family = move(family); } - String variant() const override { return String::number(weight()); } + String variant() const override; String qualified_name() const override;