1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +00:00

LibTTF: Cache rasterized glyphs within TTF::ScaledFont

This commit is contained in:
Stephan Unverwerth 2020-12-29 17:56:13 +01:00 committed by Andreas Kling
parent 0f6cf9caa1
commit 1a072a61fb
2 changed files with 14 additions and 4 deletions

View file

@ -444,4 +444,15 @@ int ScaledFont::width(const Utf32View& utf32) const
return width;
}
RefPtr<Gfx::Bitmap> ScaledFont::raster_glyph(u32 glyph_id) const
{
auto glyph_iterator = m_cached_glyph_bitmaps.find(glyph_id);
if (glyph_iterator != m_cached_glyph_bitmaps.end())
return glyph_iterator->value;
auto glyph_bitmap = m_font->raster_glyph(glyph_id, m_x_scale, m_y_scale);
m_cached_glyph_bitmaps.set(glyph_id, glyph_bitmap);
return glyph_bitmap;
}
}