From 4a3ca9069d9eeacfcd4e188118866c349b8240a8 Mon Sep 17 00:00:00 2001 From: Fini Jastrow Date: Fri, 10 Mar 2023 10:43:55 +0100 Subject: [PATCH] font-patcher: Fix crash with older fontforge [why] If a font has references in glyphs that we want to add to the essential set of glyphs, and fontforge is old (i.e. 2020*) the patcher crashes. [how] The fontforge function glyph.references returns a three element tuple in current fontforge (i.e. 20230101). But older versions skip the selection bit and return only tuples of two. As we use only the first tuple element we do not care about the 2nd and possible 3rd element(s) and just thrash them. Fixes: #1142 Signed-off-by: Fini Jastrow --- font-patcher | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/font-patcher b/font-patcher index d81f66c58..61d215fdb 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.11" +script_version = "3.5.12" version = "2.3.3" projectName = "Nerd Fonts" @@ -983,9 +983,10 @@ class font_patcher: 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. + # a glyph name, a transformation matrix, and (depending on ff version) whether the + # reference is currently selected. references = self.sourceFont[unicode].references - for refcode in [ self.sourceFont[n].unicode for n, m, s in references ]: + for refcode in [ self.sourceFont[n].unicode for n, *_ in references ]: # tuple of 2 or 3 depending on ff version if refcode not in self.essential and refcode >= 0: self.add_glyphrefs_to_essential(refcode)