Пример #1
0
def execute(name: str, sources: Path):
    print("Generating " + name + " UFO")
    outputPath = sources / str("ufo_" + name)
    os.makedirs(outputPath, exist_ok=True)
    glyphsName = "Kaisei-" + name.capitalize() + ".glyphs"
    if name == "haruno":
        glyphsName = "Kaisei-HarunoUmi.glyphs"
    main(("glyphs2ufo", str(sources / glyphsName), "-m", str(outputPath)))
    fontExport(name, sources, outputPath)
Пример #2
0
    args = parser.parse_args()
    sources = Path("sources")

    if args.all:
        args.decol = True
        args.haruno = True
        args.opti = True
        args.tokumin = True

    if args.decol or args.haruno or args.opti or args.tokumin or args.shared:
        os.makedirs("sources/ufo_shared", exist_ok=True)
        if args.shared:
            print("Generating shared UFO")
            if os.path.isfile(sources / "Kaisei-Shared.glyphs"):
                main(
                    ("glyphs2ufo", str(sources / "Kaisei-Shared.glyphs"), "-m",
                     str(sources / "ufo_shared")))
            else:
                print(
                    "Cannot locate the 'shared' Glyphs file. Please confirm the file is unzipped."
                )

        pool = multiprocessing.pool.Pool(processes=multiprocessing.cpu_count())
        processes = []

        if args.decol:
            processes.append(pool.apply_async(execute, ("decol", sources)))

        if args.haruno:
            processes.append(pool.apply_async(execute, ("haruno", sources)))
Пример #3
0
    args = parser.parse_args()
    sources = Path("sources")

    if args.all:
        args.one = True
        args.two = True
        args.code = True
        args.latin = True
        args.sources = True

    if args.sources:
        print("[MPLUS] Generating UFO sources")
        for file in sources.glob("*.glyphs"):
            print("[" + str(file).split("/")[1] + "] generating source")
            main(
                ("glyphs2ufo", str(file), "--write-public-skip-export-glyphs"))

        print(
            "[MPLUS] Generating Japanese instances for code use"
        )  #these are needed as MPlus1 & Kanji don't have the same master positions as Code

        kanaDS = DesignSpaceDocument.fromfile(sources / "MPLUS-1.designspace")
        #delete the substitution rules because we don't want the generator to swap masters when generating instances
        kanaDS.rules = []
        kanaDS.loadSourceFonts(ufoLib2.Font.open)
        generator1 = fontmake.instantiator.Instantiator.from_designspace(
            kanaDS)
        for instance in kanaDS.instances:
            if instance.name == "Mplus 1 Regular":
                kanaR = generator1.generate_instance(instance)
                kanaR.save("sources/Mplus1-Regular.ufo", overwrite=True)
Пример #4
0
for line in f.readlines():
    sub = str(line).rstrip().replace(";", "")[4:]
    palt_set.append(sub)


def DSIG_modification(font: TTFont):
    font["DSIG"] = newTable("DSIG")  #need that stub dsig
    font["DSIG"].ulVersion = 1
    font["DSIG"].usFlag = 0
    font["DSIG"].usNumSigs = 0
    font["DSIG"].signatureRecords = []
    font["head"].flags |= 1 << 3  #sets flag to always round PPEM to integer


print("Converting to UFO")
main(("glyphs2ufo", "sources/MochiyPop.glyphs"))

print("[Mochiy Pop One] Compiling")
exportFont = ufoLib2.Font.open("sources/MochiyPopOne-Regular.ufo")

exportFont.lib['com.github.googlei18n.ufo2ft.filters'] = [{
    "name": "decomposeComponents",
    "pre": 1,
}]

# BUILDING STANDARD VERSION

static_ttf = ufo2ft.compileTTF(exportFont, removeOverlaps=True)
DSIG_modification(static_ttf)
static_ttf["name"].addMultilingualName({'ja': 'モッチーポップ One'},
                                       static_ttf,
Пример #5
0
try:
    os.mkdir("sources/UFO")
except:
    pass
try:
    os.mkdir("sources/instance_UFO")
except:
    pass

sourceURL = Path("sources/UFO")
instanceURL = Path("sources/instance_UFO")

for s in sources:

    main(("glyphs2ufo", str(s), "--write-public-skip-export-glyphs",
          "--propagate-anchors", "--output-dir", str(sourceURL)))

    for ufo in Path(sourceURL).glob("*.ufo"):
        temp = ufoLib2.Font.open(ufo)

        temp.lib['com.github.googlei18n.ufo2ft.filters'] = [{
            "name": "propagateAnchors",
            "pre": 1,
        }]
        temp.save(Path(ufo), overwrite=True)

    designspace = fontTools.designspaceLib.DesignSpaceDocument.fromfile(
        sourceURL / "Signika.designspace")

    designspace.loadSourceFonts(ufoLib2.Font.open)
Пример #6
0
from fontmake import __main__
from fontTools.ttLib import TTFont, newTable
import shutil
import subprocess
from glyphsLib.cli import main
import ufoLib2
import ufo2ft  #note, requires version 2.19.2
import os

print("Converting to UFO")
main(("glyphs2ufo", "sources/YuseiMagic.glyphs"))

exportFont = ufoLib2.Font.open("sources/YuseiMagic-Regular.ufo")

exportFont.lib['com.github.googlei18n.ufo2ft.filters'] = [{
    "name": "flattenComponents",
    "pre": 1,
}]

print("Compiling")
static_ttf = ufo2ft.compileTTF(exportFont, removeOverlaps=True)

static_ttf["DSIG"] = newTable("DSIG")
static_ttf["DSIG"].ulVersion = 1
static_ttf["DSIG"].usFlag = 0
static_ttf["DSIG"].usNumSigs = 0
static_ttf["DSIG"].signatureRecords = []
static_ttf["head"].flags |= 1 << 3  #sets flag to always round PPEM to integer

print("[Yusei Magic] Saving")
static_ttf.save("fonts/ttf/YuseiMagic-Regular.ttf")