From 81ca98d5db1ac7ff61ad4e4f3fa9249b4287120b Mon Sep 17 00:00:00 2001 From: Stewart Connor Date: Fri, 21 Mar 2025 17:12:38 +1100 Subject: [PATCH] more explicit about setting features --- src/shape.rs | 48 ++++++++++++++++++++---------------------------- 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/shape.rs b/src/shape.rs index 31a510c..b7ec113 100644 --- a/src/shape.rs +++ b/src/shape.rs @@ -144,37 +144,29 @@ fn shape_fallback( let mut features = Vec::new(); - if attrs.font_features.kerning { - features.push(rustybuzz::Feature::new( - rustybuzz::ttf_parser::Tag::from_bytes(b"kern"), - 1, - 0..usize::MAX, - )); - } + features.push(rustybuzz::Feature::new( + rustybuzz::ttf_parser::Tag::from_bytes(b"kern"), + if attrs.font_features.kerning { 1 } else { 0 }, + 0..usize::MAX, + )); - if attrs.font_features.standard_ligatures { - features.push(rustybuzz::Feature::new( - rustybuzz::ttf_parser::Tag::from_bytes(b"liga"), - 1, - 0..usize::MAX, - )); - } + features.push(rustybuzz::Feature::new( + rustybuzz::ttf_parser::Tag::from_bytes(b"liga"), + if attrs.font_features.standard_ligatures { 1 } else { 0 }, + 0..usize::MAX, + )); - if attrs.font_features.contextual_ligatures { - features.push(rustybuzz::Feature::new( - rustybuzz::ttf_parser::Tag::from_bytes(b"clig"), - 1, - 0..usize::MAX, - )); - } + features.push(rustybuzz::Feature::new( + rustybuzz::ttf_parser::Tag::from_bytes(b"clig"), + if attrs.font_features.contextual_ligatures { 1 } else { 0 }, + 0..usize::MAX, + )); - if attrs.font_features.discretionary_ligatures { - features.push(rustybuzz::Feature::new( - rustybuzz::ttf_parser::Tag::from_bytes(b"dlig"), - 1, - 0..usize::MAX, - )); - } + features.push(rustybuzz::Feature::new( + rustybuzz::ttf_parser::Tag::from_bytes(b"dlig"), + if attrs.font_features.discretionary_ligatures { 1 } else { 0 }, + 0..usize::MAX, + )); let shape_plan = rustybuzz::ShapePlan::new( font.rustybuzz(),