Everywhere: Limit layout text fragments to use one font for all glyphs

The ChunkIterator now limits a chunk to using only one font (before, it
was possible to have a chunk with >1 font, when `unicode-range` CSS
property is used).

This change allows us to reduce some complexity in the text shaping and
painting code and makes us compatible with the APIs in Skia and
HarfBuzz.
This commit is contained in:
Aliaksandr Kalenik
2024-06-29 17:14:23 +02:00
committed by Alexander Kalenik
parent b95c05b611
commit 7181c3f2ea
25 changed files with 98 additions and 83 deletions

View File

@@ -167,10 +167,8 @@ void Path::text(Utf8View text, Font const& font)
}
auto& scaled_font = static_cast<ScaledFont const&>(font);
auto font_list = Gfx::FontCascadeList::create();
font_list->add(scaled_font);
for_each_glyph_position(
last_point(), text, font_list, [&](DrawGlyphOrEmoji glyph_or_emoji) {
last_point(), text, scaled_font, [&](DrawGlyphOrEmoji glyph_or_emoji) {
if (glyph_or_emoji.has<DrawGlyph>()) {
auto& glyph = glyph_or_emoji.get<DrawGlyph>();
move_to(glyph.position);
@@ -208,13 +206,10 @@ Path Path::place_text_along(Utf8View text, Font const& font) const
return lines[line_index].a();
};
auto font_list = Gfx::FontCascadeList::create();
font_list->add(font);
auto& scaled_font = static_cast<Gfx::ScaledFont const&>(font);
Gfx::Path result_path;
Gfx::for_each_glyph_position(
{}, text, font_list, [&](Gfx::DrawGlyphOrEmoji glyph_or_emoji) {
{}, text, font, [&](Gfx::DrawGlyphOrEmoji glyph_or_emoji) {
auto* glyph = glyph_or_emoji.get_pointer<Gfx::DrawGlyph>();
if (!glyph)
return;