1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-03 05:32:13 +00:00

LibHTML: Implement rendering

This commit is contained in:
Sergey Bugaev 2019-09-25 12:40:37 +03:00 committed by Andreas Kling
parent 93003bfda1
commit 235dee8c42
7 changed files with 62 additions and 0 deletions

View file

@ -1,6 +1,7 @@
#include <AK/StringBuilder.h>
#include <LibCore/CDirIterator.h>
#include <LibDraw/Font.h>
#include <LibGUI/GPainter.h>
#include <LibHTML/Layout/LayoutBlock.h>
#include <LibHTML/Layout/LayoutText.h>
#include <ctype.h>
@ -216,3 +217,19 @@ void LayoutText::layout()
rect().set_right(last_run.pos.x() + m_font->width(last_run.text));
rect().set_bottom(last_run.pos.y() + m_font->glyph_height());
}
void LayoutText::render(RenderingContext& context)
{
auto& painter = context.painter();
painter.set_font(*m_font);
for (auto& run : m_runs) {
Rect rect {
run.pos.x(),
run.pos.y(),
m_font->width(run.text),
m_font->glyph_height()
};
painter.draw_text(rect, run.text);
}
}