1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:47:44 +00:00

LibGfx+LibWeb: Move Gfx::ScaledFont caching from LibWeb into LibGfx

Before this change, we would only cache and reuse Gfx::ScaledFont
instances for downloaded CSS fonts.

By moving it into Gfx::VectorFont, we get caching for all vector fonts,
including local system TTFs etc.

This avoids a *lot* of style invalidations in LibWeb, since we now vend
the same Gfx::Font pointer for the same font when used repeatedly.
This commit is contained in:
Andreas Kling 2023-12-25 12:45:18 +01:00
parent bf8107b247
commit f900957d26
16 changed files with 54 additions and 137 deletions

View file

@ -155,7 +155,9 @@ u8 ScaledFont::glyph_fixed_width() const
RefPtr<Font> ScaledFont::with_size(float point_size) const
{
return adopt_ref(*new Gfx::ScaledFont(*m_font, point_size, point_size));
if (point_size == m_point_height && point_size == m_point_width)
return const_cast<ScaledFont*>(this);
return m_font->scaled_font(point_size);
}
Gfx::FontPixelMetrics ScaledFont::pixel_metrics() const