fix: lower Chinese full stop to bitmap cell baseline
This commit is contained in:
@@ -157,6 +157,16 @@ def pick_font(size):
|
||||
raise SystemExit("no CJK ttf found")
|
||||
|
||||
|
||||
def lower_full_stop(tile):
|
||||
"""Anchor the Chinese full stop at the bottom of its full-width cell."""
|
||||
bbox = tile.getchannel('A').getbbox()
|
||||
if bbox is None:
|
||||
return tile.copy()
|
||||
result = Image.new('RGBA', tile.size, (0, 0, 0, 0))
|
||||
result.paste(tile.crop(bbox), (bbox[0], tile.height - (bbox[3] - bbox[1])))
|
||||
return result
|
||||
|
||||
|
||||
def main():
|
||||
ap = argparse.ArgumentParser()
|
||||
ap.add_argument("--game", default=DEFAULT_GAME)
|
||||
@@ -211,6 +221,8 @@ def main():
|
||||
x = col * cell
|
||||
y = args.cjk_y0 + row * cell
|
||||
d.text((x, y + args.draw_dy), uni, font=font, fill=(255, 255, 255, 255))
|
||||
if uni == '\u3002':
|
||||
atlas.paste(lower_full_stop(atlas.crop((x, y, x + cell, y + cell))), (x, y))
|
||||
cells[code] = {"x": x, "y": y, "uni": uni}
|
||||
# sanity: ink must fit the cell
|
||||
bb = atlas.crop((x, y, x + cell, y + cell)).getbbox()
|
||||
|
||||
Reference in New Issue
Block a user