diff --git a/font-patcher b/font-patcher index a24e706e6..03595822d 100755 --- a/font-patcher +++ b/font-patcher @@ -6,7 +6,7 @@ from __future__ import absolute_import, print_function, unicode_literals # Change the script version when you edit this script: -script_version = "3.5.0" +script_version = "3.5.1" version = "2.3.0" projectName = "Nerd Fonts" @@ -915,17 +915,24 @@ class font_patcher: def add_glyphrefs_to_essential(self, unicode): self.essential.add(unicode) # According to fontforge spec, altuni is either None or a tuple of tuples - if self.sourceFont[unicode].altuni is not None: - for r in self.sourceFont[unicode].altuni: + # Those tuples contained in altuni are of the following "format": + # (unicode-value, variation-selector, reserved-field) + altuni = self.sourceFont[unicode].altuni + if altuni is not None: + for altcode in [ v for v, s, r in altuni if v >= 0 ]: # If alternate unicode already exists in self.essential, # that means it has gone through this function before. # Therefore we skip it to avoid infinite loop. # A unicode value of -1 basically means unused and is also worth skipping. - if r[0] not in self.essential and r[0] >= 0: - self.add_glyphrefs_to_essential(r[0]) - for r in self.sourceFont[unicode].references: - if self.sourceFont[r[0]].unicode not in self.essential and self.sourceFont[r[0]].unicode >= 0: - self.add_glyphrefs_to_essential(self.sourceFont[r[0]].unicode) + if altcode not in self.essential: + self.add_glyphrefs_to_essential(altcode) + # From fontforge documentation: + # glyph.references return a tuple of tuples containing, for each reference in foreground, + # a glyph name, a transformation matrix, and whether the reference is currently selected. + references = self.sourceFont[unicode].references + for refcode in [ self.sourceFont[n].unicode for n, m, s in references ]: + if refcode not in self.essential and refcode >= 0: + self.add_glyphrefs_to_essential(refcode) def get_essential_references(self): """Find glyphs that are needed for the basic glyphs"""