summaryrefslogtreecommitdiff
path: root/Userland/Applications/PixelPaint
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-05 17:13:55 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-06 12:02:20 +0100
commit2a61d66b0afbe30751fb268cfac2c136553294e7 (patch)
tree8803357e4cf2493201604a66573e5fc6a26f43a1 /Userland/Applications/PixelPaint
parent43a10674d03a2dabea723787347354ef48e31197 (diff)
downloadserenity-2a61d66b0afbe30751fb268cfac2c136553294e7.zip
LibGfx: Make Font::preferred_line_height() more correct
Return a float, and fix a bogus calculation of ascender + descender.
Diffstat (limited to 'Userland/Applications/PixelPaint')
-rw-r--r--Userland/Applications/PixelPaint/Tools/TextTool.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/Userland/Applications/PixelPaint/Tools/TextTool.cpp b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
index a8dfd8df6d..b2d579bddd 100644
--- a/Userland/Applications/PixelPaint/Tools/TextTool.cpp
+++ b/Userland/Applications/PixelPaint/Tools/TextTool.cpp
@@ -130,7 +130,7 @@ void TextTool::on_second_paint(Layer const* layer, GUI::PaintEvent& event)
painter.translate(editor_layer_location(*layer));
auto typed_text = m_text_editor->text();
auto text_width = max<int>(m_selected_font->width(typed_text), m_selected_font->width(" "sv));
- auto text_height = m_selected_font->preferred_line_height() * max<int>(static_cast<int>(m_text_editor->line_count()), 1);
+ auto text_height = static_cast<int>(ceilf(m_selected_font->preferred_line_height() * max<int>(static_cast<int>(m_text_editor->line_count()), 1)));
auto text_location = editor_stroke_position(m_add_text_position, 1);
// Since ImageEditor can be zoomed in/out, we need to be able to render the preview properly scaled
@@ -238,7 +238,7 @@ void TextTool::apply_text_to_layer()
auto demo_text = m_text_editor->text();
auto text_width = m_selected_font->width(demo_text);
- auto text_height = m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count());
+ auto text_height = static_cast<int>(ceilf(m_selected_font->preferred_line_height() * static_cast<int>(m_text_editor->line_count())));
painter.set_font(*m_selected_font);
auto text_rect = Gfx::Rect<int>(m_add_text_position, { static_cast<int>(ceilf(text_width)), text_height });