mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
feat: Support font-relative ch
and ic
units (#32171)
* feat: Support font-relative `ch` and `ic` units After #31966, which made it possible for the first time to resolve font-relative CSS units, this change adds support for the `ch` and `ic` units. One difference with the `ex` unit that was added in that PR is that these units must reflect the advance width of a character (the zero digit in the case of `ch`, and the CJK water radical for `ic`) as it would be rendered by the current font group. This means that the size of these units don't only depend on the first available font, in the case where that font does not contain a glyph for that character. This is implemented by adding the advance width for these two characters as optional fields of `FontMetrics`, so the advance width computation happens in advance. Then, when the font metrics are queried as part of unit resolution, the font group is searched for the first font containing that character. This change only implements support for these units in upright typesetting modes, since Servo does not yet have support for vertical writing modes. This means that many of the WPT tests that test for the behavior of these units with vertical writing modes do not pass. This change also makes a number of WPT tests pass, which relied on the `ch` and `ic` units. It, however, also makes the test `/css/css-text/white-space/text-wrap-balance-overflow-002.html` fail, since it tests `text-wrap: balance`, which Servo does not yet implement, and it was only previously passing by chance due to the previous behavior of these units. * Revert Python 3.10-related changes to wss * Fix formatting * Remove test expectation
This commit is contained in:
parent
928214518c
commit
8ec5344f70
68 changed files with 66 additions and 435 deletions
|
@ -131,6 +131,8 @@ pub struct FontMetrics {
|
|||
pub max_advance: Au,
|
||||
pub average_advance: Au,
|
||||
pub line_gap: Au,
|
||||
pub zero_horizontal_advance: Option<Au>,
|
||||
pub ic_horizontal_advance: Option<Au>,
|
||||
}
|
||||
|
||||
impl FontMetrics {
|
||||
|
@ -150,6 +152,8 @@ impl FontMetrics {
|
|||
max_advance: Au(0),
|
||||
average_advance: Au(0),
|
||||
line_gap: Au(0),
|
||||
zero_horizontal_advance: None,
|
||||
ic_horizontal_advance: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue