1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:15:07 +00:00

LibHTML: Implement basic support for "text-decoration: underline"

This commit is contained in:
Andreas Kling 2019-09-28 22:31:41 +02:00
parent 62cbaa74f3
commit 8271ad40a5
2 changed files with 7 additions and 1 deletions

View file

@ -228,6 +228,9 @@ void LayoutText::render(RenderingContext& context)
painter.set_font(*m_font);
auto color = style_properties().color_or_fallback("color", Color::Black);
auto text_decoration = style_properties().string_or_fallback("text-decoration", "none");
bool is_underline = text_decoration == "underline";
for (auto& run : m_runs) {
Rect rect {
@ -237,5 +240,8 @@ void LayoutText::render(RenderingContext& context)
m_font->glyph_height()
};
painter.draw_text(rect, run.text, TextAlignment::TopLeft, color);
if (is_underline)
painter.draw_line(rect.bottom_left().translated(0, 1), rect.bottom_right().translated(0, 1), color);
}
}