diff --git a/Libraries/LibHTML/Layout/LayoutBlock.cpp b/Libraries/LibHTML/Layout/LayoutBlock.cpp index df883947d3..e011214016 100644 --- a/Libraries/LibHTML/Layout/LayoutBlock.cpp +++ b/Libraries/LibHTML/Layout/LayoutBlock.cpp @@ -67,6 +67,7 @@ void LayoutBlock::layout_inline_children() } float min_line_height = style().line_height(); + float line_spacing = min_line_height - style().font().glyph_height(); float content_height = 0; // FIXME: This should be done by the CSS parser! @@ -121,7 +122,7 @@ void LayoutBlock::layout_inline_children() // Vertically align everyone's bottom to the line. // FIXME: Support other kinds of vertical alignment. fragment.rect().set_x(roundf(x_offset + fragment.rect().x())); - fragment.rect().set_y(y() + content_height + (max_height - fragment.rect().height())); + fragment.rect().set_y(y() + content_height + (max_height - fragment.rect().height()) - (line_spacing / 2)); if (text_align == CSS::ValueID::Justify) { if (fragment.is_justifiable_whitespace()) { diff --git a/Libraries/LibHTML/Layout/LayoutText.cpp b/Libraries/LibHTML/Layout/LayoutText.cpp index 885c89fea5..a3a2ec14f8 100644 --- a/Libraries/LibHTML/Layout/LayoutText.cpp +++ b/Libraries/LibHTML/Layout/LayoutText.cpp @@ -54,7 +54,7 @@ void LayoutText::render_fragment(RenderingContext& context, const LineBoxFragmen bool is_underline = text_decoration == "underline"; if (is_underline) - painter.draw_line(enclosing_int_rect(fragment.rect()).bottom_left().translated(0, -1), enclosing_int_rect(fragment.rect()).bottom_right().translated(0, -1), color); + painter.draw_line(enclosing_int_rect(fragment.rect()).bottom_left().translated(0, 1), enclosing_int_rect(fragment.rect()).bottom_right().translated(0, 1), color); painter.draw_text(enclosing_int_rect(fragment.rect()), m_text_for_rendering.substring_view(fragment.start(), fragment.length()), TextAlignment::TopLeft, color); } @@ -131,7 +131,6 @@ void LayoutText::split_into_lines(LayoutBlock& container) { auto& font = style().font(); float space_width = font.glyph_width(' ') + font.glyph_spacing(); - float line_height = style().line_height(); auto& line_boxes = container.line_boxes(); if (line_boxes.is_empty()) @@ -142,7 +141,7 @@ void LayoutText::split_into_lines(LayoutBlock& container) if (is_preformatted) { m_text_for_rendering = node().data(); for_each_source_line([&](const Utf8View& view, int start, int length) { - line_boxes.last().add_fragment(*this, start, length, font.width(view), line_height); + line_boxes.last().add_fragment(*this, start, length, font.width(view), font.glyph_height()); line_boxes.append(LineBox()); }); return; @@ -196,7 +195,7 @@ void LayoutText::split_into_lines(LayoutBlock& container) if (is_whitespace && line_boxes.last().fragments().is_empty()) continue; - line_boxes.last().add_fragment(*this, word.start, is_whitespace ? 1 : word.length, word_width, line_height); + line_boxes.last().add_fragment(*this, word.start, is_whitespace ? 1 : word.length, word_width, font.glyph_height()); available_width -= word_width; if (available_width < 0) {