mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:27:44 +00:00
LibGfx: Make Gfx::FontMetrics include the advance of '0' instead of 'M'
CSS actually wants the advance of the ASCII '0' character for its "ch" units, so let's include that instead of the arbitrarily chosen 'M'.
This commit is contained in:
parent
2f7b6af87e
commit
0f6dd8c62b
3 changed files with 3 additions and 3 deletions
|
@ -377,7 +377,7 @@ FontMetrics Font::metrics() const
|
||||||
return FontMetrics {
|
return FontMetrics {
|
||||||
.size = (float)presentation_size(),
|
.size = (float)presentation_size(),
|
||||||
.x_height = (float)x_height(),
|
.x_height = (float)x_height(),
|
||||||
.glyph_width = (float)glyph_width('M'),
|
.advance_of_ascii_zero = (float)glyph_width('0'),
|
||||||
.glyph_spacing = (float)glyph_spacing(),
|
.glyph_spacing = (float)glyph_spacing(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ private:
|
||||||
struct FontMetrics {
|
struct FontMetrics {
|
||||||
float size { 0 };
|
float size { 0 };
|
||||||
float x_height { 0 };
|
float x_height { 0 };
|
||||||
float glyph_width { 0 };
|
float advance_of_ascii_zero { 0 };
|
||||||
float glyph_spacing { 0 };
|
float glyph_spacing { 0 };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ float Length::relative_length_to_px(Gfx::IntRect const& viewport_rect, Gfx::Font
|
||||||
return m_value * font_size;
|
return m_value * font_size;
|
||||||
case Type::Ch:
|
case Type::Ch:
|
||||||
// FIXME: Use layout_node.font().glyph_height() when writing-mode is not horizontal-tb (it has to be implemented first)
|
// FIXME: Use layout_node.font().glyph_height() when writing-mode is not horizontal-tb (it has to be implemented first)
|
||||||
return m_value * (font_metrics.glyph_width + font_metrics.glyph_spacing);
|
return m_value * (font_metrics.advance_of_ascii_zero + font_metrics.glyph_spacing);
|
||||||
case Type::Rem:
|
case Type::Rem:
|
||||||
return m_value * root_font_size;
|
return m_value * root_font_size;
|
||||||
case Type::Vw:
|
case Type::Vw:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue