def clean(folder): if exists(folder): rmtree(folder) mkdir(folder) ### Instructions if __name__ == '__main__': outputFolder = 'output' clean(outputFolder) fontPaths = catchFiles('fonts', '.ufo') glyphSets = {'uppercase': ascii_uppercase, 'lowercase': ascii_lowercase} for eachPath in fontPaths: thisFont = OpenFont(eachPath) for setName, eachSet in glyphSets.items(): flat = flatKerning(thisFont, eachSet) canvasSize = CELL_SIZE * (len(eachSet) + 4) newDrawing() newPage(canvasSize, canvasSize) translate(CELL_SIZE * 2, CELL_SIZE * 2) kerningHeatMap(flat, eachSet, isFirstVertical=True) fontName = f'{thisFont.info.familyName} {thisFont.info.styleName}' saveImage(join(outputFolder, f'{fontName} - {setName}.pdf')) endDrawing()
rectClr = lerpRGB(WHITE, GREEN, factor) typeClr = BLACK shapeQualities(rectClr) rect(0, 0, CELL_SIZE, CELL_SIZE) if correction != 0: corrStr = f'{abs(correction)}' # just a check for body size if textSize(corrStr)[0] > CELL_SIZE: print(f'[WARNING] {pair} text is too big!') typeQualities(clr=typeClr) text(corrStr, (CELL_SIZE * .5, CELL_SIZE * .2), align='center') if __name__ == '__main__': ### Variables fontName = 'Source Serif Pro Regular.ufo' glyphNames = ascii_uppercase ### Instructions thisFont = OpenFont(fontName) flat = flatKerning(thisFont) canvasSize = (len(glyphNames) + 4) * CELL_SIZE newPage(canvasSize, canvasSize) translate(CELL_SIZE * 2, CELL_SIZE * 2) kerningHeatMap(flat, glyphNames, isFirstVertical=True)