1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:37:35 +00:00

LibGfx: Prepare the paint code for fonts whose glyphs are color bitmaps

This patch does three things:
- Font::has_color_bitmaps() (true if CBLC and CBDT are present)
- Glyph now knows when its bitmap comes from a color bitmap font
- Painter draws color bitmap glyphs with the appropriate scaling etc
This commit is contained in:
Andreas Kling 2023-03-04 20:33:02 +01:00
parent bca35bee6d
commit e8cc1a4373
8 changed files with 22 additions and 2 deletions

View file

@ -1369,6 +1369,13 @@ FLATTEN void Painter::draw_glyph(FloatPoint point, u32 code_point, Font const& f
if (glyph.is_glyph_bitmap()) {
draw_bitmap(top_left.to_type<int>(), glyph.glyph_bitmap(), color);
} else if (glyph.is_color_bitmap()) {
float scaled_width = glyph.advance();
float ratio = static_cast<float>(glyph.bitmap()->height()) / static_cast<float>(glyph.bitmap()->width());
float scaled_height = scaled_width * ratio;
FloatRect rect(point.x(), point.y(), scaled_width, scaled_height);
draw_scaled_bitmap(rect.to_rounded<int>(), *glyph.bitmap(), glyph.bitmap()->rect(), 1.0f, ScalingMode::BilinearBlend);
} else {
blit_filtered(glyph_position.blit_position, *glyph.bitmap(), glyph.bitmap()->rect(), [color](Color pixel) -> Color {
return pixel.multiply(color);