1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 04:57:45 +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

@ -64,14 +64,17 @@ public:
{
}
Glyph(RefPtr<Bitmap> bitmap, float left_bearing, float advance, float ascent)
Glyph(RefPtr<Bitmap> bitmap, float left_bearing, float advance, float ascent, bool is_color_bitmap)
: m_bitmap(bitmap)
, m_left_bearing(left_bearing)
, m_advance(advance)
, m_ascent(ascent)
, m_color_bitmap(is_color_bitmap)
{
}
bool is_color_bitmap() const { return m_color_bitmap; }
bool is_glyph_bitmap() const { return !m_bitmap; }
GlyphBitmap glyph_bitmap() const { return m_glyph_bitmap; }
RefPtr<Bitmap> bitmap() const { return m_bitmap; }
@ -85,6 +88,7 @@ private:
float m_left_bearing;
float m_advance;
float m_ascent;
bool m_color_bitmap { false };
};
struct GlyphSubpixelOffset {
@ -207,6 +211,8 @@ public:
Font const& bold_variant() const;
virtual bool has_color_bitmaps() const = 0;
private:
mutable RefPtr<Gfx::Font const> m_bold_variant;
};