mirror of
https://github.com/kichikuou/xsystem35-sdl2.git
synced 2026-09-22 22:48:08 +03:00
This rewrites the `ascent` and `descent` values in the `hhea` table of the font, so that the height of the surface returned by `TTF_Render*` will be the same as the `ptsize` passed to `TTF_OpenFont`. (MTLc3m.ttf already have this property.) This fixes the text rendering issue in Tsumamigui2 and Yoru ga Kuru.
23 lines
559 B
Python
Executable File
23 lines
559 B
Python
Executable File
#!/usr/bin/env python3
|
|
import sys
|
|
from fontTools.ttLib import TTFont
|
|
|
|
if len(sys.argv) != 3:
|
|
print('Usage: adjust_metrics.py infile outfile')
|
|
exit(1)
|
|
|
|
font = TTFont(sys.argv[1])
|
|
|
|
hhea = font['hhea']
|
|
os2 = font['OS/2']
|
|
|
|
if hhea.ascent != os2.sTypoAscender:
|
|
print(f'Changing hhea.ascent from {hhea.ascent} to {os2.sTypoAscender}')
|
|
hhea.ascent = os2.sTypoAscender
|
|
|
|
if hhea.descent != os2.sTypoDescender:
|
|
print(f'Changing hhea.descent from {hhea.descent} to {os2.sTypoDescender}')
|
|
hhea.descent = os2.sTypoDescender
|
|
|
|
font.save(sys.argv[2])
|