Esempio n. 1
0
def writeGlyphlist(master, glyphid=None):
    ifile = open(op.join(master.get_fonts_directory(), "glyphlist.mf"), "w")
    dirnamep1 = op.join(master.get_fonts_directory(), "glyphs")

    charlist1 = [f for f in os.listdir(dirnamep1)]

    for ch1 in charlist1:
        fnb, ext = buildfname(ch1)
        if (not glyphid or str(glyphid) == fnb) and ext in ["mf"]:
            ifile.write("input glyphs/" + ch1 + "\n")
    ifile.close()
Esempio n. 2
0
def putFontAllglyphs(master, glyphid=None):
    fontpath = op.join(master.get_ufo_path(), 'glyphs')

    charlista = [f for f in os.listdir(fontpath)]

    for ch1 in charlista:
        glyphName, ext = buildfname(ch1)
        if not glyphName or glyphName.startswith('.'):
            continue
        if ext in ["glif"] and (not glyphid or glyphid == glyphName):
            glif = etree.parse(op.join(fontpath, ch1))
            create_glyph(glif, master)
Esempio n. 3
0
def putFontAllglyphs(master, glyphid=None):
    # read all fonts (xml files with glif extension) in unix directory
    # and put the xml data into db using the rule applied in loadoption
    # only the fonts (xml file) will be read when the glifs are present
    # in both fonts A and B

    source_fontpath_A = op.join(master.get_fonts_directory('A'), 'glyphs')
    source_fontpath_B = op.join(master.get_fonts_directory('B'), 'glyphs')

    charlista = [f for f in os.listdir(source_fontpath_A)]
    charlistb = [f for f in os.listdir(source_fontpath_B)]

    for ch1 in charlista:
        glyphName, ext = buildfname(ch1)
        if ext in ["glif"] and (not glyphid or glyphid == glyphName):
            glif = etree.parse(op.join(source_fontpath_A, ch1))
            create_glyph(glif, master, 'A')

    for ch1 in charlistb:
        glyphName, ext = buildfname(ch1)
        if ext in ["glif"] and (not glyphid or glyphid == glyphName):
            glif = etree.parse(op.join(source_fontpath_B, ch1))
            create_glyph(glif, master, 'B')
Esempio n. 4
0
def ufo2mf(master):
    dirnamef1 = working_dir(op.join(master.get_fonts_directory('a'), "glyphs"))
    dirnamef2 = working_dir(op.join(master.get_fonts_directory('b'), "glyphs"))
    dirnamep1 = working_dir(op.join(master.get_fonts_directory(), "glyphs"))
    if not op.exists(dirnamep1):
        os.makedirs(dirnamep1)

    charlist1 = filter(lambda f: fnextension(f) == 'glif', os.listdir(dirnamef1))
    charlist2 = filter(lambda f: fnextension(f) == 'glif', os.listdir(dirnamef2))

    for ch1 in charlist1:
        if ch1 in charlist2:
            fnb, ext = buildfname(ch1)
            glyphA = Glyph.get(idmaster=master.idmaster, fontsource='A', name=fnb)
            glyphB = Glyph.get(idmaster=master.idmaster, fontsource='B', name=fnb)
            xmltomf.xmltomf1(master, glyphA, glyphB)
Esempio n. 5
0
def writeallxmlfromdb(master, glyphs):
    dirnamea = op.join(master.get_fonts_directory('A'), "glyphs")
    dirnameb = op.join(master.get_fonts_directory('B'), "glyphs")

    charlista = [f for f in os.listdir(dirnamea) if fnextension(f) == 'glif']
    charlistb = [f for f in os.listdir(dirnameb) if fnextension(f) == 'glif']
    #
    for ch1 in charlista:
        if ch1 in charlistb:
            glyphname, exte = buildfname(ch1)
            if glyphname in glyphs:
                cFont.glyphunic = glyphname
                cFont.glyphName = glyphname
                #   for A and B font
                for iwork in ['0', '1']:
                    cFont.idwork = iwork
                    model.writexml()