def dumpFontForgeAPI(testFontPath, printModule=False, printFont=False, printGlyph=False, printLayer=False, printContour=False, printPoint=False): def printAPI(item, name): print print "-"*80 print "API of", item names = dir(item) names.sort() print if printAPI: for n in names: print print "%s.%s"%(name, n) try: print getattr(item, n).__doc__ except: print "# error showing", n # module if printModule: print "module file:", fontforge.__file__ print "version:", fontforge.version() print "module doc:", fontforge.__doc__ print "has User Interface:", fontforge.hasUserInterface() print "has Spiro:", fontforge.hasSpiro() printAPI(fontforge, "fontforge") # font fontObj = fontforge.open(testFontPath) if printFont: printAPI(fontObj, "font") # glyph glyphObj = fontObj["A"] if printGlyph: printAPI(glyphObj, "glyph") # layer layerObj = glyphObj.foreground if printLayer: printAPI(layerObj, "layer") # contour contourObj = layerObj[0] if printContour: printAPI(contourObj, "contour") # point if printPoint: pointObj = contourObj[0] printAPI(pointObj, "point") # other objects penObj = glyphObj.glyphPen() printAPI(penObj, "glyphPen")
#Needs: fonts/Ambrosia.sfd #Test the fontforge module (but not its types) import sys, fontforge foo = fontforge.getPrefs("DetectDiagonalStems") fontforge.setPrefs("DetectDiagonalStems",~foo) fontforge.loadPrefs() # fontforge.savePrefs() fontforge.defaultOtherSubrs() # fontforge.readOtherSubrsFile() foo = fontforge.hasSpiro() # fontforge.loadEncodingFile() # fontforge.loadNamelist() # fontforge.loadNamelistDir() # fontforge.preloadCidmap() fontforge.printSetup("lpr") if (fontforge.unicodeFromName("A")!=65) or (fontforge.unicodeFromName("uni030D")!=0x30D): raise ValueError("Wrong return from unicodeFromName") foo = fontforge.version() ambrosia = sys.argv[1] fonts = fontforge.fonts() if ( len(fonts)!=0 ) : raise ValueError("Wrong return from fontforge.fonts")
def dumpFontForgeAPI(testFontPath, printModule=False, printFont=False, printGlyph=False, printLayer=False, printContour=False, printPoint=False): def printAPI(item, name): print print "-" * 80 print "API of", item names = dir(item) names.sort() print if printAPI: for n in names: print print "%s.%s" % (name, n) try: print getattr(item, n).__doc__ except: print "# error showing", n # module if printModule: print "module file:", fontforge.__file__ print "version:", fontforge.version() print "module doc:", fontforge.__doc__ print "has User Interface:", fontforge.hasUserInterface() print "has Spiro:", fontforge.hasSpiro() printAPI(fontforge, "fontforge") # font fontObj = fontforge.open(testFontPath) if printFont: printAPI(fontObj, "font") # glyph glyphObj = fontObj["A"] if printGlyph: printAPI(glyphObj, "glyph") # layer layerObj = glyphObj.foreground if printLayer: printAPI(layerObj, "layer") # contour contourObj = layerObj[0] if printContour: printAPI(contourObj, "contour") # point if printPoint: pointObj = contourObj[0] printAPI(pointObj, "point") # other objects penObj = glyphObj.glyphPen() printAPI(penObj, "glyphPen")