Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 59d9e62

Browse files
committed
Add logging output for ttc font conversion
1 parent 43c4d30 commit 59d9e62

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

lib/matplotlib/font_manager.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1502,7 +1502,15 @@ def read(fmt):
15021502
data = ttc_file.read(size)
15031503
return struct.unpack(fmt, data)
15041504

1505-
read(">HHI") # ttcf tag and version, ignore
1505+
tag, major, minor = read(">4sHH") # ttcf tag and version
1506+
if tag != b'ttcf':
1507+
_log.warning("Failed to read TTC file, invalid tag: %r", ttc_path)
1508+
return [], {}, {}
1509+
1510+
if major > 2:
1511+
_log.info("TTC file format version > 2, parsing might fail: %r",
1512+
ttc_path)
1513+
15061514
num_fonts = read(">I")[0] # Number of fonts
15071515
font_offsets = read(f">{num_fonts:d}I") # offsets of TTF font
15081516

@@ -1534,6 +1542,8 @@ def read(fmt):
15341542
ttc_file.seek(offset)
15351543
table_data[(offset, length)] = ttc_file.read(length)
15361544

1545+
_log.debug("Extracted %d tables for %d fonts from TTC file %r",
1546+
len(table_index), len(ttf_fonts), ttc_path)
15371547
return ttf_fonts, table_index, table_data
15381548

15391549

@@ -1570,6 +1580,7 @@ def write(file, fmt, values):
15701580
for table_coord in referenced_tables:
15711581
data = table_data[table_coord]
15721582
ttf_file.write(data)
1583+
_log.info("Created %r from TTC file", out_path)
15731584
return created_paths
15741585

15751586

0 commit comments

Comments
 (0)