Skip to content

Introduction ​

Why ​

SVG has no built-in text measurement or layout: you cannot auto-size text to fit a container, wrap lines, or use flexbox the way HTML does. The usual workarounds — canvas.measureText, hidden DOM elements — depend on the runtime, so the same document can measure differently across OS fonts and browser engines.

boundsvg takes OS font measurement out of the equation. Font shaping (HarfRust, HarfBuzz-compatible) and layout (Taffy flexbox and CSS Grid) run in version-pinned WASM against fonts you supply. Within one boundsvg version, accepted owned inputs produce byte-identical SVG, PNG, WebP, and GIF artifacts across supported runtimes after any documented normalization. Raw embedded SVG, live animation scheduling, and external video encoders have explicit boundaries in the determinism contract. Text can shrink or grow to fit its container, wrap, truncate with an ellipsis, or stop at a line limit.

Examples ​

Terminal-style code viewer
A heading that shrink-fits its row while Japanese body copy wraps around a donut chart via a circular text-flow exclusion
Vertical Japanese text with Ruby annotations

Packages ​

The nine publishable packages, plus the three playground apps. Internal tooling (@boundsvg/docs, @boundsvg/playground-shared, @boundsvg/bench, @boundsvg/boundtext-visual-validator) is private and not listed.

PackagePathDescription
@boundsvg/corepackages/coreMain library — text measurement, layout, SVG/PNG/WebP/GIF emit
@boundsvg/reactpackages/reactReact integration — Provider, hooks, <BoundSvg> component
@boundsvg/workerpackages/workerWeb Worker adapter — off-main-thread rendering
@boundsvg/clipackages/cliCLI tool — convert, export, inspect, doctor
@boundsvg/browserpackages/browserBrowser WASM loader and SVG DOM utilities
@boundsvg/videopackages/videoBrowser MP4 export — WebCodecs H.264 plus a bundled muxer
@boundsvg/extraspackages/extrasUnstyled utility components — HStack, FitText, etc.
@boundsvg/shapepackages/shapeGeometry / symbol data builders for Shape and Symbol
@boundsvg/testingpackages/testingTest helpers — SVG snapshots, warnings, Vitest matchers
@boundsvg/playground-reactapps/playground-reactInteractive React demo app
@boundsvg/playground-coreapps/playground-coreCore API demo (no React, TypeScript + Vite)
@boundsvg/playground-cliapps/playground-cliCLI demo — SVG analysis + multi-format output

Architecture ​

VNode → Validate → Build Taffy Tree → Compute Layout
  → Text Resolve → Build IR → Emit (SVG/PNG/WebP/GIF)

License ​

boundsvg is licensed under either the MIT License or the Apache License 2.0, at your option.