Skip to content

Qalxry/LatticeSVG

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Grid-based vector layout engine — CSS Grid layout to SVG/PNG

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages