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
REST API for sentence tokenization and embedding using Multilingual Universal Sentence Encoder.

MUSE stands for Multilingual Universal Sentence Encoder - multilingual extension (supports 16 languages) of Universal Sentence Encoder (USE).

Dani El-Ayyass 47 Sep 05, 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
Getting git-style versioning working on RDFlib

Getting git-style versioning working on RDFlib

Gabe Fierro 1 Feb 01, 2022
A program that looks through entered text and replaces certain commands with mathematical symbols

TextToSymbolConverter A program that looks through entered text and replaces certain commands with mathematical symbols Example: Syntax: Enter text in

1 Jan 02, 2022
Utility for Text Normalisation or Inverse Normalisation

Text Processor Text Normalisation or Inverse Normalisation for Indonesian, e.g. measurements "123 kg" - "seratus dua puluh tiga kilogram" Currency/Mo

Cahya Wirawan 2 Aug 11, 2022
LazyText is inspired b the idea of lazypredict, a library which helps build a lot of basic models without much code.

LazyText is inspired b the idea of lazypredict, a library which helps build a lot of basic models without much code. LazyText is for text what lazypredict is for numeric data.

Jay Vala 13 Nov 04, 2022
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 08, 2023
Convert ebooks with few clicks on Telegram!

E-Book Converter Bot A bot that converts e-books to various formats, powered by calibre! It currently supports 34 input formats and 19 output formats.

Youssif Shaaban Alsager 45 Jan 05, 2023
Athens: a great tool for taking notes and organising knowldge

AthensSyncer Athens is a great tool for taking notes and organising knowldge. But it is a bummer that you cannot use it accross multiple devices. Well

6 Dec 14, 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
Deasciify-highlighted - A Python script for deasciifying text to Turkish and copying clipboard

deasciify-highlighted is a Python script for deasciifying text to Turkish and copying clipboard.

Ümit Altıntaş 3 Mar 18, 2022
A Python package to facilitate research on building and evaluating automated scoring models.

Rater Scoring Modeling Tool Introduction Automated scoring of written and spoken test responses is a growing field in educational natural language pro

ETS 59 Oct 10, 2022
A query extract python package

A query extract python package

Fayas Noushad 4 Nov 28, 2021
Hspell, the free Hebrew spellchecker and morphology engine.

Hspell, the free Hebrew spellchecker and morphology engine.

16 Sep 15, 2022
py-trans is a Free Python library for translate text into different languages.

Free Python library to translate text into different languages.

I'm Not A Bot #Left_TG 13 Aug 27, 2022
A pipeline for making highlighted text stand-alone.

title emoji colorFrom colorTo sdk app_file pinned decontextualizer 📤 green gray streamlit main.py false Decontextualizer As a second step in improvin

Paul Bricman 26 Dec 17, 2022
Converts a Bangla numeric string to literal words.

Bangla Number in Words Converts a Bangla numeric string to literal words. Install $ pip install banglanum2words Usage

Syed Mostofa Monsur 3 Aug 29, 2022
一个可以可以统计群组用户发言,并且能将聊天内容生成词云的机器人

当前版本 v2.2 更新维护日志 更新维护日志 有问题请加群组反馈 Telegram 交流反馈群组 点击加入 演示 配置要求 内存:1G以上 安装方法 使用 Docker 安装 Docker官方安装

机器人总动员 117 Dec 29, 2022
Repository containing the code for An-Gocair text normaliser

Scottish Gaelic Text Normaliser The following project contains the code and resources for the Scottish Gaelic text normalisation project. The repo can

3 Jun 28, 2022