@@ -122,6 +122,14 @@ def write_recipe(self):
122122 else :
123123 self .fvarInstancesFile = None
124124
125+ if "fontsetter" in self .config :
126+ self .fontsetterfiles = {}
127+ for font in list (self .config ["fontsetter" ].keys ()):
128+ tmp_file = NamedTemporaryFile (delete = False , mode = "w+" )
129+ self .config ["fontsetter" ][font ] = self .config ["fontsetter" ][font ]
130+ yaml .dump (self .config ["fontsetter" ][font ], tmp_file )
131+ self .fontsetterfiles [font ] = tmp_file
132+
125133 # Find variable fonts
126134 self .recipe = {}
127135 self .build_all_variables ()
@@ -277,6 +285,8 @@ def build_all_variables(self):
277285 self .build_avar2 ()
278286 if "fvarInstances" in self .config :
279287 self .build_fvar_instances ()
288+ if "fontsetter" in self .config :
289+ self .build_fontsetter ()
280290
281291 def build_spacing_axis (self ):
282292 vfs = [x for x in self .recipe .keys () if x .endswith ("ttf" )]
@@ -331,6 +341,18 @@ def build_fvar_instances(self):
331341 self .recipe [vf ].append (args )
332342 self .fvarInstancesFile .close ()
333343
344+ def build_fontsetter (self ):
345+ vfs = [x for x in self .recipe .keys () if x .endswith ("ttf" )]
346+ for vf in vfs :
347+ filename = os .path .basename (vf )
348+ if filename not in self .fontsetterfiles :
349+ continue
350+ args = {
351+ "args" : self .fontsetterfiles [filename ].name ,
352+ "postprocess" : "fontsetter" ,
353+ }
354+ self .recipe [vf ].append (args )
355+
334356 def _vtt_steps (self , target : str ):
335357 if os .path .basename (target ) in self .config .get ("vttSources" , {}):
336358 return [
@@ -430,6 +452,8 @@ def build_all_statics(self):
430452 self .build_a_static (source , instance , output = "ttf" )
431453 if self .config ["buildOTF" ]:
432454 self .build_a_static (source , instance , output = "otf" )
455+ if "fontsetter" in self .config :
456+ self .build_fontsetter ()
433457
434458 def build_a_static (self , source : File , instance : InstanceDescriptor , output ):
435459 suffix = self .config .get ("filenameSuffix" , "" )
@@ -561,25 +585,17 @@ def _italic_fixup(self):
561585 # "italic enough" to convince gftools-fix-font to apply all its italic
562586 # font fixes (post.italicAngle etc.) when we call it with
563587 # --include-source-fixes.
564- configfile = NamedTemporaryFile (delete = False , mode = "w+" )
565588 family_name = self .sources [0 ].family_name .replace (" " , "" )
566- # Since this is mad YAML, we can't use the normal YAML library
567- # to write this. We'll just write it out manually.
568- configfile .write (
569- f"""
570- OS/2->fsSelection: 129
571- head->macStyle: "|= 0x02"
572- name->setName: ["{ family_name } Italic", 25, 3, 1, 0x409]
573- name->setName: ["Italic", 2, 3, 1, 0x409]
574- name->setName: ["Italic", 17, 3, 1, 0x409]
575- """
576- )
577- configfile .close ()
578589 return [
579590 {
580- "operation" : "exec" ,
581- "exe" : "gftools-fontsetter" ,
582- "args" : "-o $out $in " + configfile .name ,
591+ "operation" : "fontsetter" ,
592+ "values" : [
593+ ["OS/2->fsSelection" , 129 ],
594+ ["head->macStyle" , "|= 0x02" ],
595+ ["name->setName" , [f"{ family_name } Italic" , 25 , 3 , 1 , 0x409 ]],
596+ ["name->setName" , ["Italic" , 2 , 3 , 1 , 0x409 ]],
597+ ["name->setName" , ["Italic" , 17 , 3 , 1 , 0x409 ]],
598+ ],
583599 },
584600 {
585601 "operation" : "fix" ,
0 commit comments