mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-24 19:21:52 +00:00
LibGfx+LibWeb: Support per-glyph font fallbacks in canvas text painting
Instead of using the first font from the FontCascadeList for all glyphs in a text, we perform a text shaping process that finds a suitable font for each glyph and returns a list of glyph runs, where each glyph run represents consecutive glyphs using the same font.
This commit is contained in:
parent
1e7922fac8
commit
f6b0851c38
Notes:
github-actions[bot]
2025-04-21 07:52:18 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: f6b0851c38
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4409
3 changed files with 49 additions and 4 deletions
|
@ -232,11 +232,13 @@ Gfx::Path CanvasRenderingContext2D::text_path(StringView text, float x, float y,
|
|||
|
||||
auto& drawing_state = this->drawing_state();
|
||||
|
||||
auto const& font = font_cascade_list()->first();
|
||||
|
||||
auto const& font_cascade_list = this->font_cascade_list();
|
||||
auto const& font = font_cascade_list->first();
|
||||
auto glyph_runs = Gfx::shape_text({ x, y }, Utf8View(text), *font_cascade_list);
|
||||
Gfx::Path path;
|
||||
auto glyph_run = Gfx::shape_text({ x, y }, 0, Utf8View(text), font, Gfx::GlyphRun::TextType::Ltr, {});
|
||||
path.glyph_run(*glyph_run);
|
||||
for (auto const& glyph_run : glyph_runs) {
|
||||
path.glyph_run(glyph_run);
|
||||
}
|
||||
|
||||
auto text_width = path.bounding_box().width();
|
||||
Gfx::AffineTransform transform = {};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue