Skip to main content

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, fr units, 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 typesTextNode, 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

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

latticesvg-0.1.1-py3-none-any.whl (96.7 kB view details)

Uploaded Python 3

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

Hashes for latticesvg-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5b3b2ce1e7b2c60cb83626e5963fba83903bd3e7732af908ea9322d46139c263
MD5 2dafbbc23f6f6c8cc877ea8317d0f88d
BLAKE2b-256 379fe9c1752894cf9774e8f28676f6901c9c5f1766f76c4d0de8d1150fbfd7f7

See more details on using hashes here.

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

Hashes for latticesvg-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8b9c58b3a60ebc9fc764cb760cbb7cd3d689a783bb9f488f087cd93438d88c69
MD5 fe9cf9124a686e76d729a80c247e3d2a
BLAKE2b-256 8137a0b7f5295e5c2f9d05a3cdf530d871bbf5baab8397d91bd868cc20d8a96e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page