Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instructionCompiler: don't log about .notdef missing #780

Merged
merged 1 commit into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading