Files
kichikuou_xsystem35-sdl2/fonts/rename_font.py
T
kichikuou 3318bebf6c fonts: Replace mincho font with IPA Mincho
Switch the bundled mincho font from a Source Han Serif JP subset to a
subset of IPA Mincho, which has monospace ASCII glyphs.

IPA Mincho's hhea ascent/descent already match its OS/2 typo metrics, so
adjust_metrics.py is no longer needed. However, IPA Mincho is distributed
under the IPA Font License v1.0, under which a subset is a "Derived
Program"; Article 3.1(4) forbids the derived font's name from containing
the licensed program's name ("IPA"). Add rename_font.py to rewrite the
name table accordingly, and replace licenses/mincho.txt with the IPA Font
License.
2026-06-23 17:40:22 +09:00

34 lines
1.1 KiB
Python

#!/usr/bin/env python3
# Rename the font's internal name records.
#
# IPA明朝 is distributed under the IPA Font License v1.0. A subset of it is a
# "Derived Program" under that license, and Article 3.1(4) forbids using or
# including the Licensed Program's name ("IPA"/"IPAMincho") as the program,
# font, or file name of the Derived Program. pyftsubset preserves the original
# name table, so rename it here to a name that does not contain "IPA".
import sys
from fontTools.ttLib import TTFont
if len(sys.argv) != 3:
print('Usage: rename_font.py infile outfile')
exit(1)
FAMILY = 'xsystem35 Mincho'
PSNAME = 'xsystem35-Mincho'
font = TTFont(sys.argv[1])
name = font['name']
# Rewrite the family / full / typographic-family / PostScript / unique-ID
# records in place, preserving each record's platform, encoding and language.
for rec in list(name.names):
if rec.nameID in (1, 4, 16):
value = FAMILY
elif rec.nameID in (3, 6):
value = PSNAME
else:
continue
name.setName(value, rec.nameID, rec.platformID, rec.platEncID, rec.langID)
font.save(sys.argv[2])