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 with auto font sync), MathNode (LaTeX)
  • Font query APIget_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

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)

Uploaded Source

Built Distribution

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

latticesvg-0.1.2-py3-none-any.whl (99.5 kB view details)

Uploaded Python 3

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

Hashes for latticesvg-0.1.2.tar.gz
Algorithm Hash digest
SHA256 f1c5d1fed81bd49cb38944793432e7be7518eb0791fdf848c3ab5ef70ac47bb8
MD5 ef3122c463e3ecef18346ad7a9d9f888
BLAKE2b-256 908c3a63b91b43144945eec726df1022e896fd3db72d494700e158e383399196

See more details on using hashes here.

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

Hashes for latticesvg-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6badb64406b3ad98048cadee14598cb3069e3cd77e0d2c16baaf66dfdb8373f8
MD5 8e8a7bb848ac7f85d31c7602a6913acb
BLAKE2b-256 c82908ad3c78a5db4bd5caf7eb170985426038002f05a592e6ad43ccbba866b1

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