Пример #1
0
def otf2ttx(otf_path, ttx_path=None):
    """Generate a .ttx font from an .otf file.

    otf_path: Path of the .otf font source.
    ttx_path: Path of the target .ttx font.

    """
    # make ttx path
    if not ttx_path:
        ttx_path = '%s.ttx' % os.path.splitext(otf_path)[0]
    # save ttx font
    with SuppressPrint():
        tt = TTFont(otf_path)
        tt.verbose = False
        tt.saveXML(ttx_path)
Пример #2
0
def otf2ttx(otf_path, ttx_path=None):
    """Generate a .ttx font from an .otf file.

    otf_path: Path of the .otf font source.
    ttx_path: Path of the target .ttx font.

    """
    # make ttx path
    if not ttx_path:
        ttx_path = '%s.ttx' % os.path.splitext(otf_path)[0]
    # save ttx font
    with SuppressPrint():
        tt = TTFont(otf_path)
        tt.verbose = False
        tt.saveXML(ttx_path)
Пример #3
0
def ttx2otf(ttx_path, otf_path=None):
    """Generate an .otf font from a .ttx file.

    ttx_path: Path of the .ttx font source.
    otf_path: Path of the target .otf font.

    """
    # make otf path
    if not otf_path:
        otf_path = '%s.otf' % os.path.splitext(ttx_path)[0]
    # save otf font
    with SuppressPrint():
        tt = TTFont()
        tt.verbose = False
        tt.importXML(ttx_path)
        tt.save(otf_path)
Пример #4
0
def ttx2otf(ttx_path, otf_path=None):
    """Generate an .otf font from a .ttx file.

    ttx_path: Path of the .ttx font source.
    otf_path: Path of the target .otf font.

    """
    # make otf path
    if not otf_path:
        otf_path = '%s.otf' % os.path.splitext(ttx_path)[0]
    # save otf font
    with SuppressPrint():
        tt = TTFont()
        tt.verbose = False
        tt.importXML(ttx_path)
        tt.save(otf_path)
Пример #5
0
        #path = getFontPath("Arial Unicode.ttf")
        path = getFontPath("MSGothic.ttf")
        font = TTFont(path)
        if True:
            scaleFont(font, 128)
        if False:
            glyphNameToDelete = "percent"
            compoParents = _findComponentParentGlyphs(font, glyphNameToDelete)
            if compoParents:
                # can't delete this glyph, it is referenced elsewhere
                print compoParents
            #otlTools.findAlternateGlyphs(font["GSUB"], [glyphNameToDelete])
            subsetFont(font, [glyphNameToDelete])
            # force post table to vers. 2 to keep glyph names for easier debugging
            font["post"].formatType == 2.0
            font["post"].extraNames = []
            font["post"].mapping = {}
        if False:
            cmap = getBestCmap(font)
            unicodes = list(cmap)
            unicodes.sort()
            unicodes = unicodes[:1800]
            glyphsToKeep = findGlyphsByUnicode(font, unicodes)
            glyphsToDelete = set(font.getGlyphOrder()) - glyphsToKeep
            print "glyphs to keep:", len(glyphsToKeep)
            print "glyphs to delete:", len(glyphsToDelete)
            subsetFont(font, glyphsToDelete)
        outPath = os.path.expanduser("~/Desktop/TestFont.ttf")
        font.verbose = 1
        #font.save(outPath)