molyvi 1.0.0__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.
@@ -0,0 +1,35 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+
7
+ jobs:
8
+ deploy:
9
+ runs-on: ubuntu-latest
10
+
11
+ permissions:
12
+ id-token: write
13
+ contents: read
14
+
15
+ environment:
16
+ name: pypi
17
+ url: https://pypi.org/p/${{ github.event.repository.name }}
18
+
19
+ steps:
20
+ - name: Checkout source
21
+ uses: actions/checkout@v4
22
+
23
+ - name: Set up Python
24
+ uses: actions/setup-python@v5
25
+ with:
26
+ python-version: "3.13"
27
+
28
+ - name: Install build dependencies
29
+ run: python -m pip install build --user
30
+
31
+ - name: Build a binary wheel and a source tarball
32
+ run: python -m build
33
+
34
+ - name: Publish package distributions to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
molyvi-1.0.0/PKG-INFO ADDED
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: molyvi
3
+ Version: 1.0.0
4
+ Summary: A tool for creating handwritten SVGs in bulk.
5
+ Author-email: Jack Huey <jhhuey@icloud.com>
6
+ Requires-Python: >=3.14
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fonttools~=4.68
9
+ Requires-Dist: jinja2~=3.1
10
+ Requires-Dist: matplotlib~=3.11
11
+
12
+ # Molyvi
13
+ ## A tool for creating handwritten SVGs in bulk.
14
+
15
+ ---
16
+
17
+ ![PyPI Version](https://img.shields.io/pypi/v/molyvi?style=for-the-badge)
18
+
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install molyvi
24
+ ```
25
+
26
+ ## Usage
27
+ `molyvi TEMPLATE DATA OUTPUT TYPEFACE [-s] [-w] [-j]`
28
+
29
+ ### Positional arguments
30
+ |Argument|Description|
31
+ |----------|----------------------------------------|
32
+ | TEMPLATE | The Jinja file containing the template to generate from.|
33
+ | DATA | The CSV file containing the data to fill in the template with. |
34
+ | OUTPUT | The path to put the generated SVGs. |
35
+ | TYPEFACE | The typeface to use. |
36
+
37
+ ### Options
38
+ |Option|Description| Default |
39
+ |---------------------|--------------------------------------|:--------:|
40
+ | -s, --size SIZE | The font size to use. |50|
41
+ | -w, --wobble WOBBLE | The amount of wobble for each point. |8.0|
42
+ | -j, --jitter JITTER | The amount to shift each character. |2.5|
43
+
44
+ ## Example
45
+ See [my example](example/).
molyvi-1.0.0/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # Molyvi
2
+ ## A tool for creating handwritten SVGs in bulk.
3
+
4
+ ---
5
+
6
+ ![PyPI Version](https://img.shields.io/pypi/v/molyvi?style=for-the-badge)
7
+
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install molyvi
13
+ ```
14
+
15
+ ## Usage
16
+ `molyvi TEMPLATE DATA OUTPUT TYPEFACE [-s] [-w] [-j]`
17
+
18
+ ### Positional arguments
19
+ |Argument|Description|
20
+ |----------|----------------------------------------|
21
+ | TEMPLATE | The Jinja file containing the template to generate from.|
22
+ | DATA | The CSV file containing the data to fill in the template with. |
23
+ | OUTPUT | The path to put the generated SVGs. |
24
+ | TYPEFACE | The typeface to use. |
25
+
26
+ ### Options
27
+ |Option|Description| Default |
28
+ |---------------------|--------------------------------------|:--------:|
29
+ | -s, --size SIZE | The font size to use. |50|
30
+ | -w, --wobble WOBBLE | The amount of wobble for each point. |8.0|
31
+ | -j, --jitter JITTER | The amount to shift each character. |2.5|
32
+
33
+ ## Example
34
+ See [my example](example/).
@@ -0,0 +1,2 @@
1
+ #!/bin/sh
2
+ molyvi thankYou.txt gifts.csv output "Patrick Hand"
@@ -0,0 +1,3 @@
1
+ name,items
2
+ Bob,backpack
3
+ Fred,"candy, book"
@@ -0,0 +1,17 @@
1
+ Dear {{ name }},
2
+
3
+ Thank you so much for {% set ns = namespace(prefixed=[]) -%}
4
+ {%- for item in items.split(",") if item.strip() -%}
5
+ {%- set ns.prefixed = ns.prefixed + ["the " ~ item.strip()] -%}
6
+ {%- endfor -%}
7
+
8
+ {%- if ns.prefixed | length == 1 -%}
9
+ {{ ns.prefixed[0] }}
10
+ {%- elif ns.prefixed | length == 2 -%}
11
+ {{ ns.prefixed | join(" and ") }}
12
+ {%- elif ns.prefixed | length > 2 -%}
13
+ {{ ns.prefixed[:-1] | join(", ") }}, and {{ ns.prefixed[-1] }}
14
+ {%- endif -%}!!
15
+
16
+ Sincerely,
17
+ Jack Huey
@@ -0,0 +1,26 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0", "setuptools_scm[toml]>=8.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "molyvi"
7
+ dynamic = ["version"]
8
+ description = "A tool for creating handwritten SVGs in bulk."
9
+ readme = "README.md"
10
+ requires-python = ">=3.14"
11
+ authors = [
12
+ { name = "Jack Huey", email = "jhhuey@icloud.com" }
13
+ ]
14
+ dependencies = [
15
+ "fonttools~=4.68",
16
+ "jinja2~=3.1",
17
+ "matplotlib~=3.11"
18
+ ]
19
+
20
+ [tool.setuptools]
21
+ packages.find = { where = ["src"] }
22
+
23
+ [project.scripts]
24
+ molyvi = "molyvi.__main__:main"
25
+
26
+ [tool.setuptools_scm]
molyvi-1.0.0/setup.cfg ADDED
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,40 @@
1
+ import argparse
2
+ from pathlib import Path
3
+ from matplotlib import font_manager
4
+ import csv
5
+ from jinja2 import Template
6
+ from .generateSVG import textToSVG
7
+
8
+ def main():
9
+ parser = argparse.ArgumentParser(description="The Molyvi generator.")
10
+
11
+ parser.add_argument("template", type=Path, help="The Jinja file containing the template to generate from.")
12
+ parser.add_argument("data", type=Path, help="The CSV file containing the data to fill in the template with.")
13
+ parser.add_argument("output", type=Path, help="The path to put the generated SVGs.")
14
+ parser.add_argument("typeface", type=str, help="The typeface to use.", default="Patrick Hand")
15
+ parser.add_argument("-s", "--size", type=int, help="The font size to use.", default=50)
16
+ parser.add_argument("-w", "--wobble", type=float, help="The amount of wobble for each point.", default=8.0)
17
+ parser.add_argument("-j", "--jitter", type=float, help="The amount to shift each character.", default=2.5)
18
+
19
+ args = parser.parse_args()
20
+
21
+ if not args.template.is_file():
22
+ raise FileNotFoundError(f"{args.template} doesn't exist.")
23
+ if not args.data.is_file():
24
+ raise FileNotFoundError(f"{args.data} doesn't exist.")
25
+
26
+
27
+ template = Template(args.template.read_text())
28
+
29
+ with args.data.open(mode="r", newline="") as file:
30
+ data = list(csv.DictReader(file))
31
+
32
+ args.output.mkdir(exist_ok=True, parents=True)
33
+
34
+ typeface = Path(font_manager.findfont(font_manager.FontProperties(family=args.typeface), fallback_to_default=False))
35
+
36
+ for i in range(len(data)):
37
+ (args.output / f"{i}.svg").write_text(textToSVG(template.render(**data[i]), typeface, args.size, args.wobble, args.jitter))
38
+
39
+ if __name__ == "__main__":
40
+ main()
@@ -0,0 +1,70 @@
1
+ from fontTools.ttLib import TTFont
2
+ from fontTools.pens.svgPathPen import SVGPathPen
3
+ from fontTools.pens.transformPen import TransformPen
4
+ import random
5
+ from pathlib import Path
6
+
7
+ def textToSVG(text: str, typeface: Path, size: int, wobble: float = 8.0, jitter: float = 2.5) -> str:
8
+ font = TTFont(typeface)
9
+ cmap = font.getBestCmap()
10
+ glyphSet = font.getGlyphSet()
11
+ unitsPerEm = font["head"].unitsPerEm
12
+ scale = size / unitsPerEm
13
+
14
+ svgPaths = []
15
+ cursorX = 20.0
16
+ baselineY = size * 1.2
17
+ lineHeight = size * 1.4
18
+ maxX = cursorX
19
+
20
+ for char in text:
21
+ if char == " ":
22
+ cursorX += glyphSet[cmap[ord(" ")]].width * scale
23
+ continue
24
+ if char == "\n":
25
+ maxX = max(maxX, cursorX)
26
+ cursorX = 20.0
27
+ baselineY += lineHeight
28
+ continue
29
+
30
+ glyphName = cmap.get(ord(char))
31
+ if not glyphName:
32
+ continue
33
+
34
+ glyph = glyphSet[glyphName]
35
+
36
+ pen = SVGPathPen(glyphSet)
37
+ transformedPen = TransformPen(pen, (scale, 0, 0, -scale, 0, 0))
38
+ glyph.draw(transformedPen)
39
+ rawPath = pen.getCommands()
40
+
41
+ maxOffset = wobble * scale
42
+
43
+ tokens = rawPath.replace(",", " ").split()
44
+ newTokens = []
45
+ for token in tokens:
46
+ try:
47
+ val = float(token)
48
+ val += random.uniform(-maxOffset, maxOffset)
49
+ newTokens.append(f"{val:.2f}")
50
+ except ValueError:
51
+ newTokens.append(token)
52
+ jitteredPath = " ".join(newTokens)
53
+
54
+ rot = random.uniform(-jitter, jitter)
55
+ yOffset = baselineY + random.uniform(-jitter, jitter)
56
+
57
+ svgPaths.append(
58
+ f"""<path d="{jitteredPath}"
59
+ transform="translate({cursorX:.2f}, {yOffset:.2f}) rotate({rot:.2f})"
60
+ fill="#1a1a1a" />"""
61
+ )
62
+
63
+ cursorX += (glyph.width * scale) + random.uniform(-1.0, 1.5)
64
+
65
+ maxX = max(maxX, cursorX)
66
+ width = maxX + 20
67
+ height = baselineY + (size * 0.6)
68
+ return f"""<svg xmlns="http://www.w3.org/2000/svg" width="{width:.0f}" height="{height:.0f}" viewBox="0 0 {width:.0f} {height:.0f}">
69
+ {"".join(svgPaths)}
70
+ </svg>"""
@@ -0,0 +1,45 @@
1
+ Metadata-Version: 2.4
2
+ Name: molyvi
3
+ Version: 1.0.0
4
+ Summary: A tool for creating handwritten SVGs in bulk.
5
+ Author-email: Jack Huey <jhhuey@icloud.com>
6
+ Requires-Python: >=3.14
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fonttools~=4.68
9
+ Requires-Dist: jinja2~=3.1
10
+ Requires-Dist: matplotlib~=3.11
11
+
12
+ # Molyvi
13
+ ## A tool for creating handwritten SVGs in bulk.
14
+
15
+ ---
16
+
17
+ ![PyPI Version](https://img.shields.io/pypi/v/molyvi?style=for-the-badge)
18
+
19
+
20
+ ## Installation
21
+
22
+ ```bash
23
+ pip install molyvi
24
+ ```
25
+
26
+ ## Usage
27
+ `molyvi TEMPLATE DATA OUTPUT TYPEFACE [-s] [-w] [-j]`
28
+
29
+ ### Positional arguments
30
+ |Argument|Description|
31
+ |----------|----------------------------------------|
32
+ | TEMPLATE | The Jinja file containing the template to generate from.|
33
+ | DATA | The CSV file containing the data to fill in the template with. |
34
+ | OUTPUT | The path to put the generated SVGs. |
35
+ | TYPEFACE | The typeface to use. |
36
+
37
+ ### Options
38
+ |Option|Description| Default |
39
+ |---------------------|--------------------------------------|:--------:|
40
+ | -s, --size SIZE | The font size to use. |50|
41
+ | -w, --wobble WOBBLE | The amount of wobble for each point. |8.0|
42
+ | -j, --jitter JITTER | The amount to shift each character. |2.5|
43
+
44
+ ## Example
45
+ See [my example](example/).
@@ -0,0 +1,16 @@
1
+ README.md
2
+ pyproject.toml
3
+ .github/workflows/python-publish.yml
4
+ example/command.sh
5
+ example/gifts.csv
6
+ example/thankYou.txt
7
+ src/molyvi/__main__.py
8
+ src/molyvi/generateSVG.py
9
+ src/molyvi.egg-info/PKG-INFO
10
+ src/molyvi.egg-info/SOURCES.txt
11
+ src/molyvi.egg-info/dependency_links.txt
12
+ src/molyvi.egg-info/entry_points.txt
13
+ src/molyvi.egg-info/requires.txt
14
+ src/molyvi.egg-info/scm_file_list.json
15
+ src/molyvi.egg-info/scm_version.json
16
+ src/molyvi.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ molyvi = molyvi.__main__:main
@@ -0,0 +1,3 @@
1
+ fonttools~=4.68
2
+ jinja2~=3.1
3
+ matplotlib~=3.11
@@ -0,0 +1,12 @@
1
+ {
2
+ "files": [
3
+ ".github/workflows/python-publish.yml",
4
+ "README.md",
5
+ "example/command.sh",
6
+ "example/gifts.csv",
7
+ "example/thankYou.txt",
8
+ "pyproject.toml",
9
+ "src/molyvi/__main__.py",
10
+ "src/molyvi/generateSVG.py"
11
+ ]
12
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "tag": "1.0.0",
3
+ "distance": 0,
4
+ "node": "g18b63b904ba7202ff30eb780c2c0f59c5d49d75e",
5
+ "dirty": false,
6
+ "branch": "HEAD",
7
+ "node_date": "2026-11-24"
8
+ }
@@ -0,0 +1 @@
1
+ molyvi