Skip to content

The headless browser for AI agents and web scraping

Keep zero tracking ligatures enabled

SGavrlcaaf02e11c7a
diff --git a/crates/obscura-render/src/inline.rs b/crates/obscura-render/src/inline.rs
index 049e7984..d2c0bd50 100644
--- a/crates/obscura-render/src/inline.rs
+++ b/crates/obscura-render/src/inline.rs
@@ -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> {
diff --git a/crates/obscura-render/src/lib.rs b/crates/obscura-render/src/lib.rs
index 86657534..c5792616 100644
--- a/crates/obscura-render/src/lib.rs
+++ b/crates/obscura-render/src/lib.rs
@@ -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