From 9661684f112dfdd9c4554a2cdf8dd0e5f98ecbde Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Sun, 20 Aug 2023 17:26:42 +0100 Subject: [PATCH] add 'emum' prefix to class/glyph and glyph/class exceptions that's what ufo2ft kernFeatureWriter does -- fixes the aV kerning in Oswald and similar --- fontbe/src/features.rs | 15 ++++++++++++++- fontir/src/ir.rs | 12 ++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/fontbe/src/features.rs b/fontbe/src/features.rs index ce903008..54566b36 100644 --- a/fontbe/src/features.rs +++ b/fontbe/src/features.rs @@ -300,6 +300,15 @@ fn push_identifier(fea: &mut String, identifier: &KernParticipant) { } } +#[inline] +fn enumerated(kp1: &KernParticipant, kp2: &KernParticipant) -> bool { + // Glyph to class or class to glyph pairs are interpreted as 'class exceptions' to class pairs + // and are thus prefixed with 'enum' keyword so they will be enumerated as specific glyph-glyph pairs. + // http://adobe-type-tools.github.io/afdko/OpenTypeFeatureFileSpecification.html#6bii-enumerating-pairs + // https://github.com/googlefonts/ufo2ft/blob/b3895a9/Lib/ufo2ft/featureWriters/kernFeatureWriter.py#L360 + kp1.is_group() ^ kp2.is_group() +} + /// Create a single variable fea describing the kerning for the entire variation space. /// /// No merge baby! - [context](https://github.com/fonttools/fonttools/issues/3168#issuecomment-1608787520) @@ -362,7 +371,11 @@ fn create_kerning_fea(axes: &HashMap, kerning: &Kerning) -> Result bool { + matches!(self, KernParticipant::Glyph(_)) + } + + #[inline] + pub fn is_group(&self) -> bool { + matches!(self, KernParticipant::Group(_)) + } +} + impl StaticMetadata { pub fn new( units_per_em: u16,