Exemplo n.º 1
0
 def __init__(self, fontfilename=config.scriptPath("bigblocks.bsfont")):
     try:
         lines = open(fontfilename, encoding="utf-8").readlines()
     except Exception as e:
         die("Couldn't find font file “{0}”:\n{1}", fontfilename, e)
     self.metadata, lines = parseMetadata(lines)
     self.characters = parseCharacters(self.metadata, lines)
Exemplo n.º 2
0
 def __init__(self, fontfilename=config.scriptPath("bigblocks.bsfont")):
     try:
         lines = io.open(fontfilename, 'r', encoding="utf-8").readlines()
     except Exception as e:
         die("Couldn't find font file “{0}”:\n{1}", fontfilename, e)
     self.metadata, lines = parseMetadata(lines)
     self.characters = parseCharacters(self.metadata, lines)
Exemplo n.º 3
0
    try:
        if outputFilename == "-":
            sys.stdout.write("".join(lines))
        else:
            with open(outputFilename, "w", encoding="utf-8") as f:
                f.write("".join(lines))
    except Exception as e:
        die(
            "Something prevented me from saving the output document to {0}:\n{1}",
            outputFilename,
            e,
        )


if __name__ == "__main__":
    import argparse

    argparser = argparse.ArgumentParser(
        description="Outputs text as giant ASCII art.")
    argparser.add_argument(
        "--font",
        dest="fontPath",
        default=config.scriptPath("bigblocks.bsfont"),
        help="What .bsfont file to use to render the text with.",
    )
    argparser.add_argument("text", help="Text to ASCII-ify.")
    options = argparser.parse_args()
    font = Font(options.fontPath)
    for line in font.write(options.text):
        print(line, end="")
Exemplo n.º 4
0
 def __init__(self, fontfilename=config.scriptPath("bigblocks.bsfont")):
     try:
         lines = io.open(fontfilename, 'r', encoding="utf-8").readlines()
     except Exception, e:
         die("Couldn't find font file “{0}”:\n{1}", fontfilename, e)
Exemplo n.º 5
0
 def __init__(self, fontfilename=config.scriptPath("bigblocks.bsfont")):
     try:
         lines = io.open(fontfilename, 'r', encoding="utf-8").readlines()
     except Exception, e:
         die("Couldn't find font file “{0}”:\n{1}", fontfilename, e)
Exemplo n.º 6
0
        return []
    except IOError:
        die("Couldn't open the input file '{0}'.", inputFilename)
        return []
    return lines, inputFilename


def writeOutputLines(outputFilename, inputFilename, lines):
    if outputFilename is None:
        outputFilename = inputFilename
    try:
        if outputFilename == "-":
            sys.stdout.write(''.join(lines))
        else:
            with io.open(outputFilename, "w", encoding="utf-8") as f:
                f.write(''.join(lines))
    except Exception, e:
        die("Something prevented me from saving the output document to {0}:\n{1}", outputFilename, e)

if __name__ == "__main__":
    import argparse
    argparser = argparse.ArgumentParser(description="Outputs text as giant ASCII art.")
    argparser.add_argument("--font", dest="fontPath", default=config.scriptPath("bigblocks.bsfont"),
                           help="What .bsfont file to use to render the text with.")
    argparser.add_argument("text",
                           help="Text to ASCII-ify.")
    options = argparser.parse_args()
    font = Font(options.fontPath)
    for line in font.write(options.text):
        print line,