Skip to content

Instantly share code, notes, and snippets.

@metasta
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metasta/9278586 to your computer and use it in GitHub Desktop.
Save metasta/9278586 to your computer and use it in GitHub Desktop.
IPAmj明朝のMJ文字図形名とグリフ名との対応表のつくりかた

IPAmj明朝の MJ文字図形名とグリフ名との対応表をつくる

「IPAmj明朝」に収録された各文字の MJ文字図形名と、ipamjm.ttf ファイル内でその文字を指すグリフ名との対応表。 AFDKO の mergeFonts で MJ文字図形名が利用できないことに困り作成した。

こんな対応表です

.null	g1
CR	g2
aj1	space
aj2	exclam
aj3	quotedbl
aj4	numbersign
aj5	dollar
...
mj030150	uni9F98
mj030151	g30997
mj030154	g30998
mj030155	uni9F9C
mj030156	g31000
...
mj068059	uni2FF7
mj068060	uni2FF8
mj068061	uni2FF9
mj068062	uni2FFA
mj068063	uni2FFB

この対応表そのものを gist で公開する案はファイルサイズがでかすぎて断念した。

つくりかた

0. 準備物

1. gid-mj.txt を作成

ipamjm.ttf の GID と MJ文字図形名との対応表 gid-mj.txt を作成。 'post' テーブルから必要な情報を抜き出し整理。

% spot -t post ipamjm.ttf | tail -n 1 | tr " " "\n" | awk -F'[<>]' '!/^$/{print NR "\t" $2}' > gid-mj.txt

2. gid-gname.txt を作成

ipamjm.ttf の GID とグリフ名との対応表 gid-gname.txt を作成。 グリフ名の取得方法がわからないので pdf を awk で無理やり処理。

% tx -pdf ipamjm.ttf | awk -f pdf2gmap.awk > gid-gname.txt

3. mj-gname.txt を作成

上で作成した 2 つの対応表を結合して完成。

% join -t '	' gid-mj.txt gid-gname.txt | cut -f 2,3 > mj-gname.txt

更新履歴

2014.02.28

  • 公開
#!/bin/awk -f
BEGIN {
FS="[,\(\)]"
}
NR > 60 && /\(/ {
if ( $0 ~ /^\([0-9]+\)'$/ ) {
print ""
}
else {
printf $2 "\t"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment