def copy_fonts(font_awesome_src, target_font_dir): font_dir = os.path.join(font_awesome_src, 'webfonts') fonts = [os.path.join(font_dir, src_name) for src_name in FONTS] dest_path = os.path.join(target_font_dir, FONT_FILENAME) print(f'Merging fonts: {fonts} -> {dest_path}') merger = Merger() with merger.merge(fonts) as font: font.save(dest_path) rename_font_family(dest_path)
def simpleMerger(fontsPath, style, newName, onlySecureSet=False): #path of actual fonts print("start merging") merger = Merger() print(fontsPath) mergedFont = merger.merge(fontsPath) destination = newFolderForMerged("NotoCombined/fonts/TTF") if not os.path.exists(destination): os.makedirs(destination) mergedFontPath = os.path.join(destination, "NotoCombined"+style+".ttf") mergedFont.save(mergedFontPath) print(mergedFontPath) renameFonts("NotoCombined", newName) return os.path.abspath(os.path.join(destination, os.pardir))
def basicMerger(masterfont, *fontsToAdd, onlySecureSet=False): fontsPath = [] fontsPath.append(masterfont) for ft in fontsToAdd: fontsPath.append(ft) #merge merger = Merger() mergedFont = merger.merge(fontsPath) flavor = str(os.path.basename(masterfont).split(".")[-1]) if onlySecureSet is True: destination = masterfont.replace(os.path.basename(masterfont), "") else: new = os.path.basename(masterfont).split("-")[0] for i in fontsToAdd: new += i.replace("Noto", "") destination = newFolderForMerged(new) if not os.path.exists(destination): os.makedirs(destination) mergedFontPath = os.path.join(destination, os.path.basename(masterfont)) mergedFont.save(mergedFontPath)
def _merge_and_recompile(fontfiles, options=None): merger = Merger(options) merged = merger.merge(fontfiles) buf = _compile(merged) return ttLib.TTFont(buf)
def mergeBitStreams(bsList, outfile): m = Merger() bsio = [BytesIO(s) for s in bsList] font = m.merge(bsio) font.save(outfile)