mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:57:35 +00:00
LibGfx: Add Font::AllowInexactSizeMatch parameter to font lookup
This allows bitmap font lookup to return the best matching size instead of failing completely. The previous behavior (exact matches only) remains the default.
This commit is contained in:
parent
95715f0c8f
commit
4dd9e2df78
5 changed files with 28 additions and 8 deletions
|
@ -164,20 +164,20 @@ RefPtr<Gfx::Font> FontDatabase::get_by_name(StringView name)
|
|||
return it->value;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font> FontDatabase::get(const String& family, unsigned size, unsigned weight, unsigned slope)
|
||||
RefPtr<Gfx::Font> FontDatabase::get(String const& family, unsigned size, unsigned weight, unsigned slope, Font::AllowInexactSizeMatch allow_inexact_size_match)
|
||||
{
|
||||
for (auto typeface : m_private->typefaces) {
|
||||
if (typeface->family() == family && typeface->weight() == weight && typeface->slope() == slope)
|
||||
return typeface->get_font(size);
|
||||
return typeface->get_font(size, allow_inexact_size_match);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<Gfx::Font> FontDatabase::get(const String& family, const String& variant, unsigned size)
|
||||
RefPtr<Gfx::Font> FontDatabase::get(String const& family, const String& variant, unsigned size, Font::AllowInexactSizeMatch allow_inexact_size_match)
|
||||
{
|
||||
for (auto typeface : m_private->typefaces) {
|
||||
if (typeface->family() == family && typeface->variant() == variant)
|
||||
return typeface->get_font(size);
|
||||
return typeface->get_font(size, allow_inexact_size_match);
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue