Grid-based vector layout engine — CSS Grid layout to SVG/PNG
Project description
LatticeSVG
A declarative vector layout engine powered by CSS Grid. Describe layouts with Python dicts, get pixel-perfect SVG/PNG output.
Features
- Full CSS Grid Level 1 — fixed tracks,
frunits,minmax(),repeat(), named areas, auto-placement - Precise text typesetting — FreeType-based glyph measurement, auto line-breaking, CJK support, rich text (HTML/Markdown), vertical writing
- Multiple node types —
TextNode,ImageNode,SVGNode,MplNode(Matplotlib),MathNode(LaTeX) - 63 CSS properties — box model, border-radius, gradients, shadows, transforms, filters, clip-path, opacity
- SVG & PNG output — vector SVG by default, optional high-res PNG via CairoSVG, WOFF2 font embedding
Installation
pip install latticesvg
# For PNG output
pip install latticesvg[png]
# For auto-hyphenation
pip install latticesvg[hyphens]
Quick Start
from latticesvg import GridContainer, TextNode, Renderer
page = GridContainer(style={
"width": "600px",
"padding": "24px",
"grid-template-columns": ["1fr", "1fr"],
"gap": "16px",
"background-color": "#ffffff",
})
page.add(TextNode("Hello", style={"font-size": "24px", "color": "#2c3e50"}))
page.add(TextNode("World", style={"font-size": "24px", "color": "#e74c3c"}))
Renderer().render(page, "hello.svg")
Documentation
Full documentation is available at https://qalxry.github.io/LatticeSVG/
Dependencies
- Python ≥ 3.8
- drawsvg — SVG generation
- freetype-py — text measurement
- quickjax — LaTeX math rendering
- cairosvg (optional) — PNG conversion
License
MIT
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
latticesvg-0.1.1.tar.gz
(802.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file latticesvg-0.1.1.tar.gz.
File metadata
- Download URL: latticesvg-0.1.1.tar.gz
- Upload date:
- Size: 802.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5b3b2ce1e7b2c60cb83626e5963fba83903bd3e7732af908ea9322d46139c263
|
|
| MD5 |
2dafbbc23f6f6c8cc877ea8317d0f88d
|
|
| BLAKE2b-256 |
379fe9c1752894cf9774e8f28676f6901c9c5f1766f76c4d0de8d1150fbfd7f7
|
File details
Details for the file latticesvg-0.1.1-py3-none-any.whl.
File metadata
- Download URL: latticesvg-0.1.1-py3-none-any.whl
- Upload date:
- Size: 96.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b9c58b3a60ebc9fc764cb760cbb7cd3d689a783bb9f488f087cd93438d88c69
|
|
| MD5 |
fe9cf9124a686e76d729a80c247e3d2a
|
|
| BLAKE2b-256 |
8137a0b7f5295e5c2f9d05a3cdf530d871bbf5baab8397d91bd868cc20d8a96e
|