• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1from fontTools.ttLib import TTFont
2from fontTools.ttLib.tables.DefaultTable import DefaultTable
3
4font_path = "myfont.ttf"
5output_path = "myfont_patched.ttf"
6
7table_tag = "DSIG"
8
9
10# Get raw table data from the source font
11
12font = TTFont(font_path)
13raw_data = font.getTableData(table_tag)
14
15
16# Do something with the raw table data
17# This example just sets an empty DSIG table.
18
19raw_data = b"\0\0\0\1\0\0\0\0"
20
21
22# Write the data back to the font
23
24# We could re-use the existing table when the source and target font are
25# identical, but let's make a new empty table to be more universal.
26table = DefaultTable(table_tag)
27table.data = raw_data
28
29# Add the new table back into the source font and save under a new name.
30font[table_tag] = table
31font.save(output_path)
32