1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:28:12 +00:00

LibGfx: Make Font::preferred_line_height() more correct

Return a float, and fix a bogus calculation of ascender + descender.
This commit is contained in:
Andreas Kling 2023-01-05 17:13:55 +01:00
parent 43a10674d0
commit 2a61d66b0a
8 changed files with 10 additions and 10 deletions

View file

@ -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 });