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 with auto font sync),MathNode(LaTeX) - Font query API —
get_font_path(),list_fonts()for programmatic font discovery - 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.3.tar.gz
(838.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
latticesvg-0.1.3-py3-none-any.whl
(100.2 kB
view details)
File details
Details for the file latticesvg-0.1.3.tar.gz.
File metadata
- Download URL: latticesvg-0.1.3.tar.gz
- Upload date:
- Size: 838.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 |
b883248f75b63e176cced175ac26f615e227fcc6e25b3cb673fb704c2cd1df83
|
|
| MD5 |
f1c48820430a5256f7fd66b9212a8183
|
|
| BLAKE2b-256 |
e6854ff44d67e318097c7b38f6d46a2877425cf871b6139126eb14b048587684
|
File details
Details for the file latticesvg-0.1.3-py3-none-any.whl.
File metadata
- Download URL: latticesvg-0.1.3-py3-none-any.whl
- Upload date:
- Size: 100.2 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 |
99732d548d07c1437973affe2901374304585cf60d1fb27e76c4d6f8ce84c53f
|
|
| MD5 |
87d0b0b5fbe24e05eb8197a98be08aff
|
|
| BLAKE2b-256 |
4c0ebe445ff8272b3b0d29d40b918f024f8ba058ad6a2f264305109bce5278df
|