cjk baseline fix

This commit is contained in:
minjaesong
2026-02-27 05:25:25 +09:00
parent 3e3e20e5d4
commit e3a3079fb2
2 changed files with 7 additions and 0 deletions

Binary file not shown.

View File

@@ -246,6 +246,8 @@ def build_font(assets_dir, output_path, no_bitmap=False, no_features=False):
pen.closePath() pen.closePath()
charstrings[".notdef"] = pen.getCharString() charstrings[".notdef"] = pen.getCharString()
_unihan_cps = set(SC.CODE_RANGE[SC.SHEET_UNIHAN])
traced_count = 0 traced_count = 0
for cp in sorted_cps: for cp in sorted_cps:
g = glyphs[cp] g = glyphs[cp]
@@ -289,6 +291,11 @@ def build_font(assets_dir, output_path, no_bitmap=False, no_features=False):
else: else:
y_offset = -g.props.nudge_y * SCALE y_offset = -g.props.nudge_y * SCALE
# Unihan glyphs are 16px tall in a 20px cell; the bitmap engine
# centres them vertically with offsetUnihan = (H - H_UNIHAN) / 2.
if cp in _unihan_cps:
y_offset -= ((SC.H - SC.H_UNIHAN) // 2) * SCALE
contours = trace_bitmap(g.bitmap, g.props.width) contours = trace_bitmap(g.bitmap, g.props.width)
pen = T2CharStringPen(advance, None) pen = T2CharStringPen(advance, None)