mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 12:27:34 +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
|
@ -192,7 +192,7 @@ void LineBuilder::update_last_line()
|
|||
}
|
||||
|
||||
auto strut_baseline = [&] {
|
||||
auto& font = m_context.containing_block().font();
|
||||
auto& font = m_context.containing_block().first_available_font();
|
||||
auto const line_height = m_context.containing_block().line_height();
|
||||
auto const font_metrics = font.pixel_metrics();
|
||||
auto const typographic_height = CSSPixels::nearest_value_for(font_metrics.ascent + font_metrics.descent);
|
||||
|
@ -204,7 +204,7 @@ void LineBuilder::update_last_line()
|
|||
auto line_box_baseline = [&] {
|
||||
CSSPixels line_box_baseline = strut_baseline;
|
||||
for (auto& fragment : line_box.fragments()) {
|
||||
auto const& font = fragment.layout_node().font();
|
||||
auto const& font = fragment.layout_node().first_available_font();
|
||||
auto const line_height = fragment.layout_node().line_height();
|
||||
auto const font_metrics = font.pixel_metrics();
|
||||
auto const typographic_height = CSSPixels::nearest_value_for(font_metrics.ascent + font_metrics.descent);
|
||||
|
@ -301,7 +301,7 @@ void LineBuilder::update_last_line()
|
|||
top_of_inline_box = (fragment.offset().y() - fragment_box_state.margin_box_top());
|
||||
bottom_of_inline_box = (fragment.offset().y() + fragment_box_state.content_height() + fragment_box_state.margin_box_bottom());
|
||||
} else {
|
||||
auto font_metrics = fragment.layout_node().font().pixel_metrics();
|
||||
auto font_metrics = fragment.layout_node().first_available_font().pixel_metrics();
|
||||
auto typographic_height = CSSPixels::nearest_value_for(font_metrics.ascent + font_metrics.descent);
|
||||
auto leading = fragment.layout_node().line_height() - typographic_height;
|
||||
auto half_leading = leading / 2;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue