Beispiel #1
0
        varGlyph.draw(pen)
        os2 = self.ttFont["OS/2"]
        if hasattr(os2, "sxHeight"):
            xHeight = os2.sxHeight
            capHeight = os2.sCapHeight
        else:
            capHeight = self.ttFont["hhea"].ascent
            xHeight = 0.7 * self.ttFont["hhea"].ascent  # XXX
        centerPoint = (varGlyph.width / 2, xHeight / 2)
        size = capHeight
        return pen, centerPoint, size


if __name__ == "__main__":

    class DesignSpaceExplorerTest(object):
        def __init__(self, designSpace, previewCharacter="e"):
            from vanilla import Window
            from tnbits.toolparts.buildvariables.designspaceexplorer import DesignSpaceExplorer
            self.w = Window((1000, 500),
                            "DesignSpace Explorer",
                            minSize=(600, 300))
            self.w.designSpaceExplorer = DesignSpaceExplorer(
                (0, 0, 0, 0), designSpace, previewCharacter=previewCharacter)
            self.w.open()

    from tnTestFonts import getFontPath
    p = getFontPath("Noordzij_e_varfont.ttf")
    ds = TTVarFontDesignSpace.fromVarFontPath(p)
    DesignSpaceExplorerTest(ds, "e")
Beispiel #2
0
    import doctest
    return doctest.testmod()


if __name__ == "__main__":
    if True:
        import sys
        sys.exit(_runDocTests()[0])
    else:
        import os
        from fontTools.ttLib import TTFont
        from tnTestFonts import getFontPath
        #path = getFontPath("CusterRE-RegularS2.ttf")
        #path = getFontPath("SegoeUI-Regular-All.ttf")
        #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 = {}
Beispiel #3
0
        >>> #f is not None
        True
        >>> uninstallFontFile(path)
        >>> f = AppKit.NSFont.fontWithName_size_(u'-', 12)
        >>> f is not None
        False
    """


def _runDocTests():
    import doctest
    return doctest.testmod()


if __name__ == "__main__":
    if True:
        _runDocTests()
    else:
        # Test to be run in DrawBot
        from tnTestFonts import getFontPath
        path = getFontPath("Condor-Bold.otf")
        try:
            installFontFile(path)
        except FontInstallError, error:
            print "font probably already installed"
            #print error
        font("Condor-Bold")
        fontSize(200)
        text("Hallo", (100, 100))
        # uninstallFontFile(path)