Skip to content

Instantly share code, notes, and snippets.

@fdiary
Last active July 29, 2019 14:51
Show Gist options
  • Save fdiary/693c045f183aac50aa7320440e7bff33 to your computer and use it in GitHub Desktop.
Save fdiary/693c045f183aac50aa7320440e7bff33 to your computer and use it in GitHub Desktop.
Fontforge script to generate a vertical font : all glyphs are rotated 90 degrees anticlockwise
#!/usr/bin/fontforge
#
# Original source code by nixeneko
# https://nixeneko.hatenadiary.org/entry/20100724/1279982449
#
# Usage:
# fontforge -script generate_vertical_font.pe original_font.ttf
Open($1)
SelectWorthOutputting()
#縦書き字形に変更
ApplySubstitution("*","*","vrt2")
ApplySubstitution("*","*","vert")
#グリフ幅が全角のものを左へ90度回転
foreach
if (GlyphInfo('Width') == $em)
Rotate(90, $em/2, $em/2-$descent)
endif
endloop
#極大点の追加、座標値を整数に
AddExtrema()
RoundToInt()
#フォント名の先頭にVertをつける
SetFontNames("Vert-"+$fontname, $familyname, "Vert "+$fullname)
#カレントディレクトリに出力
Generate("Vert-"+$1:t:r+".ttf")
@fdiary
Copy link
Author

fdiary commented Jul 29, 2019

Revision 2: rotate all glyphs having the same width as the height, instead of hardcoded code ranges.

Revision 3: remove copying U+ff5e (fullwidth tilde) to U+301c (wave dash), that is out of scope of this script.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment