From 840a64e2f987cfd31fe322cf46d1d15376848368 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=BCseyin=20ASLIT=C3=9CRK?= Date: Sat, 16 May 2020 22:21:19 +0300 Subject: [PATCH] LibGfx: Painter, extend fonts to 384 character to support LatinExtendedA Replace codepoint variable type from char to u32. --- Libraries/LibGfx/Painter.cpp | 12 ++++++------ Libraries/LibGfx/Painter.h | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Libraries/LibGfx/Painter.cpp b/Libraries/LibGfx/Painter.cpp index 694fba0fe2..da6728fe06 100644 --- a/Libraries/LibGfx/Painter.cpp +++ b/Libraries/LibGfx/Painter.cpp @@ -764,14 +764,14 @@ void Painter::draw_scaled_bitmap(const Rect& a_dst_rect, const Gfx::Bitmap& sour } } -FLATTEN void Painter::draw_glyph(const Point& point, char ch, Color color) +FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, Color color) { - draw_glyph(point, ch, font(), color); + draw_glyph(point, codepoint, font(), color); } -FLATTEN void Painter::draw_glyph(const Point& point, char ch, const Font& font, Color color) +FLATTEN void Painter::draw_glyph(const Point& point, u32 codepoint, const Font& font, Color color) { - draw_bitmap(point, font.glyph_bitmap(ch), color); + draw_bitmap(point, font.glyph_bitmap(codepoint), color); } void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Font& font) @@ -791,9 +791,9 @@ void Painter::draw_emoji(const Point& point, const Gfx::Bitmap& emoji, const Fon void Painter::draw_glyph_or_emoji(const Point& point, u32 codepoint, const Font& font, Color color) { - if (codepoint < 256) { + if (codepoint < (u32)font.glyph_count()) { // This looks like a regular character. - draw_glyph(point, (char)codepoint, font, color); + draw_glyph(point, (size_t)codepoint, font, color); return; } diff --git a/Libraries/LibGfx/Painter.h b/Libraries/LibGfx/Painter.h index 274a5bcfed..4f695c50d1 100644 --- a/Libraries/LibGfx/Painter.h +++ b/Libraries/LibGfx/Painter.h @@ -76,8 +76,8 @@ public: void draw_text(const Rect&, const StringView&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); void draw_text(const Rect&, const Utf32View&, const Font&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); void draw_text(const Rect&, const Utf32View&, TextAlignment = TextAlignment::TopLeft, Color = Color::Black, TextElision = TextElision::None); - void draw_glyph(const Point&, char, Color); - void draw_glyph(const Point&, char, const Font&, Color); + void draw_glyph(const Point&, u32, Color); + void draw_glyph(const Point&, u32, const Font&, Color); void draw_emoji(const Point&, const Gfx::Bitmap&, const Font&); void draw_glyph_or_emoji(const Point&, u32 codepoint, const Font&, Color);