byteforge-figlet 2.0.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- byteforge_figlet/__init__.py +21 -0
- byteforge_figlet/__main__.py +61 -0
- byteforge_figlet/fig_font.py +255 -0
- byteforge_figlet/fig_let_renderer.py +333 -0
- byteforge_figlet/fonts/.gitkeep +0 -0
- byteforge_figlet/fonts/small.flf +1062 -0
- byteforge_figlet/layout_mode.py +18 -0
- byteforge_figlet/smushing_rules.py +32 -0
- byteforge_figlet-2.0.4.dist-info/METADATA +229 -0
- byteforge_figlet-2.0.4.dist-info/RECORD +13 -0
- byteforge_figlet-2.0.4.dist-info/WHEEL +4 -0
- byteforge_figlet-2.0.4.dist-info/entry_points.txt +2 -0
- byteforge_figlet-2.0.4.dist-info/licenses/LICENSE +21 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"""Layout mode enumeration for FIGLet rendering."""
|
|
2
|
+
|
|
3
|
+
from enum import IntEnum
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class LayoutMode(IntEnum):
|
|
7
|
+
"""Controls how FIGLet characters are horizontally arranged."""
|
|
8
|
+
|
|
9
|
+
FullSize = -1
|
|
10
|
+
"""Characters are placed side by side with no overlap."""
|
|
11
|
+
|
|
12
|
+
Kerning = 0
|
|
13
|
+
"""Characters are moved as close together as possible without overlapping."""
|
|
14
|
+
|
|
15
|
+
Smushing = 1
|
|
16
|
+
"""Characters may overlap and be merged according to smushing rules."""
|
|
17
|
+
|
|
18
|
+
Default = 1 # alias for Smushing
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""Smushing rules flags for FIGLet rendering."""
|
|
2
|
+
|
|
3
|
+
from enum import IntFlag
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class SmushingRules(IntFlag):
|
|
7
|
+
"""Flags that control which smushing rules are applied during rendering."""
|
|
8
|
+
|
|
9
|
+
NONE = 0
|
|
10
|
+
"""No smushing rules apply."""
|
|
11
|
+
|
|
12
|
+
EqualCharacter = 1
|
|
13
|
+
"""Rule 1: Two identical characters smush into one."""
|
|
14
|
+
|
|
15
|
+
Underscore = 2
|
|
16
|
+
"""Rule 2: An underscore is replaced by any character in the hierarchy."""
|
|
17
|
+
|
|
18
|
+
Hierarchy = 4
|
|
19
|
+
"""Rule 3: A character of higher hierarchy replaces one of lower hierarchy."""
|
|
20
|
+
|
|
21
|
+
OppositePair = 8
|
|
22
|
+
"""Rule 4: Opposing brackets/braces/parens smush into a vertical bar."""
|
|
23
|
+
|
|
24
|
+
BigX = 16
|
|
25
|
+
"""Rule 5: /+\\ becomes |, \\+/ becomes Y, >+< becomes X."""
|
|
26
|
+
|
|
27
|
+
HardBlank = 32
|
|
28
|
+
"""Rule 6: Two hardblanks smush into one hardblank."""
|
|
29
|
+
|
|
30
|
+
def has_rule(self, rule: "SmushingRules") -> bool:
|
|
31
|
+
"""Return True if this set of rules includes the given rule."""
|
|
32
|
+
return bool(self & rule)
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: byteforge-figlet
|
|
3
|
+
Version: 2.0.4
|
|
4
|
+
Summary: Python FIGLet rendering library — render text as ASCII art using .flf fonts
|
|
5
|
+
Project-URL: Homepage, https://github.com/PaulStSmith/figlet-comment-generator
|
|
6
|
+
Project-URL: Repository, https://github.com/PaulStSmith/figlet-comment-generator
|
|
7
|
+
Project-URL: Issues, https://github.com/PaulStSmith/figlet-comment-generator/issues
|
|
8
|
+
Author-email: PaulStSmith <paul@byteforge.dev>
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ascii-art,cli,figlet,fonts,text-art
|
|
12
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Topic :: Terminals
|
|
22
|
+
Classifier: Topic :: Text Processing :: Fonts
|
|
23
|
+
Requires-Python: >=3.9
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
# 🐍 **BYTEFORGE FIGLET SUITE — byteforge-figlet (Python Library)**
|
|
27
|
+
|
|
28
|
+
```
|
|
29
|
+
██████╗ ██╗ ██╗████████╗███████╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗
|
|
30
|
+
██╔══██╗╚██╗ ██╔╝╚══██╔══╝██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝
|
|
31
|
+
██████╔╝ ╚████╔╝ ██║ █████╗ █████╗ ██║ ██║██████╔╝██║ ███╗█████╗
|
|
32
|
+
██╔══██╗ ╚██╔╝ ██║ ██╔══╝ ██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝
|
|
33
|
+
██████╔╝ ██║ ██║ ███████╗██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗
|
|
34
|
+
╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
|
|
35
|
+
███████╗██╗ ██████╗ ██╗ ███████╗████████╗ ███████╗██╗ ██╗██╗████████╗███████╗
|
|
36
|
+
██╔════╝██║██╔════╝ ██║ ██╔════╝╚══██╔══╝ ██╔════╝██║ ██║██║╚══██╔══╝██╔════╝
|
|
37
|
+
█████╗ ██║██║ ███╗██║ █████╗ ██║ ███████╗██║ ██║██║ ██║ █████╗
|
|
38
|
+
██╔══╝ ██║██║ ██║██║ ██╔══╝ ██║ ╚════██║██║ ██║██║ ██║ ██╔══╝
|
|
39
|
+
██║ ██║╚██████╔╝███████╗███████╗ ██║ ███████║╚██████╔╝██║ ██║ ███████╗
|
|
40
|
+
╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
> **byteforge-figlet**
|
|
44
|
+
> *A fast, spec-compliant FIGLet engine for Python — zero dependencies.*
|
|
45
|
+
|
|
46
|
+
## 📘 Overview
|
|
47
|
+
|
|
48
|
+
`byteforge-figlet` is a Python implementation of the FIGLet rendering engine used across the ByteForge FIGLet Suite.
|
|
49
|
+
|
|
50
|
+
It provides a robust and efficient implementation of the FIGLet specification, allowing you to create ASCII art from text using FIGLet fonts. It supports all standard FIGLet features including various smushing rules, layout modes, ANSI color preservation, and Unicode.
|
|
51
|
+
|
|
52
|
+
The library ships with the built-in **small** font so it works out of the box with no additional downloads.
|
|
53
|
+
|
|
54
|
+
## ✨ Features
|
|
55
|
+
|
|
56
|
+
- 🔤 Render FIGLet text using any `.flf` font
|
|
57
|
+
- 📄 Full FIGLet font (`.flf`) file parsing and loading
|
|
58
|
+
- 🗜️ Automatic handling of compressed/zipped font files
|
|
59
|
+
- 🎨 ANSI color support for terminal output
|
|
60
|
+
- 🌏 Unicode support
|
|
61
|
+
- 📝 Paragraph formatting support
|
|
62
|
+
- ⚙️ Supports Full Size, Kerning, and Smushing layout modes
|
|
63
|
+
- 🧠 Implements all official smushing rules
|
|
64
|
+
- 📦 Default embedded font included — works out of the box
|
|
65
|
+
- 🚀 Zero dependencies — stdlib only
|
|
66
|
+
- 🐍 Python 3.9+
|
|
67
|
+
- 💻 Includes a `figprint` CLI command
|
|
68
|
+
|
|
69
|
+
### Sample Output
|
|
70
|
+
|
|
71
|
+
```
|
|
72
|
+
_ _ _ _ _ _ _ _ _
|
|
73
|
+
| || |___| | |___ \ \ / /__ _ _| |__| | |
|
|
74
|
+
| __ / -_) | / _ \_ \ \/\/ / _ \ '_| / _` |_|
|
|
75
|
+
|_||_\___|_|_\___( ) \_/\_/\___/_| |_\__,_(_)
|
|
76
|
+
|/
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## 🛠 Installation
|
|
80
|
+
|
|
81
|
+
Install via pip:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install byteforge-figlet
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## 🚀 Quick Start
|
|
88
|
+
|
|
89
|
+
### Basic Usage
|
|
90
|
+
|
|
91
|
+
```python
|
|
92
|
+
from byteforge_figlet import FIGLetRenderer
|
|
93
|
+
|
|
94
|
+
print(FIGLetRenderer.render("Hello World!"))
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Using a Custom Font
|
|
98
|
+
|
|
99
|
+
```python
|
|
100
|
+
from byteforge_figlet import FIGFont, FIGLetRenderer
|
|
101
|
+
|
|
102
|
+
font = FIGFont.from_file("/path/to/myfont.flf")
|
|
103
|
+
print(FIGLetRenderer.render("Hello!", font=font))
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
### Choosing a Layout Mode
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from byteforge_figlet import FIGLetRenderer, LayoutMode
|
|
110
|
+
|
|
111
|
+
# Full Size — no character overlap
|
|
112
|
+
print(FIGLetRenderer.render("Hi", mode=LayoutMode.FullSize))
|
|
113
|
+
|
|
114
|
+
# Kerning — characters touch but don't overlap
|
|
115
|
+
print(FIGLetRenderer.render("Hi", mode=LayoutMode.Kerning))
|
|
116
|
+
|
|
117
|
+
# Smushing — characters may merge (default)
|
|
118
|
+
print(FIGLetRenderer.render("Hi", mode=LayoutMode.Smushing))
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Renderer Instance
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
from byteforge_figlet import FIGLetRenderer, LayoutMode
|
|
125
|
+
|
|
126
|
+
renderer = FIGLetRenderer(mode=LayoutMode.Kerning, line_separator="\n")
|
|
127
|
+
print(renderer.render_text("Hello\nWorld"))
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 💻 CLI Usage
|
|
131
|
+
|
|
132
|
+
The `figprint` command is installed automatically with the package:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
figprint "Hello World"
|
|
136
|
+
figprint "Hello World" --font /path/to/font.flf
|
|
137
|
+
figprint "Hello World" --mode kerning
|
|
138
|
+
figprint "Hello World" --mode full
|
|
139
|
+
figprint --help
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
Or run as a module:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
python -m byteforge_figlet "Hello World"
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## 📐 API Reference
|
|
149
|
+
|
|
150
|
+
### `FIGFont`
|
|
151
|
+
|
|
152
|
+
| Method / Property | Description |
|
|
153
|
+
|---|---|
|
|
154
|
+
| `FIGFont.default` | The built-in `small` font (class property, cached) |
|
|
155
|
+
| `FIGFont.from_file(path)` | Load a font from a `.flf` file path |
|
|
156
|
+
| `FIGFont.from_stream(stream)` | Load a font from a binary stream |
|
|
157
|
+
| `FIGFont.from_text(text)` | Load a font from a string |
|
|
158
|
+
| `FIGFont.from_lines(lines)` | Load a font from a list of strings |
|
|
159
|
+
| `.height` | Character height in rows |
|
|
160
|
+
| `.hard_blank` | Hard blank character |
|
|
161
|
+
| `.smushing_rules` | `SmushingRules` flags for this font |
|
|
162
|
+
| `.has_smushing_rule(rule)` | Check if a specific rule is set |
|
|
163
|
+
|
|
164
|
+
### `FIGLetRenderer`
|
|
165
|
+
|
|
166
|
+
| Method | Description |
|
|
167
|
+
|---|---|
|
|
168
|
+
| `FIGLetRenderer.render(text, ...)` | Static method — render and return ASCII art string |
|
|
169
|
+
| `renderer.render_text(text)` | Instance method — render using configured settings |
|
|
170
|
+
|
|
171
|
+
**Constructor parameters:**
|
|
172
|
+
|
|
173
|
+
| Parameter | Type | Default | Description |
|
|
174
|
+
|---|---|---|---|
|
|
175
|
+
| `font` | `FIGFont \| None` | built-in small | Font to use |
|
|
176
|
+
| `mode` | `LayoutMode` | `Smushing` | Layout mode |
|
|
177
|
+
| `line_separator` | `str \| None` | `os.linesep` | Line ending |
|
|
178
|
+
| `use_ansi_colors` | `bool` | `False` | Preserve ANSI color codes |
|
|
179
|
+
| `paragraph_mode` | `bool` | `True` | Treat `\n` as paragraph breaks |
|
|
180
|
+
|
|
181
|
+
### `LayoutMode`
|
|
182
|
+
|
|
183
|
+
| Value | Description |
|
|
184
|
+
|---|---|
|
|
185
|
+
| `LayoutMode.FullSize` (`-1`) | No character overlap |
|
|
186
|
+
| `LayoutMode.Kerning` (`0`) | Minimal spacing, no merge |
|
|
187
|
+
| `LayoutMode.Smushing` (`1`) | Characters may merge (default) |
|
|
188
|
+
|
|
189
|
+
### `SmushingRules`
|
|
190
|
+
|
|
191
|
+
| Flag | Value | Description |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `SmushingRules.EqualCharacter` | 1 | Two identical characters → one |
|
|
194
|
+
| `SmushingRules.Underscore` | 2 | Underscore replaced by hierarchy char |
|
|
195
|
+
| `SmushingRules.Hierarchy` | 4 | Higher-ranked char wins |
|
|
196
|
+
| `SmushingRules.OppositePair` | 8 | Opposing brackets → `\|` |
|
|
197
|
+
| `SmushingRules.BigX` | 16 | `/+\` → `\|`, `\+/` → `Y`, `>+<` → `X` |
|
|
198
|
+
| `SmushingRules.HardBlank` | 32 | Two hardblanks → one hardblank |
|
|
199
|
+
|
|
200
|
+
## 🔗 ByteForge FIGLet Suite
|
|
201
|
+
|
|
202
|
+
| Component | Description |
|
|
203
|
+
|---|---|
|
|
204
|
+
| [**FIGLet** (.NET)](https://www.nuget.org/packages/ByteForge.FIGLet) | Core C# library on NuGet |
|
|
205
|
+
| [**@byte-forge/figlet** (TypeScript)](https://www.npmjs.com/package/@byte-forge/figlet) | TypeScript library on npm |
|
|
206
|
+
| [**byteforge-figlet** (Python)](https://pypi.org/project/byteforge-figlet) | Python library on PyPI |
|
|
207
|
+
| [**FIGPrint**](https://github.com/PaulStSmith/FIGLetAddIn/releases) | .NET CLI tool |
|
|
208
|
+
| [**VS Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.FIGLetCommentGenerator) | Visual Studio 2022+ extension |
|
|
209
|
+
| [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.figlet-comment-generator) | VS Code extension |
|
|
210
|
+
|
|
211
|
+
## 📜 License
|
|
212
|
+
|
|
213
|
+
This library is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
|
|
214
|
+
|
|
215
|
+
## 💡 Credits
|
|
216
|
+
|
|
217
|
+
- Original FIGLet concept by **Frank, Ian & Glenn**
|
|
218
|
+
- Implementations by **Paulo Santos (ByteForge)**
|
|
219
|
+
- FIGLet specification: [figlet.org](http://www.figlet.org/)
|
|
220
|
+
|
|
221
|
+
## Support
|
|
222
|
+
|
|
223
|
+
If you encounter any issues or have feature requests, please:
|
|
224
|
+
1. Search existing [issues](https://github.com/PaulStSmith/figlet-comment-generator/issues)
|
|
225
|
+
2. Create a new issue if needed
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
Made with ❤️ by Paulo Santos
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
byteforge_figlet/__init__.py,sha256=aOwtlM8gGlHdA3xQtwVVU3bZ7LzTsYXX9w6W2UohK1A,549
|
|
2
|
+
byteforge_figlet/__main__.py,sha256=AdCiH9mvkvvDypmXG7oO3egoaTL52Ohb3S7YMf6WzS8,1757
|
|
3
|
+
byteforge_figlet/fig_font.py,sha256=aIePuN-SNFyAtqAWgWw9o0XoSBMwv1ujzZMVgwqFiYY,9651
|
|
4
|
+
byteforge_figlet/fig_let_renderer.py,sha256=2-A1-X9oEe42bQ39QcaJdJNyGeAdGFkGpiZNX9Dz_Qg,12173
|
|
5
|
+
byteforge_figlet/layout_mode.py,sha256=wxbzAoD1GHI5OI3eytDvarhT_zps7-WSEgnYSWGbKek,488
|
|
6
|
+
byteforge_figlet/smushing_rules.py,sha256=nWHkKfMxXiJB2SYmKt79iaXZIm8nkVp7HPoEMLIBXTk,939
|
|
7
|
+
byteforge_figlet/fonts/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
+
byteforge_figlet/fonts/small.flf,sha256=jugBn6m34igxuEEEUAgL0_mfEtAz48hVeOIuqLekMio,11900
|
|
9
|
+
byteforge_figlet-2.0.4.dist-info/METADATA,sha256=gTnztAMBmjiniTjVNWd5tJ_S9qWk12kBcSI8WHO_wso,9869
|
|
10
|
+
byteforge_figlet-2.0.4.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
11
|
+
byteforge_figlet-2.0.4.dist-info/entry_points.txt,sha256=kum9RlaWA-ecPNXxc_BWdj22wbxRgjzgmYKH6ZmUEPM,60
|
|
12
|
+
byteforge_figlet-2.0.4.dist-info/licenses/LICENSE,sha256=123n61EbdLVCrgINOjkuGgJ0aYyJfBkwbdWD6eDNdng,1073
|
|
13
|
+
byteforge_figlet-2.0.4.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Paulo Santos
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|