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.2.tar.gz
(835.6 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.2.tar.gz.
File metadata
- Download URL: latticesvg-0.1.2.tar.gz
- Upload date:
- Size: 835.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1c5d1fed81bd49cb38944793432e7be7518eb0791fdf848c3ab5ef70ac47bb8
|
|
| MD5 |
ef3122c463e3ecef18346ad7a9d9f888
|
|
| BLAKE2b-256 |
908c3a63b91b43144945eec726df1022e896fd3db72d494700e158e383399196
|
File details
Details for the file latticesvg-0.1.2-py3-none-any.whl.
File metadata
- Download URL: latticesvg-0.1.2-py3-none-any.whl
- Upload date:
- Size: 99.5 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 |
6badb64406b3ad98048cadee14598cb3069e3cd77e0d2c16baaf66dfdb8373f8
|
|
| MD5 |
8e8a7bb848ac7f85d31c7602a6913acb
|
|
| BLAKE2b-256 |
c82908ad3c78a5db4bd5caf7eb170985426038002f05a592e6ad43ccbba866b1
|