tartan-maker is a Python package and command-line utility for defining, validating, rendering, and exporting tartan designs from YAML.
It is deliberately SVG-first: the package builds clean SVG from structured tartan data, and PNG output is derived from that same SVG. One rendering model, one source of truth, no separate raster engine slowly wandering off into the moor.
- Defines tartans as readable YAML.
- Supports symmetrical setts with explicit pivot markers.
- Supports asymmetrical/direct setts without pivot markers.
- Validates palettes, threadcounts, pivots, unused colors, and repeat sizes.
- Renders SVG with separate warp and weft threadcount groups.
- Exports PNG through the optional CairoSVG backend.
- Emits Scottish Register of Tartans-style
Pallet:andThreadcount:fields. - Resolves web color names and hex colors.
- Uses
spdlogfor CLI logging.
Requires Python 3.11 or newer. Install the CLI from PyPI. The required spdlog binding may need to compile from source when a suitable wheel is unavailable, so a C++ compiler may be needed:
python -m pip install tartan-makerTo enable PNG output as well as SVG:
python -m pip install "tartan-maker[png]"Verify the installation:
tartan-maker --versionFor development from a repository checkout, use python -m pip install -e ".[dev,png]".
From a repository checkout, render one of the reference examples (the examples/ directory is not installed with the CLI wheel):
tartan-maker render examples/black-watch.yaml -o black-watch.svgRender PNG instead:
tartan-maker render examples/royal-stewart.yaml -o royal-stewart.pngInspect a tartan:
tartan-maker inspect examples/buchanan.yamlGenerate SRT-style fields:
tartan-maker srt examples/macleod-of-lewis.yamlCheck the installed version:
tartan-maker --versionThe project site is built with MkDocs and published through GitHub Pages:
pip install -e ".[png]"
pip install mkdocs mkdocs-material mkdocstrings[python]
mkdocs serveThe docs workflow runs the unit tests on every commit and publishes the site on pushes to main.
The examples/ directory contains reference encodings used for testing and demonstration:
| File | Sett type | Source |
|---|---|---|
black-watch-government.yaml |
symmetrical | Scottish Register of Tartans ref. 277 |
balmoral-original.yaml |
symmetrical | Scottish Register of Tartans ref. 182 |
rob-roy-macgregor.yaml |
symmetrical | Scottish Register of Tartans ref. 3516 |
buchanan.yaml |
asymmetrical | Scottish Register of Tartans ref. 414 |
royal-stewart.yaml |
symmetrical | Scottish Register of Tartans ref. 3958 |
macleod-of-lewis.yaml |
symmetrical | Scottish Register of Tartans ref. 2630 |
These examples are not original design filings. They are practical sample inputs for exercising the parser, validator, renderer, and exporter.
Run the tests:
python -m pytest -qRun the linter if installed:
ruff check .Build release distributions:
python -m buildSee CONTRIBUTING.md for the development checklist and CHANGELOG.md for release history.
MIT. See LICENSE.