From d3613d8e578bfdcbdab45acf63b44c0d6d9e91ce Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 8 Sep 2023 18:00:21 +0100 Subject: [PATCH] instructionCompiler: don't log about .notdef missing this is just noise and may be confusing for the user. .notdef glyph is often automatically generated by ufo2ft, in which case of course it's missing from the source UFOs, there's no need for instructionCompiler to add noise to the already busy fontmake output... --- Lib/ufo2ft/instructionCompiler.py | 12 +++++++----- tests/instructionCompiler_test.py | 9 ++++++++- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Lib/ufo2ft/instructionCompiler.py b/Lib/ufo2ft/instructionCompiler.py index 32ed8fb48..86887e3f1 100644 --- a/Lib/ufo2ft/instructionCompiler.py +++ b/Lib/ufo2ft/instructionCompiler.py @@ -109,11 +109,13 @@ def compileGlyphInstructions(self, ttGlyph, name) -> None: """Compile the glyph instructions from the UFO glyph `name` to bytecode and add it to `ttGlyph`.""" if name not in self.ufo: - # Skip glyphs that are not in the UFO, e.g. '.notdef' - logger.info( - f"Skipping compilation of instructions for glyph '{name}' because it " - "is not in the input UFO." - ) + # Skip glyphs that are not in the UFO; no need to inform about '.notdef' + # since that glyph is often auto-generated + if name != ".notdef": + logger.info( + f"Skipping compilation of instructions for glyph '{name}' because it " + "is not in the input UFO." + ) return glyph = self.ufo[name] diff --git a/tests/instructionCompiler_test.py b/tests/instructionCompiler_test.py index 00a2c75d9..87d2d66ac 100644 --- a/tests/instructionCompiler_test.py +++ b/tests/instructionCompiler_test.py @@ -281,11 +281,18 @@ def test_compile_program(self, quadufo): def test_compileGlyphInstructions_missing_glyph(self, caplog): # The method logs an info when trying to compile a glyph which is - # missing in the UFO, e.g. '.notdef' + # missing in the UFO ic = InstructionCompiler(dict(), None) with caplog.at_level(logging.INFO, logger="ufo2ft.instructionCompiler"): ic.compileGlyphInstructions(None, "A") assert "Skipping compilation of instructions for glyph 'A'" in caplog.text + # ... except for '.notdef' which is frequently generated + with caplog.at_level(logging.INFO, logger="ufo2ft.instructionCompiler"): + ic.compileGlyphInstructions(None, ".notdef") + assert ( + "Skipping compilation of instructions for glyph '.notdef'" + not in caplog.text + ) # _compile_tt_glyph_program