mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
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 :^)
This commit is contained in:
parent
c03353e7ca
commit
c0f9adabd6
Notes:
sideshowbarker
2024-07-18 09:20:41 +09:00
Author: https://github.com/luk1337 Commit: https://github.com/SerenityOS/serenity/commit/c0f9adabd6a Pull-request: https://github.com/SerenityOS/serenity/pull/8624
1 changed files with 8 additions and 0 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue