Skip to content

Instantly share code, notes, and snippets.

@itiut
Last active August 29, 2015 14:13
Show Gist options
  • Save itiut/b988b8f5aeff690cbf83 to your computer and use it in GitHub Desktop.
Save itiut/b988b8f5aeff690cbf83 to your computer and use it in GitHub Desktop.
IPAGothicのcurved quote (U+2018, U+2019, U+201C, U+201D)の幅を半角にする
import fontforge
import os
import psMat
import shutil
import sys
def narrow_quotation_width(path):
f = fontforge.open(path)
# left quotation marks
for c in (0x2018, 0x201C):
g = f[c]
if g.width == 1000:
g.transform(psMat.translate(-500, 0))
# right quotation marks
for c in (0x2019, 0x201D):
g = f[c]
if g.width == 1000:
g.width = 500
f.save(path)
if __name__ == '__main__':
if len(sys.argv) < 2:
sys.exit('Usage: %s [font_file]...' % sys.argv[0])
for path in sys.argv[1:]:
dst = path + '.orig'
print('Copy: %s -> %s' % (path, dst))
shutil.copy(path, dst)
print('Modify: %s' % path)
narrow_quotation_width(path)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment