mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:17:44 +00:00
LibWeb: Use Gfx::FontDatabase::for_each_typeface_with_family_name()
This avoids looking at every single installed typeface to see if there's
a family name match.
Fixes a large performance regression introduced when making
StyleComputer consider system fonts in CSS font fallback.
Regressed with 69a81243f5
.
This commit is contained in:
parent
2cd89531f9
commit
7cd975268c
1 changed files with 8 additions and 10 deletions
|
@ -2077,16 +2077,14 @@ RefPtr<Gfx::Font const> StyleComputer::font_matching_algorithm(FontFaceKey const
|
||||||
if (font_key_and_loader.key.family_name.equals_ignoring_ascii_case(key.family_name))
|
if (font_key_and_loader.key.family_name.equals_ignoring_ascii_case(key.family_name))
|
||||||
matching_family_fonts.empend(font_key_and_loader.key, font_key_and_loader.value.ptr());
|
matching_family_fonts.empend(font_key_and_loader.key, font_key_and_loader.value.ptr());
|
||||||
}
|
}
|
||||||
Gfx::FontDatabase::the().for_each_typeface([&](Gfx::Typeface const& typeface) {
|
Gfx::FontDatabase::the().for_each_typeface_with_family_name(key.family_name.to_string(), [&](Gfx::Typeface const& typeface) {
|
||||||
if (typeface.family().equals_ignoring_ascii_case(key.family_name)) {
|
matching_family_fonts.empend(
|
||||||
matching_family_fonts.empend(
|
FontFaceKey {
|
||||||
FontFaceKey {
|
.family_name = MUST(FlyString::from_deprecated_fly_string(typeface.family())),
|
||||||
.family_name = MUST(FlyString::from_deprecated_fly_string(typeface.family())),
|
.weight = static_cast<int>(typeface.weight()),
|
||||||
.weight = static_cast<int>(typeface.weight()),
|
.slope = typeface.slope(),
|
||||||
.slope = typeface.slope(),
|
},
|
||||||
},
|
&typeface);
|
||||||
&typeface);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
quick_sort(matching_family_fonts, [](auto const& a, auto const& b) {
|
quick_sort(matching_family_fonts, [](auto const& a, auto const& b) {
|
||||||
return a.key.weight < b.key.weight;
|
return a.key.weight < b.key.weight;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue