diff options
author | Andreas Kling <kling@serenityos.org> | 2022-03-27 00:58:52 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-03-27 01:14:56 +0100 |
commit | b0208f38f680518666c177220554bc2fe1cafbe4 (patch) | |
tree | bb3c935bf4782a337ddb844195393c32d522e34c /Userland/Libraries/LibWeb/HTML | |
parent | 65629d26fec73510aa84ced5d3130f40c0ad7cb1 (diff) | |
download | serenity-b0208f38f680518666c177220554bc2fe1cafbe4.zip |
LibWeb: Use Gfx::Font::pixel_size() when we want pixel metrics
This gives us consistent results with both bitmap and scalable fonts.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp index 76ed693fd0..806cae33cc 100644 --- a/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp +++ b/Userland/Libraries/LibWeb/HTML/CanvasRenderingContext2D.cpp @@ -240,7 +240,7 @@ void CanvasRenderingContext2D::fill_text(const String& text, float x, float y, O return; // FIXME: painter only supports integer rects for text right now, so this effectively chops off any fractional position - auto text_rect = Gfx::IntRect(x, y, max_width.has_value() ? max_width.value() : painter->font().width(text), painter->font().glyph_height()); + auto text_rect = Gfx::IntRect(x, y, max_width.has_value() ? max_width.value() : painter->font().width(text), painter->font().pixel_size()); auto transformed_rect = m_drawing_state.transform.map(text_rect); painter->draw_text(transformed_rect, text, Gfx::TextAlignment::TopLeft, m_drawing_state.fill_style); did_draw(transformed_rect.to_type<float>()); @@ -586,7 +586,7 @@ CanvasRenderingContext2D::PreparedText CanvasRenderingContext2D::prepare_text(St // FIXME: Once we have CanvasTextDrawingStyles, add the CSS attributes. auto& font = Gfx::FontDatabase::default_font(); size_t width = 0; - size_t height = font.glyph_height(); + size_t height = font.pixel_size(); for (auto c : Utf8View { replaced_text }) { width += font.glyph_or_emoji_width(c); } |