Exemple #1
0
def main():
    parser = optparse.OptionParser(usage=usage,
                                   description=description,
                                   version="%prog 0.1beta")
    parser.add_option(
        "-d",
        dest="outputDirectory",
        help=
        "Output directory. The default is to output the proof into the same directory as the font file."
    )
    parser.add_option(
        "-o",
        dest="outputFileName",
        help="Output file name. The default is \"fontfilename_proof.html\".")
    parser.add_option(
        "-t",
        dest="sampleTextFile",
        help=
        "Sample text file. A file containing sample text to display. If not file is provided, The quick brown fox... will be used."
    )
    parser.set_defaults(excludeTests=[])
    (options, args) = parser.parse_args()
    outputDirectory = options.outputDirectory
    if outputDirectory is not None and not os.path.exists(outputDirectory):
        print "Directory does not exist:", outputDirectory
        sys.exit()
    sampleText = defaultSampleText
    if options.sampleTextFile:
        if not os.path.exists(options.sampleTextFile):
            print "Sample text file does not exist:", options.sampleTextFile
            sys.exit()
        f = open(options.sampleTextFile, "r")
        sampleText = f.read()
        f.close()
    for fontPath in args:
        if not os.path.exists(fontPath):
            print "File does not exist:", fontPath
            sys.exit()
        else:
            print "Creating Proof: %s..." % fontPath
            fontPath = fontPath.decode("utf-8")
            font = WOFFFont(fontPath)
            html = proofFont(font, fontPath, sampleText=sampleText)
            # make the output file name
            if options.outputFileName is not None:
                fileName = options.outputFileName
            else:
                fileName = os.path.splitext(os.path.basename(fontPath))[0]
                fileName += "_proof.html"
            # make the output directory
            if options.outputDirectory is not None:
                directory = options.outputDirectory
            else:
                directory = os.path.dirname(fontPath)
            # write the file
            path = os.path.join(directory, fileName)
            path = findUniqueFileName(path)
            f = open(path, "wb")
            f.write(html)
            f.close()
Exemple #2
0
def main():
    parser = optparse.OptionParser(usage=usage,
                                   description=description,
                                   version="%prog 0.1beta")
    parser.add_option(
        "-d",
        dest="outputDirectory",
        help=
        "Output directory. The default is to output the CSS into the same directory as the font file."
    )
    parser.add_option(
        "-o",
        dest="outputFileName",
        help=
        "Output file name. The default is \"fontfilename.css\". If this file already exists a time stamp will be added to the file name."
    )
    parser.add_option(
        "-l",
        action="store_true",
        dest="doLocalSrc",
        help="Write \"local\" instructions as part of the \"src\" descriptor.")
    (options, args) = parser.parse_args()
    outputDirectory = options.outputDirectory
    if outputDirectory is not None and not os.path.exists(outputDirectory):
        print "Directory does not exist:", outputDirectory
        sys.exit()
    for fontPath in args:
        if not os.path.exists(fontPath):
            print "File does not exist:", fontPath
            sys.exit()
        else:
            print "Creating CSS: %s..." % fontPath
            fontPath = fontPath.decode("utf-8")
            font = WOFFFont(fontPath)
            css = makeFontFaceRule(font,
                                   fontPath,
                                   doLocalSrc=options.doLocalSrc)
            # make the output file name
            if options.outputFileName is not None:
                fileName = options.outputFileName
            else:
                fileName = os.path.splitext(os.path.basename(fontPath))[0]
                fileName += ".css"
            # make the output directory
            if options.outputDirectory is not None:
                directory = options.outputDirectory
            else:
                directory = os.path.dirname(fontPath)
            # write the file
            path = os.path.join(directory, fileName)
            path = findUniqueFileName(path)
            f = open(path, "wb")
            f.write(css)
            f.close()
