Skip to content

Commit

Permalink
instructionCompiler: don't log about .notdef missing
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
anthrotype committed Sep 8, 2023
1 parent b3895a9 commit d3613d8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
12 changes: 7 additions & 5 deletions Lib/ufo2ft/instructionCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
9 changes: 8 additions & 1 deletion tests/instructionCompiler_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d3613d8

Please sign in to comment.