1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 21:37:35 +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:
Aliaksandr Kalenik 2023-12-09 23:42:02 +01:00 committed by Andreas Kling
parent f50bf00814
commit 2cb0039a13
23 changed files with 250 additions and 109 deletions

View file

@ -427,7 +427,7 @@ ErrorOr<void> TreeBuilder::create_layout_tree(DOM::Node& dom_node, TreeBuilder::
auto content_box_computed_values = parent.computed_values().clone_inherited_values();
auto content_box_wrapper = parent.heap().template allocate_without_realm<BlockContainer>(parent.document(), nullptr, move(content_box_computed_values));
content_box_wrapper->set_font(parent.font());
content_box_wrapper->set_font_list(parent.font_list());
content_box_wrapper->set_line_height(parent.line_height());
content_box_wrapper->set_children_are_inline(parent.children_are_inline());
@ -630,7 +630,7 @@ static void wrap_in_anonymous(Vector<JS::Handle<Node>>& sequence, Node* nearest_
}
wrapper->set_children_are_inline(parent.children_are_inline());
wrapper->set_line_height(parent.line_height());
wrapper->set_font(parent.font());
wrapper->set_font_list(parent.font_list());
if (nearest_sibling)
parent.insert_before(*wrapper, *nearest_sibling);
else
@ -717,7 +717,7 @@ Vector<JS::Handle<Box>> TreeBuilder::generate_missing_parents(NodeWithStyle& roo
parent.remove_child(*table_box);
wrapper->append_child(*table_box);
wrapper->set_font(parent.font());
wrapper->set_font_list(parent.font_list());
wrapper->set_line_height(parent.line_height());
if (nearest_sibling)
@ -753,7 +753,7 @@ static void fixup_row(Box& row_box, TableGrid const& table_grid, size_t row_inde
// Ensure that the cell (with zero content height) will have the same height as the row by setting vertical-align to middle.
cell_computed_values.set_vertical_align(CSS::VerticalAlign::Middle);
auto cell_box = row_box.heap().template allocate_without_realm<BlockContainer>(row_box.document(), nullptr, cell_computed_values);
cell_box->set_font(row_box.font());
cell_box->set_font_list(row_box.font_list());
cell_box->set_line_height(row_box.line_height());
row_box.append_child(cell_box);
}