コード例 #1
0
ファイル: proof.py プロジェクト: sahwar/woffTools
def proofFont(font, fontPath, sampleText=None):
    """
    Create a proof file from the given font. This always
    returns HTML.

    Arguments:
    **font** - A *WOFFFont* object from *woffLib*.
    **fontPath** - The location of the font file. At the least, this should be the file name for the font.
    **sampleText** - A string of text to display. If not provided, no text will be displayed.
    """
    # start the html
    title = "Proof: %s" % os.path.basename(fontPath)
    cssReplacements = {
        "/* proof: @font-face rule */" : makeFontFaceRule(font, fontPath, doLocalSrc=False),
        "/* proof: @font-face font-family */" : makeFontFaceFontFamily(font)
    }
    writer = startHTML(title=title, cssReplacements=cssReplacements)
    # file info
    writeFileInfo(font, fontPath, writer)
    # character set
    writeCharacterSet(font, writer, sampleText=sampleText)
    # finish the html
    text = finishHTML(writer)
    text = text.replace("%%break%%", "</br>")
    # return
    return text
コード例 #2
0
def reportInfo(font, fontPath):
    """
    Create a report about the contents of font. This returns HTML.

    Arguments

    **font** - A *WOFFFont* object from *woffLib*.
    **fontPath** - The location of the font file. At the least, this should be the file name for the font.
    """
    # start the html
    title = "Info: %s" % os.path.basename(fontPath)
    writer = startHTML(title=title)
    # file info
    writeFileInfo(font, fontPath, writer)
    # SFNT tables
    writeSFNTInfo(font, writer)
    # metadata
    writeMetadata(font, writer)
    # private data
    writePrivateData(font, writer)
    # @font-face
    writeFontFaceRule(font, fontPath, writer)
    # finish the html
    text = finishHTML(writer)
    # return
    return text