Exemple #3
0
def main():
    parser = optparse.OptionParser(usage=usage, description=description, version="%prog 0.1beta")
    parser.add_option("-d", dest="outputDirectory", help="Output directory. The default is to output the proof into the same directory as the font file.")
    parser.add_option("-o", dest="outputFileName", help="Output file name. The default is \"fontfilename_proof.html\".")
    parser.add_option("-t", dest="sampleTextFile", help="Sample text file. A file containing sample text to display. If not file is provided, The quick brown fox... will be used.")
    parser.set_defaults(excludeTests=[])
    (options, args) = parser.parse_args()
    outputDirectory = options.outputDirectory
    if outputDirectory is not None and not os.path.exists(outputDirectory):
        print("Directory does not exist:", outputDirectory)
        sys.exit()
    sampleText = defaultSampleText
    if options.sampleTextFile:
        if not os.path.exists(options.sampleTextFile):
            print("Sample text file does not exist: %s" % options.sampleTextFile)
            sys.exit()
        f = open(options.sampleTextFile, "r")
        sampleText = f.read()
        f.close()
    for fontPath in args:
        if not os.path.exists(fontPath):
            print("File does not exist: %s" % fontPath)
            sys.exit()
        else:
            print("Creating Proof: %s..." % fontPath)
            fontPath = fontPath.decode("utf-8")
            font = WOFFFont(fontPath)
            html = proofFont(font, fontPath, sampleText=sampleText)
            # make the output file name
            if options.outputFileName is not None:
                fileName = options.outputFileName
            else:
                fileName = os.path.splitext(os.path.basename(fontPath))[0]
                fileName += "_proof.html"
            # make the output directory
            if options.outputDirectory is not None:
                directory = options.outputDirectory
            else:
                directory = os.path.dirname(fontPath)
            # write the file
            path = os.path.join(directory, fileName)
            path = findUniqueFileName(path)
            f = open(path, "wb")
            f.write(html)
            f.close()
Exemple #4
0
def main():
    parser = optparse.OptionParser(usage=usage, description=description, version="%prog 0.1beta")
    parser.add_option("-d", dest="outputDirectory", help="Output directory. The default is to output the CSS into the same directory as the font file.")
    parser.add_option("-o", dest="outputFileName", help="Output file name. The default is \"fontfilename.css\". If this file already exists a time stamp will be added to the file name.")
    parser.add_option("-l", action="store_true", dest="doLocalSrc", help="Write \"local\" instructions as part of the \"src\" descriptor.")
    (options, args) = parser.parse_args()
    outputDirectory = options.outputDirectory
    if outputDirectory is not None and not os.path.exists(outputDirectory):
        print("Directory does not exist: %s" % outputDirectory)
        sys.exit()
    for fontPath in args:
        if not os.path.exists(fontPath):
            print("File does not exist: %s" % fontPath)
            sys.exit()
        else:
            print("Creating CSS: %s..." % fontPath)
            fontPath = fontPath.decode("utf-8")
            font = WOFFFont(fontPath)
            css = makeFontFaceRule(font, fontPath, doLocalSrc=options.doLocalSrc)
            # make the output file name
            if options.outputFileName is not None:
                fileName = options.outputFileName
            else:
                fileName = os.path.splitext(os.path.basename(fontPath))[0]
                fileName += ".css"
            # make the output directory
            if options.outputDirectory is not None:
                directory = options.outputDirectory
            else:
                directory = os.path.dirname(fontPath)
            # write the file
            path = os.path.join(directory, fileName)
            path = findUniqueFileName(path)
            f = open(path, "wb")
            f.write(css)
            f.close()
Exemple #5
0
def main():
    parser = optparse.OptionParser(usage=usage, description=description, version="%prog 0.1beta")
    parser.add_option("-d", dest="outputDirectory", help="Output directory. The default is to output the report into the same directory as the font file.")
    parser.add_option("-o", dest="outputFileName", help="Output file name. The default is \"fontfilename_info.html\".")
    parser.set_defaults(excludeTests=[])
    (options, args) = parser.parse_args()
    outputDirectory = options.outputDirectory
    if outputDirectory is not None and not os.path.exists(outputDirectory):
        print("Directory does not exist: %s" % outputDirectory)
        sys.exit()
    for fontPath in args:
        if not os.path.exists(fontPath):
            print("File does not exist: %s" % fontPath)
            sys.exit()
        else:
            print("Creating Info Report: %s..." % fontPath)
            fontPath = fontPath.decode("utf-8")
            font = WOFFFont(fontPath)
            html = reportInfo(font, fontPath)
            # make the output file name
            if options.outputFileName is not None:
                fileName = options.outputFileName
            else:
                fileName = os.path.splitext(os.path.basename(fontPath))[0]
                fileName += "_info.html"
            # make the output directory
            if options.outputDirectory is not None:
                directory = options.outputDirectory
            else:
                directory = os.path.dirname(fontPath)
            # write the file
            path = os.path.join(directory, fileName)
            path = findUniqueFileName(path)
            f = open(path, "wb")
            f.write(html)
            f.close()