byteforge-figlet 2.0.6__tar.gz → 2.0.9__tar.gz

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.
Files changed (24) hide show
  1. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/.gitignore +10 -3
  2. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/PKG-INFO +146 -45
  3. byteforge_figlet-2.0.9/README.md +305 -0
  4. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/__init__.py +1 -1
  5. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/pyproject.toml +1 -1
  6. byteforge_figlet-2.0.6/README.md +0 -204
  7. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/LICENSE +0 -0
  8. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/__main__.py +0 -0
  9. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/fig_font.py +0 -0
  10. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/fig_let_renderer.py +0 -0
  11. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/fonts/.gitkeep +0 -0
  12. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/fonts/small.flf +0 -0
  13. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/layout_mode.py +0 -0
  14. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/byteforge_figlet/smushing_rules.py +0 -0
  15. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/TestFonts/mini-fixed.flf +0 -0
  16. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/TestFonts/smushing-test.flf +0 -0
  17. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/__init__.py +0 -0
  18. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_figfont.py +0 -0
  19. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_integration.py +0 -0
  20. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_layout_mode.py +0 -0
  21. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_performance.py +0 -0
  22. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_renderer.py +0 -0
  23. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_smushing_rules.py +0 -0
  24. {byteforge_figlet-2.0.6 → byteforge_figlet-2.0.9}/tests/test_utilities.py +0 -0
@@ -317,6 +317,13 @@ paket-files/
317
317
  __pycache__/
318
318
  *.pyc
319
319
 
320
+ # Our Python library cache directories
321
+ FIGLet.Python/.pytest_cache/
322
+
323
+ # Python virtual environments
324
+ venv/
325
+ .venv/
326
+
320
327
  # Cake - Uncomment if you are using it
321
328
  # tools/**
322
329
  # !tools/packages.config
@@ -363,9 +370,9 @@ MigrationBackup/
363
370
  # Fody - auto-generated XML schema
364
371
  FodyWeavers.xsd
365
372
 
366
- # Claude Code worktrees
367
- .claude/worktrees/
368
- .claude/settings.local.json
373
+ # Claude Code
374
+ CLAUDE.md
375
+ .claude/
369
376
 
370
377
  # VS Code extension — webpack bundles (generated by `npm run build:webview`)
