mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:17:45 +00:00
LibWeb: Use glyph run to store text paint command in RecordingPainter
Representing a text run panting command as a vector of glyphs, rather than as a string simplifies collecting of unique glyphs which is a prerequisite for `prepare_glyphs_texture()` call.
This commit is contained in:
parent
32ea11d45c
commit
ee28ba0c93
6 changed files with 23 additions and 17 deletions
|
@ -20,10 +20,18 @@ PaintingCommandExecutorCPU::PaintingCommandExecutorCPU(Gfx::Bitmap& bitmap)
|
|||
stacking_contexts.append({ Gfx::Painter(bitmap), {}, 1.0f });
|
||||
}
|
||||
|
||||
CommandResult PaintingCommandExecutorCPU::draw_text_run(Color const& color, Gfx::IntPoint const& baseline_start, String const& string, Gfx::Font const& font)
|
||||
CommandResult PaintingCommandExecutorCPU::draw_glyph_run(Vector<Gfx::DrawGlyphOrEmoji> const& glyph_run, Color const& color)
|
||||
{
|
||||
auto& painter = this->painter();
|
||||
painter.draw_text_run(baseline_start, Utf8View(string), font, color);
|
||||
for (auto& glyph_or_emoji : glyph_run) {
|
||||
if (glyph_or_emoji.has<Gfx::DrawGlyph>()) {
|
||||
auto& glyph = glyph_or_emoji.get<Gfx::DrawGlyph>();
|
||||
painter.draw_glyph(glyph.position, glyph.code_point, *glyph.font, color);
|
||||
} else {
|
||||
auto& emoji = glyph_or_emoji.get<Gfx::DrawEmoji>();
|
||||
painter.draw_emoji(emoji.position, *emoji.emoji, *emoji.font);
|
||||
}
|
||||
}
|
||||
return CommandResult::Continue;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue