@@ -500,10 +500,7 @@ impl KerningGatherWork {
500
500
let mut lookups_by_script = BTreeMap :: new ( ) ;
501
501
let mut ordered_lookups = Vec :: new ( ) ;
502
502
503
- let fea_langs_by_script: BTreeMap < _ , _ > = get_script_language_systems ( ast)
504
- . into_values ( )
505
- . flat_map ( |x| x. into_iter ( ) )
506
- . collect ( ) ;
503
+ let fea_langs_by_script = get_fea_language_systems ( ast) ;
507
504
508
505
// in python this part happens earlier, as part of splitKerning.
509
506
for ( scripts, lookups) in lookups {
@@ -1017,10 +1014,9 @@ fn scripts_for_chars(glyphs: &impl CharMap) -> HashSet<UnicodeShortName> {
1017
1014
. collect ( )
1018
1015
}
1019
1016
1020
- // <https://github.com/googlefonts/ufo2ft/blob/cea60d71dfcf0b1c0fa4e133e/Lib/ufo2ft/featureWriters/ast.py#L23>
1021
- /// returns a map of unicode script names to (ot_script, `[ot_lang]`)
1022
- fn get_script_language_systems ( ast : & ParseTree ) -> HashMap < UnicodeShortName , Vec < ( Tag , Vec < Tag > ) > > {
1023
- let mut languages_by_script = HashMap :: new ( ) ;
1017
+ /// returns a map of opentype script: [opentype lang], for the languagesystems in FEA
1018
+ fn get_fea_language_systems ( ast : & ParseTree ) -> BTreeMap < Tag , Vec < Tag > > {
1019
+ let mut languages_by_script = BTreeMap :: new ( ) ;
1024
1020
for langsys in ast
1025
1021
. typed_root ( )
1026
1022
. statements ( )
@@ -1031,7 +1027,13 @@ fn get_script_language_systems(ast: &ParseTree) -> HashMap<UnicodeShortName, Vec
1031
1027
. or_insert ( Vec :: new ( ) )
1032
1028
. push ( langsys. language ( ) . to_raw ( ) )
1033
1029
}
1030
+ languages_by_script
1031
+ }
1034
1032
1033
+ // <https://github.com/googlefonts/ufo2ft/blob/cea60d71dfcf0b1c0fa4e133e/Lib/ufo2ft/featureWriters/ast.py#L23>
1034
+ /// returns a map of unicode script names to (ot_script, `[ot_lang]`)
1035
+ fn get_script_language_systems ( ast : & ParseTree ) -> HashMap < UnicodeShortName , Vec < ( Tag , Vec < Tag > ) > > {
1036
+ let languages_by_script = get_fea_language_systems ( ast) ;
1035
1037
let mut unic_script_to_languages = HashMap :: new ( ) ;
1036
1038
for ( ot_script, langs) in languages_by_script {
1037
1039
let Some ( unicode_script) = super :: properties:: ot_tag_to_script ( ot_script) else {
@@ -1329,4 +1331,26 @@ mod tests {
1329
1331
assert_eq ! ( kerns. get( & glyph_glyph) . map( |x| x. 0 ) , Some ( 10.0f32 ) ) ;
1330
1332
}
1331
1333
}
1334
+
1335
+ #[ test]
1336
+ // https://github.com/googlefonts/fontc/issues/1121
1337
+ fn default_language_systems ( ) {
1338
+ let fea = "\
1339
+ languagesystem DFLT dflt;
1340
+ languagesystem DFLT MAH;" ;
1341
+ let ( ast, errs) = fea_rs:: parse:: parse_string ( fea) ;
1342
+ assert ! ( errs. is_empty( ) ) ;
1343
+ // make one dummy lookup
1344
+ let script = BTreeSet :: from ( [ UnicodeShortName :: from_bytes_lossy ( b"Latn" ) ] ) ;
1345
+ let lookup = vec ! [ PendingLookup :: new(
1346
+ vec![ PairPosBuilder :: default ( ) ] ,
1347
+ Default :: default ( ) ,
1348
+ None ,
1349
+ ) ] ;
1350
+ let lookups = BTreeMap :: from ( [ ( script, lookup) ] ) ;
1351
+ let ( _lookup, features) = KerningGatherWork . assign_lookups_to_scripts ( lookups, & ast, KERN ) ;
1352
+ let dflt_mah = FeatureKey :: new ( KERN , Tag :: new ( b"MAH " ) , DFLT_SCRIPT ) ;
1353
+ // ensure that the feature was registered for the DFLT/Mah language system
1354
+ assert ! ( features. contains_key( & dflt_mah) ) ;
1355
+ }
1332
1356
}
0 commit comments