|
#!/usr/bin/env python3 |
|
import re |
|
|
|
IPAmjMinchoVersion = '006.01' |
|
|
|
mjn2gid = {} |
|
|
|
with open('ipamjm-name.txt') as f: |
|
for line in f: |
|
m = re.match(r'^(\d+)\tmj(\d+)$', line) |
|
if m: |
|
gid = int(m.group(1)) |
|
mjn = int(m.group(2)) |
|
mjn2gid[mjn] = gid |
|
|
|
mjns = sorted(mjn2gid.keys()) |
|
mjnr = [] |
|
for mjn in mjns: |
|
if len(mjnr) > 0 and mjnr[len(mjnr)-1][1] == mjn - 1: |
|
mjnr[len(mjnr)-1][1] = mjn |
|
else: |
|
mjnr.append([mjn, mjn]) |
|
|
|
for dir in ['h', 'v']: |
|
with open(f'ipamjmm--{dir}.zvp', 'w') as f: |
|
def outvp(s): |
|
f.write(s) |
|
f.write('\n') |
|
|
|
charht = '0.88' |
|
chardp = '0.12' |
|
|
|
if dir == 'v': |
|
charht = '0.5' |
|
chardp = '0.5' |
|
|
|
outvp( '(DIRECTION TATE)') |
|
|
|
outvp(f'(VTITLE IPAmjMincho{IPAmjMinchoVersion})') |
|
outvp( '(FAMILY IPAMJM KANJI)') |
|
outvp( '(FACE F MRR)') |
|
outvp( '(CODINGSCHEME TEX KANJI TEXT)') |
|
outvp( '(DESIGNSIZE R 10.0)') |
|
outvp( '(CHECKSUM O 0)') |
|
outvp( '(FONTDIMEN') |
|
outvp( ' (SLANT R 0.0)') |
|
outvp( ' (SPACE R 0.0)') |
|
outvp( ' (STRETCH R 0.1)') |
|
outvp( ' (SHRINK R 0.0)') |
|
outvp( ' (XHEIGHT R 1.0)') |
|
outvp( ' (QUAD R 1.0)') |
|
outvp( ' (EXTRASPACE R 0.25)') |
|
outvp( ' (EXTRASTRETCH R 0.2)') |
|
outvp( ' (EXTRASHRINK R 0.125)') |
|
outvp( ' )') |
|
|
|
outvp( '(MAPFONT D 0') |
|
outvp(f' (FONTNAME ipamjm-mzm-{dir})') |
|
outvp( ' (FONTCHECKSUM O 0)') |
|
outvp( ' (FONTAT R 1.0)') |
|
outvp( ' (FONTDSIZE R 10.0)') |
|
outvp( ' )') |
|
|
|
outvp( '(CODESPACE') |
|
for [mjn1, mjn2] in mjnr: |
|
if mjn1 == mjn2: |
|
outvp(f' X{mjn1:X}') |
|
else: |
|
outvp(f' (CTRANGE H {mjn1:X} H {mjn2:X})') |
|
outvp( ' )') |
|
|
|
outvp( '(TYPE D 0') |
|
outvp( ' (CHARWD R 1.0)') |
|
outvp(f' (CHARHT R {charht})') |
|
outvp(f' (CHARDP R {chardp})') |
|
outvp( ' (MAP)') |
|
outvp( ' )') |
|
|
|
for mjn in mjns: |
|
gid = mjn2gid[mjn] |
|
outvp(f'(CHARACTER H {mjn:X}') |
|
outvp( ' (MAP') |
|
outvp(f' (SETCHAR H {gid:X})') |
|
outvp( ' )') |
|
outvp( ' )') |