Keep zero tracking ligatures enabled

This commit is contained in:
SGavrl
2026-07-30 22:51:49 +00:00
parent 474c2e97e0
commit caaf02e11c
2 changed files with 10 additions and 4 deletions

View File

@@ -1000,7 +1000,10 @@ impl SpanAttrs {
if self.letter_spacing.is_finite() && self.letter_spacing != 0.0 {
a = a.letter_spacing(self.letter_spacing / self.font_size.max(1.0));
}
if self.letter_spacing_non_normal {
if self.letter_spacing_non_normal
&& self.letter_spacing.is_finite()
&& self.letter_spacing != 0.0
{
let mut features = FontFeatures::new();
features
.disable(FeatureTag::STANDARD_LIGATURES)
@@ -1926,6 +1929,10 @@ mod tests {
assert!(attrs.font_features.features.iter().any(|feature| {
feature.tag == FeatureTag::CONTEXTUAL_LIGATURES && feature.value == 0
}));
let mut zero = span;
zero.letter_spacing = 0.0;
assert!(zero.to_attrs().font_features.features.is_empty());
}
fn variable_font_fixture() -> Vec<u8> {

View File

@@ -363,9 +363,8 @@ pub struct LayoutStyle {
/// Deferred functional `letter-spacing` (`calc()`, `min()`, `clamp()`).
pub letter_spacing_expression: Option<String>,
/// Whether the computed value came from a non-`normal` declaration.
/// CSS suppresses optional ligatures for every non-normal value, including
/// an explicit zero; keeping this provenance avoids conflating it with the
/// `normal` initial value.
/// Keeping this provenance distinguishes an explicit zero from the
/// `normal` initial value while resolving the inherited property.
pub letter_spacing_non_normal: Option<bool>,
/// Specified CSS font weight during cascade (`1..1000`, `bolder`, or
/// `lighter`), normalized to its numeric computed value by the inheritance