#!/usr/bin/env python # coding=utf-8 # # Copyright © 2011 Nick Bowler # # Generates new M+ fonts with the CJK characters enlarged, based on the IPAG # versions. This gives better proportions relative to DejaVu Sans Mono in # rxvt-unicode. # # Run this script in a directory containing the M+ fonts. The new fonts will # be called M+1T+IPAG and M+2T+IPAG. # # License WTFPL2: Do What The Fuck You Want To Public License, version 2. # This is free software: you are free to do what the fuck you want to. # There is NO WARRANTY, to the extent permitted by law. import fontforge as ff import psMat import re families = [ "M+1M+IPAG", "M+2M+IPAG" ] scripts = [ "hani", "kana" ] for family in families: font = ff.open(family + ".ttf") font.familyname = re.sub(r"(\d)M", r"\1T", font.familyname) font.fontname = font.familyname + "-Regular" font.fullname = font.familyname + " Regular" for glyph in font.selection.all().byGlyphs: for s in scripts: if (glyph.script == s): glyph.transform(psMat.scale(1.35)) print "Generating " + font.familyname + ".ttf" font.generate(font.familyname + ".ttf") font.close()