mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:37:44 +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:
parent
79006c03b4
commit
1f4106842d
21 changed files with 71 additions and 21 deletions
|
@ -206,7 +206,7 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
|
|||
auto weight = parts.take_last().to_int().value_or(0);
|
||||
auto size = parts.take_last().to_int().value_or(0);
|
||||
auto family = DeprecatedString::join(' ', parts);
|
||||
return get(family, size, weight, slope);
|
||||
return get(family, size, weight, Gfx::FontWidth::Normal, slope);
|
||||
}
|
||||
dbgln("Font lookup failed: '{}'", name);
|
||||
return nullptr;
|
||||
|
@ -214,13 +214,13 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
|
|||
return it->value;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, float point_size, unsigned weight, unsigned slope, Font::AllowInexactSizeMatch allow_inexact_size_match)
|
||||
RefPtr<Gfx::Font> FontDatabase::get(DeprecatedFlyString const& family, float point_size, unsigned weight, unsigned width, unsigned slope, Font::AllowInexactSizeMatch allow_inexact_size_match)
|
||||
{
|
||||
auto it = m_private->typefaces.find(family);
|
||||
if (it == m_private->typefaces.end())
|
||||
return nullptr;
|
||||
for (auto const& typeface : it->value) {
|
||||
if (typeface->weight() == weight && typeface->slope() == slope)
|
||||
if (typeface->weight() == weight && typeface->width() == width && typeface->slope() == slope)
|
||||
return typeface->get_font(point_size, allow_inexact_size_match);
|
||||
}
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue