mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 21:08:12 +00:00
LibGfx+LibWeb: Produce font cascade list in CSS font matching algorithm
According to the CSS font matching algorithm specification, it is supposed to be executed for each glyph instead of each text run, as is currently done. This change partially implements this by having the font matching algorithm produce a list of fonts against which each glyph will be tested to find its suitable font. Now, it becomes possible to have per-glyph fallback fonts: if the needed glyph is not present in a font, we can check the subsequent fonts in the list.
This commit is contained in:
parent
f50bf00814
commit
2cb0039a13
23 changed files with 250 additions and 109 deletions
|
@ -190,14 +190,14 @@ Optional<InlineLevelIterator::Item> InlineLevelIterator::next_without_lookahead(
|
|||
Vector<Gfx::DrawGlyphOrEmoji> glyph_run;
|
||||
float glyph_run_width = 0;
|
||||
Gfx::for_each_glyph_position(
|
||||
{ 0, 0 }, chunk.view, text_node.font(), [&](Gfx::DrawGlyphOrEmoji const& glyph_or_emoji) {
|
||||
{ 0, 0 }, chunk.view, text_node.first_available_font(), [&](Gfx::DrawGlyphOrEmoji const& glyph_or_emoji) {
|
||||
glyph_run.append(glyph_or_emoji);
|
||||
return IterationDecision::Continue;
|
||||
},
|
||||
Gfx::IncludeLeftBearing::No, glyph_run_width);
|
||||
|
||||
if (!m_text_node_context->is_last_chunk)
|
||||
glyph_run_width += text_node.font().glyph_spacing();
|
||||
glyph_run_width += text_node.first_available_font().glyph_spacing();
|
||||
|
||||
CSSPixels chunk_width = CSSPixels::nearest_value_for(glyph_run_width);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue