return result
-def make_font(fn, size, autohinter, margin, padding):
+def make_font(fn, size, ch_range, autohinter, margin, padding):
import maketex
import os
cmd = "ttf2png \"%s\" -o makefont-tmp.png -d makefont-tmp.def -t -p -s %d -m %d -n %d"%(fn, size, margin, padding)
+ if ch_range:
+ cmd += " -r %d,%d"%ch_range
if autohinter:
cmd += " -a"
if os.system(cmd):
return result
+def parse_range(s):
+ return tuple(map(int, s.split(',', 1)))
+
if __name__=="__main__":
import sys
import argparse
parser.add_argument("-a", "--autohinter", action="store_const", const=True, default=False, help="Force autohinter")
parser.add_argument("-m", "--margin", default=0, type=int, metavar="NUM", help="Margin around image edge in pixels")
parser.add_argument("-n", "--padding", default=1, type=int, metavar="NUM", help="Padding between glyphs in pixels")
+ parser.add_argument("-r", "--range", type=parse_range, metavar="START,END", help="Range of code points to include")
parser.add_argument("ttf", metavar="font.ttf", help="TrueType file to read")
parser.add_argument("outfile", help="MspGL font file to write")
args = parser.parse_args()
out = file(args.outfile, "w")
- out.write(make_font(args.ttf, args.size, args.autohinter, args.margin, args.padding))
+ out.write(make_font(args.ttf, args.size, args.range, args.autohinter, args.margin, args.padding))