mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGfx: Add FontDatabase::for_each_typeface_with_family_name()
Some clients (e.g LibWeb) want to look up typefaces by name. Since we already store typefaces in a HashMap keyed by family name, let's also have a nice & fast API that takes advantage of this.
This commit is contained in:
parent
82ccc49b52
commit
2cd89531f9
Notes:
sideshowbarker
2024-07-17 03:35:16 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2cd89531f9 Pull-request: https://github.com/SerenityOS/serenity/pull/20741
2 changed files with 10 additions and 0 deletions
|
@ -260,4 +260,13 @@ void FontDatabase::for_each_typeface(Function<void(Typeface const&)> callback)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FontDatabase::for_each_typeface_with_family_name(String const& family_name, Function<void(Typeface const&)> callback)
|
||||||
|
{
|
||||||
|
auto it = m_private->typefaces.find(family_name.bytes_as_string_view());
|
||||||
|
if (it == m_private->typefaces.end())
|
||||||
|
return;
|
||||||
|
for (auto const& typeface : it->value)
|
||||||
|
callback(*typeface);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
|
void for_each_fixed_width_font(Function<void(Gfx::Font const&)>);
|
||||||
|
|
||||||
void for_each_typeface(Function<void(Typeface const&)>);
|
void for_each_typeface(Function<void(Typeface const&)>);
|
||||||
|
void for_each_typeface_with_family_name(String const& family_name, Function<void(Typeface const&)>);
|
||||||
|
|
||||||
void load_all_fonts_from_path(DeprecatedString const&);
|
void load_all_fonts_from_path(DeprecatedString const&);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue