Metadata-Version: 2.4
Name: handwriting-generator
Version: 0.1.0
Summary: Render text as a natural-looking handwriting PNG using a handwriting-style font with subtle per-glyph randomization. Fully offline (no ML, no network).
Author-email: smolkai <smolkai@users.noreply.github.com>
License: MIT License
        
        Copyright (c) 2026 smolkai
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
        ---
        
        This MIT license applies to the handwriting-generator source code only.
        
        The bundled font "Shadows Into Light" (handwriting_generator/fonts/
        ShadowsIntoLight.ttf), by Kimberly Geswein, is licensed separately under the
        SIL Open Font License, Version 1.1. Its full license text is distributed
        alongside the font at handwriting_generator/fonts/OFL.txt and is NOT covered by
        the MIT license above.
        
Project-URL: Homepage, https://github.com/smolkapps/handwriting-generator
Keywords: handwriting,font,png,image,text-to-image,pillow
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Console
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Text Processing :: Fonts
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: Pillow>=9.1.0
Provides-Extra: test
Requires-Dist: pytest>=7.0; extra == "test"
Dynamic: license-file

# handwriting-generator

Render text as a natural-looking **handwriting** image (PNG) from the command
line or as a Python library. It draws a handwriting-style font glyph-by-glyph
and applies subtle, seeded per-glyph randomization (baseline wander, slight
rotation, size wobble) so the result looks hand-written instead of typeset.

This is a **font-rendering** approach — **not** machine learning. It runs fully
**offline**: no network access or API keys at runtime. (A font is downloaded
once at build time and committed into the package.)

## Install

```bash
pip install .
# or, for development with tests:
pip install -e ".[test]"
```

Runtime dependency: [Pillow](https://python-pillow.org/).

## CLI

Two equivalent entry points are installed: `handwriting-generator` and the
shorter `handwrite`.

```bash
# Simple
handwriting-generator "Dear John, I hope this letter finds you well." -o note.png

# From a file (use '-' for stdin)
handwriting-generator --input letter.txt -o letter.png

# Messy notebook style, reproducible
handwrite "Meeting notes" --paper lined --jitter 1.8 --seed 42 -o notes.png

# Neat, narrow column, custom ink color
handwrite "Tidy and straight" --jitter 0 --width 600 --color "#1a1a8a" -o tidy.png
```

### Flags

| Flag | Default | Meaning |
|------|---------|---------|
| `TEXT` (positional) | — | Text to render (omit when using `--input`). |
| `--input`, `-i` | — | Read text from a file (`-` = stdin). |
| `--output`, `-o` | `handwriting.png` | Output PNG path. |
| `--font` | bundled *Shadows Into Light* | Path to a `.ttf`/`.otf` font. |
| `--size` | `48` | Font size in points. |
| `--color` | `#1a1a8a` | Ink color (`#hex`, name, or `rgb(...)`). |
| `--width` | `1000` | Word-wrap column width in px (`0` disables wrapping). |
| `--jitter` | `1.0` | Messiness. `0` = neat; higher = messier. |
| `--line-spacing` | `1.0` | Line-height multiplier. |
| `--paper` | `blank` | `blank`, `lined`, or `none` (transparent). |
| `--margin` | `40` | Padding around the text, in px. |
| `--seed` | none | RNG seed; same text+seed+settings ⇒ byte-identical PNG. |

Long text is word-wrapped to `--width`, and the image grows taller to fit all
lines.

## Library

```python
from handwriting_generator import HandwritingRenderer, RenderConfig, render_text

# One-shot helper
render_text("Hello, world!", "hello.png", paper="lined", jitter=1.2, seed=7)

# Or keep a configured renderer
cfg = RenderConfig(size=56, color="#222222", width=800, jitter=0.8, seed=1)
renderer = HandwritingRenderer(cfg)
img = renderer.render("Reusable renderer")   # a PIL RGBA Image
renderer.save("Reusable renderer", "out.png")
```

## Determinism

Pass `--seed` (CLI) or `seed=` (library) to make output reproducible: the same
text, seed, and settings always produce a **byte-identical** PNG. Without a
seed, the jitter is randomized on each run.

## Licensing

- **Code:** MIT (see [`LICENSE`](LICENSE)).
- **Bundled font:** *Shadows Into Light* by Kimberly Geswein is licensed under
  the **SIL Open Font License, Version 1.1**. Its full license text ships with
  the package at
  [`handwriting_generator/fonts/OFL.txt`](handwriting_generator/fonts/OFL.txt).
  The OFL is **not** the same as the MIT license that covers the code; it
  governs the font file only. You may swap in any other font with `--font`.
