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)
An implementation of figlet written in Python
Overview
Comments
-
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
help wantedpyfiglet -L
, while keeping safe fonts in the main repository. -
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:
- Remove/replace the use of your package
- Convert all direct use of pyfiglet (via import) into separate process calls (via your command-line script).
- Agree with you (as the copyright holders) a separate license for my project.
- 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?
-
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.
-
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:
- Identify fonts which need removing.
- (or equivalently, which can be kept, so that the code is self standing)
- Remove them from the github repository.
- Decode if they need removing from the history of the repository.
- Remove them from source distributions on PyPi.
- Decide if they need removing from older versions (if they should be removed from the repository
- Provide a mechanism for the user to obtain/use additional fonts from sources where the license is valid.
- Identify fonts which need removing.
-
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?
-
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'
-
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....
-
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
-
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? -
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. -
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:
help wanted➜ /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
-
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
-
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.
help wanted -
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?
-
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)
help wantedgit clone https://github.com/pwaller/pyfiglet cd pyfiglet git checkout d7079e9 # Working version sudo python3.7 setup.py install
-
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
Releases(0.7.3)
-
0.7.3(Apr 14, 2015)
See #41.
Source code(tar.gz)
Source code(zip)
-
0.7.2(Sep 14, 2014)
Fixes #34.
Source code(tar.gz)
Source code(zip)
A Python3 script that simulates the user typing a text on their keyboard.
A Python3 script that simulates the user typing a text on their keyboard. (control the speed, randomness, rate of typos and more!)
An extension to detect if the articles content match its title.
Clickbait Detector An extension to detect if the articles content match its title. This was developed in a period of 24-hours in a hackathon called 'H
Word-Generator - Generates meaningful words from dictionary with given no. of letters and words.
Meaningful Word Generator Generates meaningful words from dictionary with given no. of letters and words. This might be useful for generating short li
Vastasanuli - Vastasanuli pelaa Sanuli-peliä.
Vastasanuli Vastasanuli pelaa SANULI -peliä. Se ei aina voita. Käyttö Tarttet Pythonin (3.6+). Aja make (tai lataa words.txt muualta) Asentele vaaditt
Wordle strategy: Find frequency of letters appearing in 5-letter words in the English language
Find frequency of letters appearing in 5-letter words in the English language In
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
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.
A python tool one can extract the "hash" from a WINDOWS HELLO PIN
WINHELLO2hashcat About With this tool one can extract the "hash" from a WINDOWS HELLO PIN. This hash can be cracked with Hashcat, more precisely with
The bot creates hashtags for user's texts in Russian and English.
telegram_bot_hashtags The bot creates hashtags for user's texts in Russian and English. It is a simple bot for creating hashtags. NOTE file config.py
Wikipedia Extractive Text Summarizer + Keywords Identification (entropy-based)
Wikipedia Extractive Text Summarizer + Keywords Identification (entropy-based)Wikipedia Extractive Text Summarizer + Keywords Identification (entropy-based)
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).
Hspell, the free Hebrew spellchecker and morphology engine.
Hspell, the free Hebrew spellchecker and morphology engine.
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
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,
Simple python program to auto credit your code, text, book, whatever!
Credit Simple python program to auto credit your code, text, book, whatever! Setup First change credit_text to whatever text you would like to credit
A generator library for concise, unambiguous and URL-safe UUIDs.
Description shortuuid is a simple python library that generates concise, unambiguous, URL-safe UUIDs. Often, one needs to use non-sequential IDs in pl
一个可以可以统计群组用户发言,并且能将聊天内容生成词云的机器人
当前版本 v2.2 更新维护日志 更新维护日志 有问题请加群组反馈 Telegram 交流反馈群组 点击加入 演示 配置要求 内存:1G以上 安装方法 使用 Docker 安装 Docker官方安装
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
汉字转拼音(pypinyin)
汉字拼音转换工具(Python 版) 将汉字转为拼音。可以用于汉字注音、排序、检索(Russian translation) 。 基于 hotoo/pinyin 开发。 Documentation: http://pypinyin.rtfd.io/ GitHub: https://github.co
Question answering on russian with XLMRobertaLarge as a service
QA Roberta Ru SaaS Question answering on russian with XLMRobertaLarge as a service. Thanks for the model to Alexander Kaigorodov. Stack Flask Gunicorn