import fontforge from color import isJGlyphP, isJGlyph if len(sys.argv) < 3: print "Usage: %s source-file target-file" % sys.argv[0] quit(1) print "Loading base file %s..." % sys.argv[1] BaseFont = fontforge.open(sys.argv[1]) BaseFont.selection.none() for glyph in BaseFont.glyphs(): if glyph.isWorthOutputting(): if isJGlyphP(glyph): glyph.unlinkRef() if isJGlyph(glyph): BaseFont.selection.select(("more",), glyph) WidthE = BaseFont["ahiragana"].width WidthV = BaseFont["ahiragana"].vwidth print "Rescaling..." BaseFont.transform(psMat.scale(1.2)) BaseFont.transform(psMat.translate(0, -50)) WidthJ = BaseFont["ahiragana"].width WidthA = BaseFont["A"].width BaseFont.selection.none() for glyph in BaseFont.glyphs(): if glyph.isWorthOutputting():
lastX = point.x; lastY = point.y if hypot(firstX - lastX, firstY - lastY) > 3.0: newContour += tmpContour newContour.closed = True newLayer += newContour glyph.foreground = newLayer if (len(sys.argv) < 3): print 'Usage: %s source-file target-file' % sys.argv[0] quit(1) print 'Loading base file %s...' % sys.argv[1] BaseFont = fontforge.open(sys.argv[1]) for glyph in BaseFont.glyphs(): if glyph.isWorthOutputting(): if isJGlyphP(glyph): glyph.unlinkRef() print 'Changing weight...' for glyph in BaseFont.glyphs(): if glyph.isWorthOutputting(): if isJGlyph(glyph): glyph.transform(psMat.scale(2.0)) glyph.stroke("circular", 10, "butt", "miter", ("removeexternal", "cleanup")) fixContour(glyph) glyph.transform(psMat.scale(0.5)) print 'Saving target file %s...' % sys.argv[2] BaseFont.save(sys.argv[2])