summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuK1337 <priv.luk@gmail.com>2021-07-11 00:06:13 +0200
committerAndreas Kling <kling@serenityos.org>2021-07-11 14:12:47 +0200
commitc0f9adabd6ab874ae98ef26bacb46a2eef153e51 (patch)
tree89ee228f85e5147349646314358d14c2bcd6f5b2
parentc03353e7cae00a0757a7ff50a2d8e89c025fc5c8 (diff)
downloadserenity-c0f9adabd6ab874ae98ef26bacb46a2eef153e51.zip
LibGfx: Try to get TTF font when query is not in name->font map
This change allows us to select TTF fonts in display settings again :^)
-rw-r--r--Userland/Libraries/LibGfx/FontDatabase.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGfx/FontDatabase.cpp b/Userland/Libraries/LibGfx/FontDatabase.cpp
index 85c8adf7e2..555212f170 100644
--- a/Userland/Libraries/LibGfx/FontDatabase.cpp
+++ b/Userland/Libraries/LibGfx/FontDatabase.cpp
@@ -140,6 +140,13 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(const StringView& name)
{
auto it = m_private->full_name_to_font_map.find(name);
if (it == m_private->full_name_to_font_map.end()) {
+ auto parts = name.split_view(" "sv);
+ if (parts.size() >= 3) {
+ auto weight = parts.take_last().to_int().value_or(0);
+ auto size = parts.take_last().to_int().value_or(0);
+ auto family = String::join(' ', parts);
+ return get(family, size, weight);
+ }
dbgln("Font lookup failed: '{}'", name);
return nullptr;
}
@@ -152,6 +159,7 @@ RefPtr<Gfx::Font> FontDatabase::get(const String& family, unsigned size, unsigne
if (typeface->family() == family && typeface->weight() == weight)
return typeface->get_font(size);
}
+ dbgln("Failed to get font: '{} {} {}'", family, size, weight);
return nullptr;
}