371
378
  FIGLet.VSCodeExtension/media/*.js
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: byteforge-figlet
3
- Version: 2.0.6
3
+ Version: 2.0.9
4
4
  Summary: Python FIGLet rendering library — render text as ASCII art using .flf fonts
5
5
  Project-URL: Homepage, https://github.com/PaulStSmith/figlet-comment-generator
6
6
  Project-URL: Repository, https://github.com/PaulStSmith/figlet-comment-generator
@@ -23,7 +23,7 @@ Classifier: Topic :: Text Processing :: Fonts
23
23
  Requires-Python: >=3.9
24
24
  Description-Content-Type: text/markdown
25
25
 
26
- # 🐍 **BYTEFORGE FIGLET SUITE — byteforge-figlet (Python Library)**
26
+ # 🐍 **BYTEFORGE FIGLET SUITE — byteforge-figlet (Python Library)**
27
27
 
28
28
  ```
29
29
  ██████╗ ██╗ ██╗████████╗███████╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗
@@ -149,64 +149,165 @@ python -m byteforge_figlet "Hello World"
149
149
 
150
150
  ### `FIGFont`
151
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 |
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
+ | `.characters` | `dict` mapping character code point → glyph rows |
162
+ | `.smushing_rules` | `SmushingRules` flags for this font |
163
+ | `.print_direction` | `0` = left-to-right, `1` = right-to-left |
164
+ | `.has_smushing_rule(rule)` | Check if a specific rule is set |
163
165
 
164
166
  ### `FIGLetRenderer`
165
167
 
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 |
168
+ | Member | Description |
169
+ | ---------------------------------- | ------------------------------------------------------ |
170
+ | `FIGLetRenderer.render(text, ...)` | Static method — render and return ASCII art string |
171
+ | `renderer.render_text(text)` | Instance method — render using configured settings |
172
+ | `.layout_mode` | Active `LayoutMode` |
173
+ | `.line_separator` | Line separator string (default `os.linesep`) |
174
+ | `.use_ansi_colors` | Whether to preserve ANSI color codes through rendering |
175
+ | `.paragraph_mode` | Whether blank lines produce separate FIGLet renders |
170
176
 
171
177
  **Constructor parameters:**
172
178
 
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 |
179
+ | Parameter | Type | Default | Description |
180
+ | ----------------- | ------------------- | ------------ | ------------------------------ |
181
+ | `font` | `FIGFont | None` | `built-in small` | Font to use |
182
+ | `mode` | `LayoutMode` | `Smushing` | Layout mode |
183
+ | `line_separator` | `str | None` | `os.linesep` | Line separator |
184
+ | `use_ansi_colors` | `bool` | `False` | Preserve ANSI color codes |
185
+ | `paragraph_mode` | `bool` | `True` | Treat `\n` as paragraph breaks |
180
186
 
181
187
  ### `LayoutMode`
182
188
 
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) |
189
+ | Value | Description |
190
+ | ---------------------------- | ------------------------------ |
191
+ | `LayoutMode.FullSize` (`-1`) | No character overlap |
192
+ | `LayoutMode.Kerning` (`0`) | Minimal spacing, no merge |
193
+ | `LayoutMode.Smushing` (`1`) | Characters may merge (default) |
188
194
 
189
195
  ### `SmushingRules`
190
196
 
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 hardblanksone hardblank |
197
+ | Flag | Value | Description |
198
+ | ------------------------------ | ----- | -------------------------------------- |
199
+ | `SmushingRules.None` | 0 | No smushing rules active |
200
+ | `SmushingRules.EqualCharacter` | 1 | Two identical characters one |
201
+ | `SmushingRules.Underscore` | 2 | Underscore replaced by hierarchy char |
202
+ | `SmushingRules.Hierarchy` | 4 | Higher-ranked char wins |
203
+ | `SmushingRules.OppositePair` | 8 | Opposing brackets`\|` |
204
+ | `SmushingRules.BigX` | 16 | `/+\` `\|`, `\+/``Y`, `>+<` → `X` |
205
+ | `SmushingRules.HardBlank` | 32 | Two hardblanks → one hardblank |
206
+
207
+ ## 📁 Font Support
208
+
209
+ - Standard `.flf` font files
210
+ - Compressed `.flf` files inside `.zip` archives (auto-detected by PK magic bytes)
211
+
212
+ ## 🎨 ANSI Color Support
213
+
214
+ The library preserves ANSI color codes through the rendering process, allowing you to create colorful FIGLet text in terminals:
215
+
216
+ ```python
217
+ from byteforge_figlet import FIGLetRenderer
218
+
219
+ renderer = FIGLetRenderer(use_ansi_colors=True)
220
+
221
+ colorful_text = '\x1b[31mRed\x1b[0m \x1b[32mGreen\x1b[0m \x1b[34mBlue\x1b[0m'
222
+ print(renderer.render_text(colorful_text))
223
+ ```
224
+
225
+ ## 📝 Paragraph Mode
226
+
227
+ When enabled (the default), blank lines in the input produce separate FIGLet renderings spaced by the font's character height:
228
+
229
+ ```python
230
+ from byteforge_figlet import FIGLetRenderer
231
+
232
+ renderer = FIGLetRenderer()
233
+
234
+ paragraphs = 'Paragraph 1\n\nParagraph 2'
235
+ print(renderer.render_text(paragraphs))
236
+ ```
237
+ Output:
238
+ ```text
239
+ ___ _ _
240
+ | _ \__ _ _ _ __ _ __ _ _ _ __ _ _ __| |_ / |
241
+ | _/ _` | '_/ _` / _` | '_/ _` | '_ \ ' \ | |
242
+ |_| \__,_|_| \__,_\__, |_| \__,_| .__/_||_| |_|
243
+ |___/ |_|
244
+
245
+
246
+
247
+
248
+ ___ _ ___
249
+ | _ \__ _ _ _ __ _ __ _ _ _ __ _ _ __| |_ |_ )
250
+ | _/ _` | '_/ _` / _` | '_/ _` | '_ \ ' \ / /
251
+ |_| \__,_|_| \__,_\__, |_| \__,_| .__/_||_| /___|
252
+ |___/ |_|
253
+
254
+ ```
255
+
256
+ ## 🌏 Unicode Support
257
+
258
+ The library fully supports Unicode characters. Characters not present in the font are skipped gracefully:
259
+
260
+ ```python
261
+ from byteforge_figlet import FIGLetRenderer
262
+
263
+ renderer = FIGLetRenderer()
264
+ print(renderer.render_text('Hello 😊 World!'))
265
+ ```
266
+ Output:
267
+ ```
268
+ _ _ _ _ __ __ _ _ _
269
+ | || |___| | |___ \ \ / /__ _ _| |__| | |
270
+ | __ / -_) | / _ \ \ \/\/ / _ \ '_| / _` |_|
271
+ |_||_\___|_|_\___/ \_/\_/\___/_| |_\__,_(_)
272
+
273
+ ```
274
+
275
+ ## 🏗 Implementation Details
276
+
277
+ 1. **FIGFont** — Parses `.flf` font files; supports loading from files, streams, strings, or line lists; handles ZIP-compressed font files; manages smushing rule configuration.
278
+
279
+ 2. **FIGLetRenderer** — Converts input text to FIGLet output; implements character smushing logic; handles different layout modes; processes ANSI color codes in a single pre-pass; supports paragraph formatting.
280
+
281
+ 3. **LayoutMode** — Enumeration controlling how characters are combined during rendering.
282
+
283
+ 4. **SmushingRules** — Flags enumeration defining which character-combining rules are active.
284
+
285
+ ## ⚡ Performance Considerations
286
+
287
+ - Default font is cached after the first load and reused across all calls
288
+ - ANSI color codes are handled in a single pre-pass, not during rendering
289
+ - Efficient string building throughout the rendering pipeline
290
+
291
+ ## 🤝 Contributing
292
+
293
+ Contributions are welcome!
294
+ To contribute:
295
+
296
+ 1. Fork the repository
297
+ 2. Create a feature branch
298
+ 3. Commit your changes
299
+ 4. Open a Pull Request
199
300
 
200
301
  ## 🔗 ByteForge FIGLet Suite
201
302
 
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 |
303
+ | Component | Description |
304
+ | ----------------------------------------------------------------------------------------------------------------- | ----------------------------- |
305
+ | [**FIGLet** (.NET)](https://www.nuget.org/packages/ByteForge.FIGLet) | Core C# library on NuGet |
306
+ | [**@byte-forge/figlet** (TypeScript)](https://www.npmjs.com/package/@byte-forge/figlet) | TypeScript library on npm |
307
+ | [**byteforge-figlet** (Python)](https://pypi.org/project/byteforge-figlet) | Python library on PyPI |
308
+ | [**FIGPrint**](https://github.com/PaulStSmith/FIGLetAddIn/releases) | .NET CLI tool |
309
+ | [**VS Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.FIGLetCommentGenerator) | Visual Studio 2022+ extension |
310
+ | [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.figlet-comment-generator) | VS Code extension |
210
311
 
211
312
  ## 📜 License
212
313
 
@@ -0,0 +1,305 @@
1
+ # 🐍 **BYTEFORGE FIGLET SUITE — byteforge-figlet (Python Library)**
2
+
3
+ ```
4
+ ██████╗ ██╗ ██╗████████╗███████╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗
5
+ ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝
6
+ ██████╔╝ ╚████╔╝ ██║ █████╗ █████╗ ██║ ██║██████╔╝██║ ███╗█████╗
7
+ ██╔══██╗ ╚██╔╝ ██║ ██╔══╝ ██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝
8
+ ██████╔╝ ██║ ██║ ███████╗██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗
9
+ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
10
+ ███████╗██╗ ██████╗ ██╗ ███████╗████████╗ ███████╗██╗ ██╗██╗████████╗███████╗
11
+ ██╔════╝██║██╔════╝ ██║ ██╔════╝╚══██╔══╝ ██╔════╝██║ ██║██║╚══██╔══╝██╔════╝
12
+ █████╗ ██║██║ ███╗██║ █████╗ ██║ ███████╗██║ ██║██║ ██║ █████╗
13
+ ██╔══╝ ██║██║ ██║██║ ██╔══╝ ██║ ╚════██║██║ ██║██║ ██║ ██╔══╝
14
+ ██║ ██║╚██████╔╝███████╗███████╗ ██║ ███████║╚██████╔╝██║ ██║ ███████╗
15
+ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝
16
+ ```
17
+
18
+ > **byteforge-figlet**
19
+ > *A fast, spec-compliant FIGLet engine for Python — zero dependencies.*
20
+
21
+ ## 📘 Overview
22
+
23
+ `byteforge-figlet` is a Python implementation of the FIGLet rendering engine used across the ByteForge FIGLet Suite.
24
+
25
+ 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.
26
+
27
+ The library ships with the built-in **small** font so it works out of the box with no additional downloads.
28
+
29
+ ## ✨ Features
30
+
31
+ - 🔤 Render FIGLet text using any `.flf` font
32
+ - 📄 Full FIGLet font (`.flf`) file parsing and loading
33
+ - 🗜️ Automatic handling of compressed/zipped font files
34
+ - 🎨 ANSI color support for terminal output
35
+ - 🌏 Unicode support
36
+ - 📝 Paragraph formatting support
37
+ - ⚙️ Supports Full Size, Kerning, and Smushing layout modes
38
+ - 🧠 Implements all official smushing rules
39
+ - 📦 Default embedded font included — works out of the box
40
+ - 🚀 Zero dependencies — stdlib only
41
+ - 🐍 Python 3.9+
42
+ - 💻 Includes a `figprint` CLI command
43
+
44
+ ### Sample Output
45
+
46
+ ```
47
+ _ _ _ _ _ _ _ _ _
48
+ | || |___| | |___ \ \ / /__ _ _| |__| | |
49
+ | __ / -_) | / _ \_ \ \/\/ / _ \ '_| / _` |_|
50
+ |_||_\___|_|_\___( ) \_/\_/\___/_| |_\__,_(_)
51
+ |/
52
+ ```
53
+
54
+ ## 🛠 Installation
55
+
56
+ Install via pip:
57
+
58
+ ```bash
59
+ pip install byteforge-figlet
60
+ ```
61
+
62
+ ## 🚀 Quick Start
63
+
64
+ ### Basic Usage
65
+
66
+ ```python
67
+ from byteforge_figlet import FIGLetRenderer
68
+
69
+ print(FIGLetRenderer.render("Hello World!"))
70
+ ```
71
+
72
+ ### Using a Custom Font
73
+
74
+ ```python
75
+ from byteforge_figlet import FIGFont, FIGLetRenderer
76
+
77
+ font = FIGFont.from_file("/path/to/myfont.flf")
78
+ print(FIGLetRenderer.render("Hello!", font=font))
79
+ ```
80
+
81
+ ### Choosing a Layout Mode
82
+
83
+ ```python
84
+ from byteforge_figlet import FIGLetRenderer, LayoutMode
85
+
86
+ # Full Size — no character overlap
87
+ print(FIGLetRenderer.render("Hi", mode=LayoutMode.FullSize))
88
+
89
+ # Kerning — characters touch but don't overlap
90
+ print(FIGLetRenderer.render("Hi", mode=LayoutMode.Kerning))
91
+
92
+ # Smushing — characters may merge (default)
93
+ print(FIGLetRenderer.render("Hi", mode=LayoutMode.Smushing))
94
+ ```
95
+
96
+ ### Renderer Instance
97
+
98
+ ```python
99
+ from byteforge_figlet import FIGLetRenderer, LayoutMode
100
+
101
+ renderer = FIGLetRenderer(mode=LayoutMode.Kerning, line_separator="\n")
102
+ print(renderer.render_text("Hello\nWorld"))
103
+ ```
104
+
105
+ ## 💻 CLI Usage
106
+
107
+ The `figprint` command is installed automatically with the package:
108
+
109
+ ```bash
110
+ figprint "Hello World"
111
+ figprint "Hello World" --font /path/to/font.flf
112
+ figprint "Hello World" --mode kerning
113
+ figprint "Hello World" --mode full
114
+ figprint --help
115
+ ```
116
+
117
+ Or run as a module:
118
+
119
+ ```bash
120
+ python -m byteforge_figlet "Hello World"
121
+ ```
122
+
123
+ ## 📐 API Reference
124
+
125
+ ### `FIGFont`
126
+
127
+ | Method / Property | Description |
128
+ | ----------------------------- | -------------------------------------------------- |
129
+ | `FIGFont.default` | The built-in `small` font (class property, cached) |
130
+ | `FIGFont.from_file(path)` | Load a font from a `.flf` file path |
131
+ | `FIGFont.from_stream(stream)` | Load a font from a binary stream |
132
+ | `FIGFont.from_text(text)` | Load a font from a string |
133
+ | `FIGFont.from_lines(lines)` | Load a font from a list of strings |
134
+ | `.height` | Character height in rows |
135
+ | `.hard_blank` | Hard blank character |
136
+ | `.characters` | `dict` mapping character code point → glyph rows |
137
+ | `.smushing_rules` | `SmushingRules` flags for this font |
138
+ | `.print_direction` | `0` = left-to-right, `1` = right-to-left |
139
+ | `.has_smushing_rule(rule)` | Check if a specific rule is set |
140
+
141
+ ### `FIGLetRenderer`
142
+
143
+ | Member | Description |
144
+ | ---------------------------------- | ------------------------------------------------------ |
145
+ | `FIGLetRenderer.render(text, ...)` | Static method — render and return ASCII art string |
146
+ | `renderer.render_text(text)` | Instance method — render using configured settings |
147
+ | `.layout_mode` | Active `LayoutMode` |
148
+ | `.line_separator` | Line separator string (default `os.linesep`) |
149
+ | `.use_ansi_colors` | Whether to preserve ANSI color codes through rendering |
150
+ | `.paragraph_mode` | Whether blank lines produce separate FIGLet renders |
151
+
152
+ **Constructor parameters:**
153
+
154
+ | Parameter | Type | Default | Description |
155
+ | ----------------- | ------------------- | ------------ | ------------------------------ |
156
+ | `font` | `FIGFont &#124; None` | `built-in small` | Font to use |
157
+ | `mode` | `LayoutMode` | `Smushing` | Layout mode |
158
+ | `line_separator` | `str &#124; None` | `os.linesep` | Line separator |
159
+ | `use_ansi_colors` | `bool` | `False` | Preserve ANSI color codes |
160
+ | `paragraph_mode` | `bool` | `True` | Treat `\n` as paragraph breaks |
161
+
162
+ ### `LayoutMode`
163
+
164
+ | Value | Description |
165
+ | ---------------------------- | ------------------------------ |
166
+ | `LayoutMode.FullSize` (`-1`) | No character overlap |
167
+ | `LayoutMode.Kerning` (`0`) | Minimal spacing, no merge |
168
+ | `LayoutMode.Smushing` (`1`) | Characters may merge (default) |
169
+
170
+ ### `SmushingRules`
171
+
172
+ | Flag | Value | Description |
173
+ | ------------------------------ | ----- | -------------------------------------- |
174
+ | `SmushingRules.None` | 0 | No smushing rules active |
175
+ | `SmushingRules.EqualCharacter` | 1 | Two identical characters → one |
176
+ | `SmushingRules.Underscore` | 2 | Underscore replaced by hierarchy char |
177
+ | `SmushingRules.Hierarchy` | 4 | Higher-ranked char wins |
178
+ | `SmushingRules.OppositePair` | 8 | Opposing brackets → `\|` |
179
+ | `SmushingRules.BigX` | 16 | `/+\` → `\|`, `\+/` → `Y`, `>+<` → `X` |
180
+ | `SmushingRules.HardBlank` | 32 | Two hardblanks → one hardblank |
181
+
182
+ ## 📁 Font Support
183
+
184
+ - Standard `.flf` font files
185
+ - Compressed `.flf` files inside `.zip` archives (auto-detected by PK magic bytes)
186
+
187
+ ## 🎨 ANSI Color Support
188
+
189
+ The library preserves ANSI color codes through the rendering process, allowing you to create colorful FIGLet text in terminals:
190
+
191
+ ```python
192
+ from byteforge_figlet import FIGLetRenderer
193
+
194
+ renderer = FIGLetRenderer(use_ansi_colors=True)
195
+
196
+ colorful_text = '\x1b[31mRed\x1b[0m \x1b[32mGreen\x1b[0m \x1b[34mBlue\x1b[0m'
197
+ print(renderer.render_text(colorful_text))
198
+ ```
199
+
200
+ ## 📝 Paragraph Mode
201
+
202
+ When enabled (the default), blank lines in the input produce separate FIGLet renderings spaced by the font's character height:
203
+
204
+ ```python
205
+ from byteforge_figlet import FIGLetRenderer
206
+
207
+ renderer = FIGLetRenderer()
208
+
209
+ paragraphs = 'Paragraph 1\n\nParagraph 2'
210
+ print(renderer.render_text(paragraphs))
211
+ ```
212
+ Output:
213
+ ```text
214
+ ___ _ _
215
+ | _ \__ _ _ _ __ _ __ _ _ _ __ _ _ __| |_ / |
216
+ | _/ _` | '_/ _` / _` | '_/ _` | '_ \ ' \ | |
217
+ |_| \__,_|_| \__,_\__, |_| \__,_| .__/_||_| |_|
218
+ |___/ |_|
219
+
220
+
221
+
222
+
223
+ ___ _ ___
224
+ | _ \__ _ _ _ __ _ __ _ _ _ __ _ _ __| |_ |_ )
225
+ | _/ _` | '_/ _` / _` | '_/ _` | '_ \ ' \ / /
226
+ |_| \__,_|_| \__,_\__, |_| \__,_| .__/_||_| /___|
227
+ |___/ |_|
228
+
229
+ ```
230
+
231
+ ## 🌏 Unicode Support
232
+
233
+ The library fully supports Unicode characters. Characters not present in the font are skipped gracefully:
234
+
235
+ ```python
236
+ from byteforge_figlet import FIGLetRenderer
237
+
238
+ renderer = FIGLetRenderer()
239
+ print(renderer.render_text('Hello 😊 World!'))
240
+ ```
241
+ Output:
242
+ ```
243
+ _ _ _ _ __ __ _ _ _
244
+ | || |___| | |___ \ \ / /__ _ _| |__| | |
245
+ | __ / -_) | / _ \ \ \/\/ / _ \ '_| / _` |_|
246
+ |_||_\___|_|_\___/ \_/\_/\___/_| |_\__,_(_)
247
+
248
+ ```
249
+
250
+ ## 🏗 Implementation Details
251
+
252
+ 1. **FIGFont** — Parses `.flf` font files; supports loading from files, streams, strings, or line lists; handles ZIP-compressed font files; manages smushing rule configuration.
253
+
254
+ 2. **FIGLetRenderer** — Converts input text to FIGLet output; implements character smushing logic; handles different layout modes; processes ANSI color codes in a single pre-pass; supports paragraph formatting.
255
+
256
+ 3. **LayoutMode** — Enumeration controlling how characters are combined during rendering.
257
+
258
+ 4. **SmushingRules** — Flags enumeration defining which character-combining rules are active.
259
+
260
+ ## ⚡ Performance Considerations
261
+
262
+ - Default font is cached after the first load and reused across all calls
263
+ - ANSI color codes are handled in a single pre-pass, not during rendering
264
+ - Efficient string building throughout the rendering pipeline
265
+
266
+ ## 🤝 Contributing
267
+
268
+ Contributions are welcome!
269
+ To contribute:
270
+
271
+ 1. Fork the repository
272
+ 2. Create a feature branch
273
+ 3. Commit your changes
274
+ 4. Open a Pull Request
275
+
276
+ ## 🔗 ByteForge FIGLet Suite
277
+
278
+ | Component | Description |
279
+ | ----------------------------------------------------------------------------------------------------------------- | ----------------------------- |
280
+ | [**FIGLet** (.NET)](https://www.nuget.org/packages/ByteForge.FIGLet) | Core C# library on NuGet |
281
+ | [**@byte-forge/figlet** (TypeScript)](https://www.npmjs.com/package/@byte-forge/figlet) | TypeScript library on npm |
282
+ | [**byteforge-figlet** (Python)](https://pypi.org/project/byteforge-figlet) | Python library on PyPI |
283
+ | [**FIGPrint**](https://github.com/PaulStSmith/FIGLetAddIn/releases) | .NET CLI tool |
284
+ | [**VS Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.FIGLetCommentGenerator) | Visual Studio 2022+ extension |
285
+ | [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.figlet-comment-generator) | VS Code extension |
286
+
287
+ ## 📜 License
288
+
289
+ This library is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
290
+
291
+ ## 💡 Credits
292
+
293
+ - Original FIGLet concept by **Frank, Ian & Glenn**
294
+ - Implementations by **Paulo Santos (ByteForge)**
295
+ - FIGLet specification: [figlet.org](http://www.figlet.org/)
296
+
297
+ ## Support
298
+
299
+ If you encounter any issues or have feature requests, please:
300
+ 1. Search existing [issues](https://github.com/PaulStSmith/figlet-comment-generator/issues)
301
+ 2. Create a new issue if needed
302
+
303
+ ---
304
+
305
+ Made with ❤️ by Paulo Santos
@@ -17,5 +17,5 @@ from .fig_let_renderer import FIGLetRenderer
17
17
  from .layout_mode import LayoutMode
18
18
  from .smushing_rules import SmushingRules
19
19
 
20
- __version__ = "2.0.6"
20
+ __version__ = "2.0.9"
21
21
  __all__ = ["FIGFont", "FIGLetRenderer", "LayoutMode", "SmushingRules"]
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "byteforge-figlet"
7
- version = "2.0.6"
7
+ version = "2.0.9"
8
8
  description = "Python FIGLet rendering library — render text as ASCII art using .flf fonts"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
@@ -1,204 +0,0 @@
1
- # 🐍 **BYTEFORGE FIGLET SUITE — byteforge-figlet (Python Library)**
2
-
3
- ```
4
- ██████╗ ██╗ ██╗████████╗███████╗███████╗ ██████╗ ██████╗ ██████╗ ███████╗
5
- ██╔══██╗╚██╗ ██╔╝╚══██╔══╝██╔════╝██╔════╝██╔═══██╗██╔══██╗██╔════╝ ██╔════╝
6
- ██████╔╝ ╚████╔╝ ██║ █████╗ █████╗ ██║ ██║██████╔╝██║ ███╗█████╗
7
- ██╔══██╗ ╚██╔╝ ██║ ██╔══╝ ██╔══╝ ██║ ██║██╔══██╗██║ ██║██╔══╝
8
- ██████╔╝ ██║ ██║ ███████╗██║ ╚██████╔╝██║ ██║╚██████╔╝███████╗
9
- ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚══════╝
10
- ███████╗██╗ ██████╗ ██╗ ███████╗████████╗ ███████╗██╗ ██╗██╗████████╗███████╗
11
- ██╔════╝██║██╔════╝ ██║ ██╔════╝╚══██╔══╝ ██╔════╝██║ ██║██║╚══██╔══╝██╔════╝
12
- █████╗ ██║██║ ███╗██║ █████╗ ██║ ███████╗██║ ██║██║ ██║ █████╗
13
- ██╔══╝ ██║██║ ██║██║ ██╔══╝ ██║ ╚════██║██║ ██║██║ ██║ ██╔══╝
14
- ██║ ██║╚██████╔╝███████╗███████╗ ██║ ███████║╚██████╔╝██║ ██║ ███████╗
15
- ╚═╝ ╚═╝ ╚═════╝ ╚══════╝╚══════╝ ╚═╝ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝
16
- ```
17
-
18
- > **byteforge-figlet**
19
- > *A fast, spec-compliant FIGLet engine for Python — zero dependencies.*
20
-
21
- ## 📘 Overview
22
-
23
- `byteforge-figlet` is a Python implementation of the FIGLet rendering engine used across the ByteForge FIGLet Suite.
24
-
25
- 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.
26
-
27
- The library ships with the built-in **small** font so it works out of the box with no additional downloads.
28
-
29
- ## ✨ Features
30
-
31
- - 🔤 Render FIGLet text using any `.flf` font
32
- - 📄 Full FIGLet font (`.flf`) file parsing and loading
33
- - 🗜️ Automatic handling of compressed/zipped font files
34
- - 🎨 ANSI color support for terminal output
35
- - 🌏 Unicode support
36
- - 📝 Paragraph formatting support
37
- - ⚙️ Supports Full Size, Kerning, and Smushing layout modes
38
- - 🧠 Implements all official smushing rules
39
- - 📦 Default embedded font included — works out of the box
40
- - 🚀 Zero dependencies — stdlib only
41
- - 🐍 Python 3.9+
42
- - 💻 Includes a `figprint` CLI command
43
-
44
- ### Sample Output
45
-
46
- ```
47
- _ _ _ _ _ _ _ _ _
48
- | || |___| | |___ \ \ / /__ _ _| |__| | |
49
- | __ / -_) | / _ \_ \ \/\/ / _ \ '_| / _` |_|
50
- |_||_\___|_|_\___( ) \_/\_/\___/_| |_\__,_(_)
51
- |/
52
- ```
53
-
54
- ## 🛠 Installation
55
-
56
- Install via pip:
57
-
58
- ```bash
59
- pip install byteforge-figlet
60
- ```
61
-
62
- ## 🚀 Quick Start
63
-
64
- ### Basic Usage
65
-
66
- ```python
67
- from byteforge_figlet import FIGLetRenderer
68
-
69
- print(FIGLetRenderer.render("Hello World!"))
70
- ```
71
-
72
- ### Using a Custom Font
73
-
74
- ```python
75
- from byteforge_figlet import FIGFont, FIGLetRenderer
76
-
77
- font = FIGFont.from_file("/path/to/myfont.flf")
78
- print(FIGLetRenderer.render("Hello!", font=font))
79
- ```
80
-
81
- ### Choosing a Layout Mode
82
-
83
- ```python
84
- from byteforge_figlet import FIGLetRenderer, LayoutMode
85
-
86
- # Full Size — no character overlap
87
- print(FIGLetRenderer.render("Hi", mode=LayoutMode.FullSize))
88
-
89
- # Kerning — characters touch but don't overlap
90
- print(FIGLetRenderer.render("Hi", mode=LayoutMode.Kerning))
91
-
92
- # Smushing — characters may merge (default)
93
- print(FIGLetRenderer.render("Hi", mode=LayoutMode.Smushing))
94
- ```
95
-
96
- ### Renderer Instance
97
-
98
- ```python
99
- from byteforge_figlet import FIGLetRenderer, LayoutMode
100
-
101
- renderer = FIGLetRenderer(mode=LayoutMode.Kerning, line_separator="\n")
102
- print(renderer.render_text("Hello\nWorld"))
103
- ```
104
-
105
- ## 💻 CLI Usage
106
-
107
- The `figprint` command is installed automatically with the package:
108
-
109
- ```bash
110
- figprint "Hello World"
111
- figprint "Hello World" --font /path/to/font.flf
112
- figprint "Hello World" --mode kerning
113
- figprint "Hello World" --mode full
114
- figprint --help
115
- ```
116
-
117
- Or run as a module:
118
-
119
- ```bash
120
- python -m byteforge_figlet "Hello World"
121
- ```
122
-
123
- ## 📐 API Reference
124
-
125
- ### `FIGFont`
126
-
127
- | Method / Property | Description |
128
- |---|---|
129
- | `FIGFont.default` | The built-in `small` font (class property, cached) |
130
- | `FIGFont.from_file(path)` | Load a font from a `.flf` file path |
131
- | `FIGFont.from_stream(stream)` | Load a font from a binary stream |
132
- | `FIGFont.from_text(text)` | Load a font from a string |
133
- | `FIGFont.from_lines(lines)` | Load a font from a list of strings |
134
- | `.height` | Character height in rows |
135
- | `.hard_blank` | Hard blank character |
136
- | `.smushing_rules` | `SmushingRules` flags for this font |
137
- | `.has_smushing_rule(rule)` | Check if a specific rule is set |
138
-
139
- ### `FIGLetRenderer`
140
-
141
- | Method | Description |
142
- |---|---|
143
- | `FIGLetRenderer.render(text, ...)` | Static method — render and return ASCII art string |
144
- | `renderer.render_text(text)` | Instance method — render using configured settings |
145
-
146
- **Constructor parameters:**
147
-
148
- | Parameter | Type | Default | Description |
149
- |---|---|---|---|
150
- | `font` | `FIGFont \| None` | built-in small | Font to use |
151
- | `mode` | `LayoutMode` | `Smushing` | Layout mode |
152
- | `line_separator` | `str \| None` | `os.linesep` | Line ending |
153
- | `use_ansi_colors` | `bool` | `False` | Preserve ANSI color codes |
154
- | `paragraph_mode` | `bool` | `True` | Treat `\n` as paragraph breaks |
155
-
156
- ### `LayoutMode`
157
-
158
- | Value | Description |
159
- |---|---|
160
- | `LayoutMode.FullSize` (`-1`) | No character overlap |
161
- | `LayoutMode.Kerning` (`0`) | Minimal spacing, no merge |
162
- | `LayoutMode.Smushing` (`1`) | Characters may merge (default) |
163
-
164
- ### `SmushingRules`
165
-
166
- | Flag | Value | Description |
167
- |---|---|---|
168
- | `SmushingRules.EqualCharacter` | 1 | Two identical characters → one |
169
- | `SmushingRules.Underscore` | 2 | Underscore replaced by hierarchy char |
170
- | `SmushingRules.Hierarchy` | 4 | Higher-ranked char wins |
171
- | `SmushingRules.OppositePair` | 8 | Opposing brackets → `\|` |
172
- | `SmushingRules.BigX` | 16 | `/+\` → `\|`, `\+/` → `Y`, `>+<` → `X` |
173
- | `SmushingRules.HardBlank` | 32 | Two hardblanks → one hardblank |
174
-
175
- ## 🔗 ByteForge FIGLet Suite
176
-
177
- | Component | Description |
178
- |---|---|
179
- | [**FIGLet** (.NET)](https://www.nuget.org/packages/ByteForge.FIGLet) | Core C# library on NuGet |
180
- | [**@byte-forge/figlet** (TypeScript)](https://www.npmjs.com/package/@byte-forge/figlet) | TypeScript library on npm |
181
- | [**byteforge-figlet** (Python)](https://pypi.org/project/byteforge-figlet) | Python library on PyPI |
182
- | [**FIGPrint**](https://github.com/PaulStSmith/FIGLetAddIn/releases) | .NET CLI tool |
183
- | [**VS Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.FIGLetCommentGenerator) | Visual Studio 2022+ extension |
184
- | [**VS Code Extension**](https://marketplace.visualstudio.com/items?itemName=PaulStSmith.figlet-comment-generator) | VS Code extension |
185
-
186
- ## 📜 License
187
-
188
- This library is licensed under the **MIT License** — see the [LICENSE](LICENSE) file for details.
189
-
190
- ## 💡 Credits
191
-
192
- - Original FIGLet concept by **Frank, Ian & Glenn**
193
- - Implementations by **Paulo Santos (ByteForge)**
194
- - FIGLet specification: [figlet.org](http://www.figlet.org/)
195
-
196
- ## Support
197
-
198
- If you encounter any issues or have feature requests, please:
199
- 1. Search existing [issues](https://github.com/PaulStSmith/figlet-comment-generator/issues)
200
- 2. Create a new issue if needed
201
-
202
- ---
203
-
204
- Made with ❤️ by Paulo Santos