diff --git a/Lib/fontTools/ttLib/tables/otBase.py b/Lib/fontTools/ttLib/tables/otBase.py index c9e167918..d30892f32 100644 --- a/Lib/fontTools/ttLib/tables/otBase.py +++ b/Lib/fontTools/ttLib/tables/otBase.py @@ -96,6 +96,7 @@ class BaseTTXConverter(DefaultTable): self.tableTag, ) + hb_first_error_logged = False while True: try: writer = OTTableWriter(tableTag=self.tableTag) @@ -109,19 +110,22 @@ class BaseTTXConverter(DefaultTable): log.debug("serializing '%s' with hb.repack", self.tableTag) return writer.getAllDataUsingHarfbuzz() except (ValueError, MemoryError, hb.RepackerError) as e: - if use_hb_repack is None: + # Only log hb repacker errors the first time they occur in + # the offset-overflow resolution loop, they are just noisy. + # Maybe we can revisit this if/when uharfbuzz actually gives + # us more info as to why hb.repack failed... + if not hb_first_error_logged: error_msg = f"{type(e).__name__}" if str(e) != "": error_msg += f": {e}" - log.error( + log.warning( "hb.repack failed to serialize '%s', reverting to " "pure-python serializer; the error message was: %s", self.tableTag, error_msg, ) - return writer.getAllData(remove_duplicate=False) - # let the error propagate if USE_HARFBUZZ_REPACKER is True - raise + hb_first_error_logged = True + return writer.getAllData(remove_duplicate=False) return writer.getAllData() except OTLOffsetOverflowError as e: diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index 07c47b515..facafb2a7 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -847,18 +847,11 @@ class SubsetTest: args.append("--no-harfbuzz-repacker") # elif enabled is None: ... is the default - if enabled is True: - if not installed: - # raise if enabled but not installed - with pytest.raises(ImportError, match="uharfbuzz"): - subset.main(args) - return - - elif not ok: - # raise if enabled but fails - with pytest.raises(hb.RepackerError, match="mocking"): - subset.main(args) - return + if enabled is True and not installed: + # raise if enabled but not installed + with pytest.raises(ImportError, match="uharfbuzz"): + subset.main(args) + return with caplog.at_level(logging.DEBUG, "fontTools.ttLib.tables.otBase"): subset.main(args)