def fuse(font): readGlyphList = getDataFile(font.path, 'Choose a dump file') if readGlyphList is not None: # Check to make sure that all compontents are present in the font checkedGlyphList = checkGlyphs(font, readGlyphList) if len(checkedGlyphList) == 0: mark = AskYesNoCancel('Do you wish to mark changed glyphs?') if mark != -1: saveBackup = AskYesNoCancel('Do you want a backup of changed glyphs?') if saveBackup != -1: makeGlyph(readGlyphList, font, 'Updating glyphs', mark, saveBackup) font.update() Message('Done updating glyphs') else: # Gives a list of the components missing from the VFB OneList(checkedGlyphList, 'Sorry, your VFB is missing:')
def scaleNums(): question = "Is your num height " + str( currentNumHeight) + "?" + " If not, please enter it:" customNumHeight = AskString(question, currentNumHeight, "Current Numeral Height") customNumHeight = int(float(customNumHeight.upper())) yesNoQuestion = "This will scale all your numerals to " + str( targetNumHeight) + ". " + "Continue?" confirmScale = AskYesNoCancel(yesNoQuestion, title='Just Checking...', default=0) print confirmScale numScale = targetNumHeight / customNumHeight if confirmScale == 1: for g in f: if customNumHeight != targetNumHeight: g.prepareUndo() if g.name in numerals: g.selected = True print "scaled ", g.name, " to ", targetNumHeight g.scale(numScale) g.width = g.width * numScale g.update() g.performUndo()
def buildAccents(font, list, message, overwrite, preflight=False): """ Takes in a list of accents to build in the format of (baseGlyph, finalName, accentList) Marks glyphs that it has built, and updates the font """ tickCount = len(list) bar = ProgressBar(message, tickCount) tick = 0 for item in list: baseGlyph, outputName, accents = item if font.has_key(baseGlyph): if font.has_key(outputName): if overwrite == 1 or overwrite == 3: answer = AskYesNoCancel(outputName + ' exists in font, overwrite?') if answer == 1: font.compileGlyph(outputName, baseGlyph, accents, preflight=preflight) font[outputName].mark = 200 font[outputName].autoUnicodes() font[outputName].update() font.update() if overwrite == 2: font.compileGlyph(outputName, baseGlyph, accents, preflight=preflight) font[outputName].mark = 200 font[outputName].autoUnicodes() font[outputName].update() font.update() else: font.compileGlyph(outputName, baseGlyph, accents, preflight=preflight) font[outputName].mark = 200 font[outputName].autoUnicodes() font[outputName].update() font.update() bar.tick(tick) tick = tick+1 bar.close()
def startDialog(self): # Welcome message! Message("Hi! My name is typeStats.") # Mode verboso = AskYesNoCancel("Do you prefer the verbose mode?", title='typeStats', default=0) # Search path folder = GetFolder("Choose the directory to analyze") return folder, verboso
def getInstances(axisType): axis = [] numberOfInstances = getNumber('How many instances on the ' + axisType + ' axis would you like?', 0) if numberOfInstances is not None: if numberOfInstances >= 10: result = AskYesNoCancel('Did you really want ' + str(numberOfInstances)) if result is 1: pass if result is 0: numberOfInstances = getNumber('How many instances on the ' + axisType + ' axis would you like?', 0) if result is -1: numberOfInstances = 0 for count in range(numberOfInstances): instance = getNumber('The ' + str(count+1) + ' value for the ' + axisType + ' instance', 1) if instance is not None: axis.append(instance) return axis
def skewSelection(): # set up the question for a yes/no/cancel yesNoQuestion = "This will horizontall skew *all* your selected glyphs in " + fontName + " by " + str(skewValue) + " degrees. You should have a backup before any batch operation. " + "Continue?" # double check with the user before doing anything crazy confirmSkew = AskYesNoCancel(yesNoQuestion ,title='Just Checking...', default=0) # if the user answers "yes", proceed if confirmSkew == 1: ## loop through font for g in f: # set up "undo" for every glyph changed g.prepareUndo() ## compare each glyph name to list of selected glyph names, and only edit if they are in the list if g.name in glyphSelection: # skew every selected glyph with the value the user has entered g.skew(skewValue) g.update() # undo, if the user asks to in the font view while glyphs are selected g.performUndo()
def checkPath(path, fontType): if os.path.isfile(path): dir, fileName = os.path.split(path) else: dir = path fontName = addExtension(fontType, font.font_name) path = os.sep.join([dir, fontName]) if os.path.isfile(path): overwrite = AskYesNoCancel('Font exists, do you want to rename the font?', default=1) if overwrite is 1: f = renameFont(font) fontName = addExtension(fontType, version, f.font_name) dir, fileName = os.path.split(path) path = os.sep.join([dir, fontName]) elif overwrite is -1: closeFont(font) else: pass return path
def scaleGlyphsMetricsAndBlueValues(): yesNoQuestion = "This will scale *all* your glyphs in " + fontName + " by " + str( scaleBy) + ". " + "Continue?" confirmScale = AskYesNoCancel(yesNoQuestion, title='Just Checking...', default=0) if confirmScale == 1: f.info.ascender = f.info.ascender * scaleBy f.info.descender = f.info.descender * scaleBy f.info.capHeight = f.info.capHeight * scaleBy f.info.xHeight = f.info.xHeight * scaleBy blues = f.info.postscriptBlueValues newBlues = [x * scaleBy for x in blues] f.info.postscriptBlueValues = newBlues for g in f: g.scale(scaleBy) g.width = g.width * scaleBy g.update()
def moveAscenders(): yesNoQuestion = "This will move your ascender to " + str( targetAscender) + ". " + "Continue?" confirmScale = AskYesNoCancel(yesNoQuestion, title='Just Checking...', default=0) print confirmScale if confirmScale == 1: for g in f: g.prepareUndo() if g.name in glyphsWithAscenders: g.selected = True for contour in g: for seg in contour: for point in seg: if point.y > f.info.xHeight + xHeightClearance: # print type(point.type), point.y point.move((0, moveAscenderBy)) g.update() print "moved ascender of ", g.name, " by ", str(moveAscenderBy) g.performUndo() f.info.ascender = targetAscender
def scaleCaps(): capScale = targetCapHeight / currentCapHeight print capScale if currentCapHeight != targetCapHeight: yesNoQuestion = "This will scale all your caps to " + str( targetCapHeight) + ". " + "Continue?" confirmScale = AskYesNoCancel(yesNoQuestion, title='Just Checking...', default=0) print confirmScale if confirmScale == 1: newCapHeight = int(float(f.info.capHeight * capScale)) f.info.capHeight = newCapHeight for g in f: g.prepareUndo() if g.name in uppercase: g.selected = True g.scale(capScale) g.width = g.width * capScale g.update() print "scaled ", g.name, " to ", newCapHeight g.performUndo()
'Small Caps in font?', value1=0, value2=0) buildSmallCap = 0 if whatToBuild == 0: upperCaseList = baseUpperCaseList if whatToBuild == 1: suffix = AskString('Suffix for cap accents') upperCaseList = rewriteAccentNames(baseUpperCaseList, suffix) if whatToBuild == 2: scAccentSuffix = '' upperCaseList = baseUpperCaseList buildSmallCap = 1 scAccentSuffix = '' scSuffix = AskString('Suffix for small caps?') specialSmallCapAccents = AskYesNoCancel('Special small cap accents?') if specialSmallCapAccents == 1: scAccentSuffix = AskString('Suffix for small cap accents', scSuffix) smallCapList = rewriteSmallCapList(baseUpperCaseList, scSuffix, scAccentSuffix) if whatToBuild == 3: buildSmallCap = 1 scAccentSuffix = '' suffix = AskString('Suffix for cap accents') upperCaseList = rewriteAccentNames(baseUpperCaseList, suffix) scSuffix = AskString('Suffix for small caps?') specialSmallCapAccents = AskYesNoCancel( 'Use lowercase accents for small caps?') if specialSmallCapAccents == 0: whatToDo = TwoChecks('Use cap accents', 'Use special accents',
print "hhea Ascender: %5d" % hheaAscender print "hhea Descender: %5d" % hheaDescender print "hhea LineGap: %5d" % hheaLineGap print "---------------------" print "OS/2 WinAsc.: %5d" % os2WinAscent print "OS/2 WinDesc.: %5d" % os2WinDescent print "\nIgnored glyphs:", if ignored == "": print "none" else: print ignored # Dialogbox, ob ermittelte Metriken in offene Fonts geschrieben werden sollen setMetrics = AskYesNoCancel( "Write calculated vertical metrics to font? (For values see Output window)", title="Set Vertical Metrics", default=0) if setMetrics == 1: # Antwort war ja, schreibe Werte in die Fonts print "\nWriting metrics to font" # Schleife ueber offene Fonts for f in AllFonts(): # Setze Werte im Font f.info.ascender = vAscender f.info.descender = vDescender f.info.openTypeHheaAscender = hheaAscender f.info.openTypeHheaDescender = hheaDescender f.info.openTypeHheaLineGap = hheaLineGap f.info.openTypeOS2TypoAscender = os2TypoAscender f.info.openTypeOS2TypoDescender = os2TypoDescender f.info.openTypeOS2TypoLineGap = os2TypoLineGap