Skip to content

Commit

Permalink
Merge pull request #780 from googlefonts/instrcomp-logging-noise
Browse files Browse the repository at this point in the history
instructionCompiler: don't log about .notdef missing
  • Loading branch information
anthrotype authored Sep 8, 2023
2 parents b3895a9 + d3613d8 commit fb5031f
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 fb5031f

Please sign in to comment.