Example #1
0
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
Example #2
0
def writeFontFaceRule(font, fontPath, writer):
    # start the block
    writer.begintag("div", c_l_a_s_s="infoBlock")
    # title
    writer.begintag("h3", c_l_a_s_s="infoBlockTitle")
    writer.write("@font-face")
    writer.endtag("h3")
    # the text
    fontFaceRule = makeFontFaceRule(font, fontPath, doLocalSrc=False)
    writer.begintag("pre", c_l_a_s_s="fontFaceRule")
    writer.write(fontFaceRule)
    writer.endtag("pre")
    # close the container
    writer.endtag("div")