An implementation of figlet written in Python

Overview
All of the documentation and the majority of the work done was by
    Christopher Jones ([email protected]).
Packaged by Peter Waller <[email protected]>,
various enhancements by Stefano Rivera <[email protected]>.

                        _|_|  _|            _|              _|
_|_|_|    _|    _|    _|            _|_|_|  _|    _|_|    _|_|_|_|
_|    _|  _|    _|  _|_|_|_|  _|  _|    _|  _|  _|_|_|_|    _|
_|    _|  _|    _|    _|      _|  _|    _|  _|  _|          _|
_|_|_|      _|_|_|    _|      _|    _|_|_|  _|    _|_|_|      _|_|
_|              _|                      _|
_|          _|_|                    _|_|


SYNOPSIS

        pyfiglet is a full port of FIGlet (http://www.figlet.org/) into pure
        python. It takes ASCII text and renders it in ASCII art fonts (like
        the title above, which is the 'block' font).

FAQ

        Q. Why? WHY?!
        A. I was bored. Really bored.

        Q. What the hell does this do that FIGlet doesn't?
        A. Not much, except allow your font collection to live
           in one big zipfile. The point of this code is to embed
           dynamic figlet rendering in Python without having to
           execute an external program, although it operates on the
           commandline as well.  See below for USAGE details. You can
           think of this as a python FIGlet driver.

        Q. Does this support kerning/smushing like FIGlet?
        A. Yes, yes it does. Output should be identical to FIGlet. If
           not, this is a bug, which you should report to me!

        Q. Can I use/modify/redstribute this code?
        A. Yes, under the terms of the MIT (see LICENSE below).

        Q. I improved this code, what should I do with it?
        A. You can submit changes to https://github.com/pwaller/pyfiglet/pulls.
           If you make changes to the kerning/mushing/rendering portion, PLEASE
           test it throroughly. The code is fragile and complex.

        Q. Where did my font go?
        A. It turns out that we didn't have distribution rights for some of the
           fonts and so we had to remove them.  Full details of the change and
           why we did it are in https://github.com/pwaller/pyfiglet/issues/59.

        Q. Where can I find these and other fonts?
        A. Do a quick search for "figlet fonts" on your favourite search engine
           should give you what you need.  However, if you are looking for the
           specific removed fonts, please go to http://www.jave.de/figlet/fonts.html.

USAGE

        You can use pyfiglet in one of two ways. First, it operates on the
        commandline as C figlet does and supports most of the same options.
        Run with --help to see a full list of tweaks.  Mostly you will only
        use -f to change the font. It defaults to standard.flf.

        tools/pyfiglet 'text to render'

        Pyfiglet is also a library that can be used in python code:

        from pyfiglet import Figlet
        f = Figlet(font='slant')
        print f.renderText('text to render')

        If you have found some new fonts that you want to use, you can use the
        command line interface to install your font file as follows:

        pyfiglet -L <font file>

        The font file can be a ZIP file of lots of fonts or just a single font.
        Depending on how you installed pyfiglet, you may find that you need
        root access to install the font - e.g. `sudo pyfiglet -L <font file>`.

AUTHOR

        pyfiglet is a *port* of FIGlet, and much of the code is directly translated
        from the C source. I optimized some bits where I could, but because the smushing
        and kerning code is so incredibly complex, it was safer and easier to port the logic
        almost exactly.  Therefore, I can't really take much credit for authorship, just
        translation. The original authors of FIGlet are listed on their website  at
        http://www.figlet.org/.

        The Python port was done by Christopher Jones <[email protected]> (http://gruntle.org/).
        It is currently maintained by Peter Waller ([email protected], github:pwaller)

        The toilet fonts (.tlf) were imported from toilet 0.3-1, by Sam Hocevar <[email protected]>.

THANKS

        github:stefanor for various bug fixes and improvements and the debian packaging.

        Thanks to anyone who contributed an issue or code on github!

LICENSE

        The MIT License (MIT)
        Copyright © 2007-2018

          Christopher Jones <[email protected]>
          Stefano Rivera <[email protected]>
          Peter Waller <[email protected]>
          And various contributors (see git history).

        (see LICENSE for full details)

CHANGELOG

        2018-12-06 0.8.0
            #62 Change LICENSE to MIT
            #61 Provide font installation option (-L) and remove
                unlicenced fonts from the distribution

        2018-10-17 0.7.6

            #57 Implement colored print
            #53 Allow fonts to be specified by path

        2016-06-12 0.7.5

            #46 Add 100+ fonts from java.de figlet fonts collection v4.0
            #48 Include python3 in testing

        2015-05-27 0.7.4

            #43 Don't leak file handles

        2015-04-14 0.7.3

            #41 Add newline and text wrapping support

        2014-09-14 0.7.2

            #35 Add this CHANGELOG
            #36 Bug fix for #34 (broken --reverse and --flip)
                (reported "character mapping must return integer, None or unicode")

        2014-07-27 0.7.1

            #29 Fix for UTF8 regression
            #31 Add __main__ entry point
            #32 Pep8 the code and minor refactoring
            #33 Trove classifiers update

        2014-06-02 0.7

            #9  Add --list_fonts and --info_font
            #10 Add tools/pyfiglet_example for listing all fonts
            #11 Fix the pyfiglet command (had bad python path)
            #12 Pyflakes fixes
            #13 Configure Travis Continuous Integration
            #17 Documentation usage sample fix
            #19 Enable pyfiglet to use extended ASCII chars
            #20 Add two cyrillic fonts
            #21 Python 3 support
            #27 Code improvements
            #28 Human readable font list (-l)
Comments
  • Font Licensing

    Font Licensing

    Hello :),

    A while ago (nearly a year!), I submitted pyfiglet for inclusion in the Fedora repositories. It was approved, but its inclusion was aborted as I found out about all the fonts included and nearly fainted at the sight of reviewing each of these fonts licenses. In retrospect, I should've contacted you to help me with those issues, which is why I decided to do it now.

    Indeed, today @peterbrittain found out by luck of our effort to package pyfiglet and let us know that all the fonts which were not distributable were removed (as per #59). That is great, but unfortunately not enough. Indeed, for Fedora, it is required that the license of each font is documented and shipped with its license. And this package has fonts... A lot of them... And most are undocumented.

    I also found out thanks to @peterbrittain that there is prior art in FIGlet licensing in Fedora, and what I seem to take out from that discussion is that if the shape and appearance of the fonts themselves are Public Domain, the files still remain under a font license.

    So, what needs to be done is the curation of each font file in this repository. What could also be done is the creation of a new repository containing non-free or lost fonts that users can add easily using pyfiglet -L, while keeping safe fonts in the main repository.

    help wanted 
    opened by LyesSaadi 57
  • Alternatives to GPL-2.0 license?

    Alternatives to GPL-2.0 license?

    First off, I just wanted to say that I love that you've spent the time to port FIGlet to Python. This is a great project and I want to say thank you for creating it. But that's not why I've raised this issue... :-)

    It turns out that many of your dependent projects/packages (https://github.com/pwaller/pyfiglet/network/dependents) are using pyfiglet, but are not redistributing under the terms of the GPL-2.0 license that you are using. My own package (https://github.com/peterbrittain/asciimatics) appears to have fallen foul of this.

    I really want to continue to deploy my package under the terms of the Apache-2.0 license, which as I understand it means I have to follow one of the following options:

    1. Remove/replace the use of your package
    2. Convert all direct use of pyfiglet (via import) into separate process calls (via your command-line script).
    3. Agree with you (as the copyright holders) a separate license for my project.
    4. Persuade you to change your standard license to something that allows for this use case - e.g. LGPL-3.0.

    Given how many other projects depend on this one (and are actually breaking the terms as I now understand them), I'd like to try to do the right thing here and explore options 3 and 4 with you before just diving into options 1 or 2.

    So... Would you be willing to consider some other form of licensing like LGPL?

    opened by peterbrittain 42
  • Add newline support

    Add newline support

    Added carriage return support to pyfiglet refactored the FigletRenderingEngine: Use a Director - Builder - Product design pattern refactored test.py, tests are now easy to add. added a test_font script too diff fonts results with figlet added stats_erroneous_font.py based on test.py, show which font and type of smush value are failing the tests

    If the width is smaller than a character width of the font, we throw an exception, get a bigger terminal with more than 6 columns :-) This is different from figlet which will either send many spaces or little part of the characters

    Fixes #25.

    opened by grandemk 22
  • Fonts don't have a suitable license for distribution

    Fonts don't have a suitable license for distribution

    Please see comments raised by @peterbrittain in https://github.com/pwaller/pyfiglet/issues/58#issuecomment-425883141 #58

    In essence, I think we need to revert #46, or come to an understanding that distributing these is legitimate.

    Paging @peterbrittain, @stefanor @asakasinsky (#20) @MinchinWeb (#46).

    I could use some help figuring out what needs to be done here, I also don't have much free time for actioning this. Here is a quick first pass proposal:

    1. Identify fonts which need removing.
      • (or equivalently, which can be kept, so that the code is self standing)
    2. Remove them from the github repository.
      • Decode if they need removing from the history of the repository.
    3. Remove them from source distributions on PyPi.
      • Decide if they need removing from older versions (if they should be removed from the repository
    4. Provide a mechanism for the user to obtain/use additional fonts from sources where the license is valid.
    opened by pwaller 20
  • Fix for #89 - clarify font licensing

    Fix for #89 - clarify font licensing

    Hopefully this is everything we agreed...

    • Fonts now separated out into 2 directories
    • Makefule updated to make it easy to build minimal or full font definitions
    • Docs updated to say what's happened.

    I didn't go for the BDF files in the end as I wasn't so sure about the legality, while the other explicit license text was much more reassuring.

    Are we good to go?

    opened by peterbrittain 12
  • an unexpected keyword argument 'dir'?

    an unexpected keyword argument 'dir'?

    pyfiglet-0.6.1 from pip

    >>> f = Figlet(dir=fontPath, font='slant')
    Traceback (most recent call last):
      File "<console>", line 1, in <module>
    TypeError: __init__() got an unexpected keyword argument 'dir'
    
    opened by asakasinsky 7
  • Implemented colored print

    Implemented colored print

    Hi,

    I just implemented this because I needed to use in a project and said, why not?

    I added to keyword args into the print_figlet method

    I also created a dictionary for storing the ASCII codes of the colors, and i created a method that converts the color passed to the escaped sequence

    I also added to more params to the optparse, -c and -b

    is my first time doing a PR so hope i do it right....

    opened by mnunezdm 6
  • Thank you!  ❤ your contribution to available Python packages....

    Thank you! ❤ your contribution to available Python packages....

    I don't see a sponsor button, so I'm going to at least say

    M""""""""M dP                         dP       
    Mmmm  mmmM 88                         88       
    MMMM  MMMM 88d888b. .d8888b. 88d888b. 88  .dP  
    MMMM  MMMM 88'  `88 88'  `88 88'  `88 88888"   
    MMMM  MMMM 88    88 88.  .88 88    88 88  `8b. 
    MMMM  MMMM dP    dP `88888P8 dP    dP dP   `YP 
    MMMMMMMMMM                                     
                                                   
    M""MMMM""M                   dP 
    M. `MM' .M                   88 
    MM.    .MM .d8888b. dP    dP 88 
    MMMb  dMMM 88'  `88 88    88 dP 
    MMMM  MMMM 88.  .88 88.  .88    
    MMMM  MMMM `88888P' `88888P' oo 
    MMMMMMMMMM
    

    You've made my code so much more enjoyable, fun, and provided the library that my GUI sits on top of. Without your code, there would be no figlets in my code.

    Much happier code after finding pyfiglet

    image

    opened by PySimpleGUI 5
  • More colours for output

    More colours for output

    Using the colored module, you can access quite many colors available in the terminal.

    Is it anyhow possible to confugure pyfiglet to use color settings (as) provided by this module?

    opened by synergiator 5
  • Don't Leak File Handles

    Don't Leak File Handles

    In pypy, which is garbage collected rather than refcounted, open file handles can sometimes collect too quickly for the garbage collector and trigger the operating system's file handle limit.

    In my test code, I was seeing this failure:

    ERROR: Failure: IOError ([Errno 24] Too many open files: u'/Users/llimllib/.virtualenvs/limbopypy/site-packages/pyfiglet/fonts/stellar.flf')
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/nose/loader.py", line 414, in loadTestsFromName
        addr.filename, addr.module)
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/nose/importer.py", line 47, in importFromPath
        return self.importFromDir(dir_path, fqname)
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/nose/importer.py", line 94, in importFromDir
        mod = load_module(part_fqname, fh, filename, desc)
      File "/Users/llimllib/code/limbo/test/test_plugins/test_banner.py", line 10, in <module>
        from banner import on_message
      File "/Users/llimllib/code/limbo/test/test_plugins/../../limbo/plugins/banner.py", line 9, in <module>
        FONTS = FIGLET.getFonts()
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/pyfiglet/__init__.py", line 750, in getFonts
        return self.Font.getFonts()
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/pyfiglet/__init__.py", line 119, in getFonts
        if cls.isValidFont(font)]
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/pyfiglet/__init__.py", line 111, in isValidFont
        f = pkg_resources.resource_stream('pyfiglet.fonts', font)
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/pkg_resources/__init__.py", line 1161, in resource_stream
        self, resource_name
      File "/Users/llimllib/.virtualenvs/limbopypy/site-packages/pkg_resources/__init__.py", line 1715, in get_resource_stream
        return open(self._fn(self.module_path, resource_name), 'rb')
    IOError: [Errno 24] Too many open files: u'/Users/llimllib/.virtualenvs/limbopypy/site-packages/pyfiglet/fonts/stellar.flf'
    

    As soon as I patched pyfiglet's getFont method to close the file handle, all my tests passed.

    I don't know much about pkg_resources, but the docs promise that the result of resource_stream should be a file-like object, and so .close() should be legal on it.

    opened by llimllib 5
  • Extraneous newlines

    Extraneous newlines

    Maybe trim to 1 newline at front and end?

    Happy to work on this. Let me know what you think. Thanks for the project. :)

    Example:

    ➜  /tmp  pyfiglet -f doh 0
                       
                       
         000000000     
       00:::::::::00   
     00:::::::::::::00 
    0:::::::000:::::::0
    0::::::0   0::::::0
    0:::::0     0:::::0
    0:::::0     0:::::0
    0:::::0 000 0:::::0
    0:::::0 000 0:::::0
    0:::::0     0:::::0
    0:::::0     0:::::0
    0::::::0   0::::::0
    0:::::::000:::::::0
     00:::::::::::::00 
       00:::::::::00   
         000000000     
                       
                       
                       
                       
                       
                       
                       
    
    ➜  /tmp  
    
    help wanted 
    opened by aerickson 4
  • How to install fonts

    How to install fonts

    I've try to install custom fonts, but the command returns error.

    pyfiglet -L ansi_shadow Usage: pyfiglet [options] [text..] pyfiglet: error: no such option: -L

    opened by aeciobf 0
  • Lack of spaces with some fonts

    Lack of spaces with some fonts

    With the font ANSI Regular, the output text lacks spaces between the letters. Which, that goes without saying, makes the text pretty much unreadable. The issue occurs only with pyfiglet and not figlet.

    image

    image

    help wanted 
    opened by victorbnl 0
  • New line after each formatted string

    New line after each formatted string

    I'm trying to make a calculator, but I need to format different strings with different colors but when I add all the formatted strings together they each appear on a new line. I've been looking through the code for the library but can't find any thing that can help

    Any ideas?

    opened by G-us 0
  • No

    No "pyfiglet.fonts" module found

    I installed pyserial without the pip package manager. I could not get the SSL module to work on my Nvidia Jetson (ubuntu 14), so installing via pip was not an option. Instead, I cloned the repo and installed from the setup script.

    This is not an issue when installing via pip on another computer (same python and pip versions).

    Here are the commands I used:

    git clone https://github.com/pwaller/pyfiglet
    cd pyfiglet
    sudo python3.7 setup.py install
    

    When I checked out the most recent release tag, it solved the issue. (I deleted the previous version from site-packages)

    git clone https://github.com/pwaller/pyfiglet
    cd pyfiglet
    git checkout d7079e9 # Working version
    sudo python3.7 setup.py install
    

    Screen Shot 2022-05-02 at 1 38 33 AM

    help wanted 
    opened by The1TrueJoe 2
  • Problem with standalone JupyterLab on Windows

    Problem with standalone JupyterLab on Windows

    pyfiglet doesn't import. Here's the error:

    import pyfiglet

    KeyError Traceback (most recent call last) ~\AppData\Local\Temp/ipykernel_17912/2380198760.py in ----> 1 import pyfiglet

    C:\JupyterLab\resources\jlab_server\lib\site-packages\pyfiglet_init_.py in 57 58 if sys.platform == 'win32': ---> 59 SHARED_DIRECTORY = os.path.join(os.environ["APPDATA"], "pyfiglet") 60 else: 61 SHARED_DIRECTORY = '/usr/local/share/pyfiglet/'

    C:\JupyterLab\resources\jlab_server\lib\os.py in getitem(self, key) 673 except KeyError: 674 # raise KeyError with the original key value --> 675 raise KeyError(key) from None 676 return self.decodevalue(value) 677

    KeyError: 'APPDATA'

    And here's the contents of os.environ

    environ{'HOMEDRIVE': 'C:', 'HOMEPATH': '\Users\mike', 'JUPYTER_CONFIG_DIR': 'C:\Users\mike\AppData\Roaming\jupyterlab-desktop', 'JUPYTER_TOKEN': 'foo(removed)', 'LOGONSERVER': '\\LUNDERVAND', 'PATH': 'C:\JupyterLab\resources\jlab_server;C:\JupyterLab\resources\jlab_server\Library\mingw-w64\bin;C:\JupyterLab\resources\jlab_server\Library\usr\bin;C:\JupyterLab\resources\jlab_server\Library\bin;C:\JupyterLab\resources\jlab_server\Scripts;C:\JupyterLab\resources\jlab_server\bin;C:\Python39\Scripts\;C:\Python39\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\ProgramData\chocolatey\bin;C:\Program Files\Git\cmd;C:\Program Files\nodejs\;C:\JupyterLab;C:\Users\mike\AppData\Local\Microsoft\WindowsApps;C:\Users\mike\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\mike\AppData\Roaming\npm', 'SYSTEMDRIVE': 'C:', 'SYSTEMROOT': 'C:\WINDOWS', 'TEMP': 'C:\Users\mike\AppData\Local\Temp', 'USERDOMAIN': 'LUNDERVAND', 'USERNAME': 'mike', 'USERPROFILE': 'C:\Users\mike', 'WINDIR': 'C:\WINDOWS', 'PYDEVD_USE_FRAME_EVAL': 'NO', 'JPY_INTERRUPT_EVENT': '2248', 'IPY_INTERRUPT_EVENT': '2248', 'JPY_PARENT_PID': '1996', 'TERM': 'xterm-color', 'CLICOLOR': '1', 'PAGER': 'cat', 'GIT_PAGER': 'cat', 'MPLBACKEND': 'module://matplotlib_inline.backend_inline'}

    And here's the JupyterLab version (standalone / Electron app): Version 3.2.5-1

    help wanted 
    opened by miklevin 1
Releases(0.7.3)
Owner
Peter Waller
Peter Waller
BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes.

BaseCrack Decoder For Base Encoding Schemes BaseCrack is a tool written in Python that can decode all alphanumeric base encoding schemes. This tool ca

Mufeed VH 383 Dec 27, 2022
A minimal code sceleton for a textadveture parser written in python.

Textadventure sceleton written in python Use with a map file generated on https://www.trizbort.io Use the following Sockets for walking directions: n

null 1 Jan 6, 2022
Implementation of hashids (http://hashids.org) in Python. Compatible with Python 2 and Python 3

hashids for Python 2.7 & 3 A python port of the JavaScript hashids implementation. It generates YouTube-like hashes from one or many numbers. Use hash

David Aurelio 1.4k Jan 2, 2023
Compute distance between sequences. 30+ algorithms, pure python implementation, common interface, optional external libs usage.

TextDistance TextDistance -- python library for comparing distance between two or more sequences by many algorithms. Features: 30+ algorithms Pure pyt

Life4 3k Jan 2, 2023
Python character encoding detector

Chardet: The Universal Character Encoding Detector Detects ASCII, UTF-8, UTF-16 (2 variants), UTF-32 (4 variants) Big5, GB2312, EUC-TW, HZ-GB-2312, IS

Character Encoding Detector 1.8k Jan 8, 2023
Fuzzy String Matching in Python

FuzzyWuzzy Fuzzy string matching like a boss. It uses Levenshtein Distance to calculate the differences between sequences in a simple-to-use package.

SeatGeek 8.8k Jan 8, 2023
The Levenshtein Python C extension module contains functions for fast computation of Levenshtein distance and string similarity

Contents Maintainer wanted Introduction Installation Documentation License History Source code Authors Maintainer wanted I am looking for a new mainta

Antti Haapala 1.2k Dec 16, 2022
Paranoid text spacing in Python

pangu.py Paranoid text spacing for good readability, to automatically insert whitespace between CJK (Chinese, Japanese, Korean) and half-width charact

Vinta Chen 194 Nov 19, 2022
Python flexible slugify function

awesome-slugify Python flexible slugify function PyPi: https://pypi.python.org/pypi/awesome-slugify Github: https://github.com/dimka665/awesome-slugif

Dmitry Voronin 471 Dec 20, 2022
Python Lex-Yacc

PLY (Python Lex-Yacc) Copyright (C) 2001-2020 David M. Beazley (Dabeaz LLC) All rights reserved. Redistribution and use in source and binary forms, wi

David Beazley 2.4k Dec 31, 2022
Python library for creating PEG parsers

PyParsing -- A Python Parsing Module Introduction The pyparsing module is an alternative approach to creating and executing simple grammars, vs. the t

Pyparsing 1.7k Dec 27, 2022
A simple Python module for parsing human names into their individual components

Name Parser A simple Python (3.2+ & 2.6+) module for parsing human names into their individual components. hn.title hn.first hn.middle hn.last hn.suff

Derek Gulbranson 574 Dec 20, 2022
Python port of Google's libphonenumber

phonenumbers Python Library This is a Python port of Google's libphonenumber library It supports Python 2.5-2.7 and Python 3.x (in the same codebase,

David Drysdale 3.1k Dec 29, 2022
A Python library that provides an easy way to identify devices like mobile phones, tablets and their capabilities by parsing (browser) user agent strings.

Python User Agents user_agents is a Python library that provides an easy way to identify/detect devices like mobile phones, tablets and their capabili

Selwin Ong 1.3k Dec 22, 2022
A non-validating SQL parser module for Python

python-sqlparse - Parse SQL statements sqlparse is a non-validating SQL parser for Python. It provides support for parsing, splitting and formatting S

Andi Albrecht 3.1k Jan 4, 2023
An anthology of a variety of tools for the Persian language in Python

An anthology of a variety of tools for the Persian language in Python

Persian Tools 106 Nov 8, 2022
Widevine KEY Extractor in Python

Widevine Client 3 This was originally written by T3rry7f. This repo is slightly modified version of his repo. This only works on standard Windows! Usa

Vank0n (SJJeon) 68 Dec 29, 2022
A Python app which can convert normal text to Handwritten text.

Text to HandWritten Text ✍️ Converter Watch Tutorial for this project Usage:- Clone my repository. Open CMD in working directory. Run following comman

Kushal Bhavsar 5 Dec 11, 2022
Etranslate is a free and unlimited python library for transiting your texts

Etranslate is a free and unlimited python library for transiting your texts

Abolfazl Khalili 16 Sep 13, 2022