@@ -1502,7 +1502,15 @@ def read(fmt):
1502
1502
data = ttc_file .read (size )
1503
1503
return struct .unpack (fmt , data )
1504
1504
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
+
1506
1514
num_fonts = read (">I" )[0 ] # Number of fonts
1507
1515
font_offsets = read (f">{ num_fonts :d} I" ) # offsets of TTF font
1508
1516
@@ -1534,6 +1542,8 @@ def read(fmt):
1534
1542
ttc_file .seek (offset )
1535
1543
table_data [(offset , length )] = ttc_file .read (length )
1536
1544
1545
+ _log .debug ("Extracted %d tables for %d fonts from TTC file %r" ,
1546
+ len (table_index ), len (ttf_fonts ), ttc_path )
1537
1547
return ttf_fonts , table_index , table_data
1538
1548
1539
1549
@@ -1570,6 +1580,7 @@ def write(file, fmt, values):
1570
1580
for table_coord in referenced_tables :
1571
1581
data = table_data [table_coord ]
1572
1582
ttf_file .write (data )
1583
+ _log .info ("Created %r from TTC file" , out_path )
1573
1584
return created_paths
1574
1585
1575
1586
0 commit comments