mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:07:35 +00:00
LibGfx: Decouple glyph positions calculation from draw_text_run()
This change separates a part of the `draw_text_run()` function, which is responsible for calculating the positions for glyphs that need to be painted, into a separate function called `get_glyph_run()`. It is a part of the preparation for text run painting using OpenGL, where we can't immediately blit glyph bitmaps but instead need to prepare a sequence of quads for them in advance.
This commit is contained in:
parent
3ac77dac99
commit
efdbd8238e
4 changed files with 121 additions and 61 deletions
|
@ -167,13 +167,16 @@ void Path::text(Utf8View text, Font const& font)
|
|||
dbgln("Cannot path-ify bitmap fonts!");
|
||||
return;
|
||||
}
|
||||
|
||||
auto& scaled_font = static_cast<ScaledFont const&>(font);
|
||||
for_each_glyph_position(
|
||||
last_point(), text, font, [&](GlyphPosition glyph_position) {
|
||||
move_to(glyph_position.position);
|
||||
// FIXME: This does not correctly handle multi-codepoint glyphs (i.e. emojis).
|
||||
auto glyph_id = scaled_font.glyph_id_for_code_point(*glyph_position.it);
|
||||
scaled_font.append_glyph_path_to(*this, glyph_id);
|
||||
last_point(), text, font, [&](DrawGlyphOrEmoji glyph_or_emoji) {
|
||||
if (glyph_or_emoji.has<DrawGlyph>()) {
|
||||
auto& glyph = glyph_or_emoji.get<DrawGlyph>();
|
||||
move_to(glyph.position);
|
||||
auto glyph_id = scaled_font.glyph_id_for_code_point(glyph.code_point);
|
||||
scaled_font.append_glyph_path_to(*this, glyph_id);
|
||||
}
|
||||
},
|
||||
IncludeLeftBearing::Yes);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue