1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:17:44 +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

@ -191,7 +191,7 @@ CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const
auto line_height = property(CSS::PropertyID::LineHeight);
if (line_height->is_identifier() && line_height->to_identifier() == ValueID::Normal)
return CSSPixels::nearest_value_for(layout_node.font().pixel_metrics().line_spacing());
return CSSPixels::nearest_value_for(layout_node.first_available_font().pixel_metrics().line_spacing());
if (line_height->is_length()) {
auto line_height_length = line_height->as_length().length();
@ -213,7 +213,7 @@ CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const
auto resolved = line_height->as_calculated().resolve_number();
if (!resolved.has_value()) {
dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height->as_calculated().to_string());
return CSSPixels::nearest_value_for(layout_node.font().pixel_metrics().line_spacing());
return CSSPixels::nearest_value_for(layout_node.first_available_font().pixel_metrics().line_spacing());
}
return Length(resolved.value(), Length::Type::Em).to_px(layout_node);
}
@ -221,12 +221,12 @@ CSSPixels StyleProperties::line_height(Layout::Node const& layout_node) const
auto resolved = line_height->as_calculated().resolve_length(layout_node);
if (!resolved.has_value()) {
dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height->as_calculated().to_string());
return CSSPixels::nearest_value_for(layout_node.font().pixel_metrics().line_spacing());
return CSSPixels::nearest_value_for(layout_node.first_available_font().pixel_metrics().line_spacing());
}
return resolved->to_px(layout_node);
}
return CSSPixels::nearest_value_for(layout_node.font().pixel_metrics().line_spacing());
return CSSPixels::nearest_value_for(layout_node.first_available_font().pixel_metrics().line_spacing());
}
Optional<int> StyleProperties::z_index() const