1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:27:35 +00:00

LibGfx: Pass font width to FontDatabase::get()

Width need to be passed to `FontDatabase::get()` to resolve font name
unambiguously.
This commit is contained in:
Aliaksandr Kalenik 2023-02-04 23:00:34 +03:00 committed by Sam Atkins
parent 79006c03b4
commit 1f4106842d
21 changed files with 71 additions and 21 deletions

View file

@ -34,11 +34,11 @@ FontPluginQt::FontPluginQt()
update_generic_fonts();
auto default_font_name = generic_font_name(Web::Platform::GenericFont::UiSansSerif);
m_default_font = Gfx::FontDatabase::the().get(default_font_name, 12.0, 400, 0);
m_default_font = Gfx::FontDatabase::the().get(default_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0);
VERIFY(m_default_font);
auto default_fixed_width_font_name = generic_font_name(Web::Platform::GenericFont::UiMonospace);
m_default_fixed_width_font = Gfx::FontDatabase::the().get(default_fixed_width_font_name, 12.0, 400, 0);
m_default_fixed_width_font = Gfx::FontDatabase::the().get(default_fixed_width_font_name, 12.0, 400, Gfx::FontWidth::Normal, 0);
VERIFY(m_default_fixed_width_font);
}
@ -73,10 +73,10 @@ void FontPluginQt::update_generic_fonts()
QFontInfo qt_info(qt_font);
auto qt_font_family = qt_info.family();
auto gfx_font = Gfx::FontDatabase::the().get(qt_font_family.toUtf8().data(), 16, 400, 0, Gfx::Font::AllowInexactSizeMatch::Yes);
auto gfx_font = Gfx::FontDatabase::the().get(qt_font_family.toUtf8().data(), 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes);
if (!gfx_font) {
for (auto& fallback : fallbacks) {
gfx_font = Gfx::FontDatabase::the().get(fallback, 16, 400, 0, Gfx::Font::AllowInexactSizeMatch::Yes);
gfx_font = Gfx::FontDatabase::the().get(fallback, 16, 400, Gfx::FontWidth::Normal, 0, Gfx::Font::AllowInexactSizeMatch::Yes);
if (gfx_font)
break;
}