Skip to main content
Fallback image description

Source Code Examples Documentation Python Package Index Python versions

Ruff pre-commit NumPy docstrings pydoclint mypy License: Apache-2.0

tenderness is a fast library for synthetic, deterministic document rendering from text and images, powered by Cairo and Pango.

Why tenderness?

Most document datasets don’t come from real structure — they come from reconstruction. Text is rendered, then reverse-engineered back into layout using OCR, heuristics, or fragile parsing pipelines. The result is noisy, incomplete, and not reproducible.

tenderness flips this entirely.

It renders text directly into documents producing images, SVGs, and PDFs with fully known layout from the start. Every character placement, line break, and block position is defined at render time — not inferred afterward.

What this gives you

  • Generate large-scale synthetic document datasets
  • Provide precise structural supervision for vision-language models
  • Build benchmarks for layout understanding systems
  • Ground-truth layout across characters, clusters, runs, and lines

No OCR. No heuristics. No reconstruction. No manual annotation.

Just text in → fully structured document out.

Main Features

  • Multi-format output: Render text and images into Image, SVG, PDF, or NumPy arrays.

  • Composable content blocks: Build documents from simple primitives: TextBlock, ImageBlock, and TableBlock.

  • Minimal flexbox layout engine: A lightweight system that automatically resolves positioning and flow.

  • Exact bounding boxes (OBB + AABB, logical + ink): Extract multi-level data for text (character, cluster, run, line, layout) and blocks.

  • Rich typography & text flow: Custom fonts, hierarchical styling, Pango markup, automatic font fallback, and overflow-aware text continuation across blocks.

  • Composable pipelines: Use the built-in pipeline with pre-defined layouts, or build your own from scratch.

Quick Start

pip install tenderness
import pathlib

from tenderness.cairo_backend.color_patterns import SolidColorSpec
from tenderness.cairo_backend.surface_config_manager import SurfaceConfigManager
from tenderness.colors.color_selector import ColorSelector
from tenderness.pango_backend.font_description_interface import FontDescriptionInterfaceParameters
from tenderness.pipelines.document import (
    DocumentBlocksConfig,
    DocumentConfig,
    DocumentRenderPipeline,
    TextBlock,
    TextStyle,
)

# select colors
color_selector = ColorSelector()
white = SolidColorSpec(color=color_selector.by_names(["white"])[0])
black = SolidColorSpec(color=color_selector.by_names(["black"])[0])

# select surface (image, pdf, svg, etc.)
img_surface_config = SurfaceConfigManager().create_image_surface_config(
    width=400,
    height=100,
)

# create document config and blocks config
doc_config = DocumentConfig(surface_config=img_surface_config, background_spec=white)
doc_blocks_config = DocumentBlocksConfig(
    surface_config=img_surface_config,
    blocks=[
        TextBlock(
            text="Hello, world!",
            text_style=TextStyle(
                font_description_params=FontDescriptionInterfaceParameters(size=32),
                text_color_spec=black,
            ),
        ),
    ],
)

# create pipeline and render document
pipeline = DocumentRenderPipeline()
setup_result = pipeline.setup(config=doc_config)
render_result = pipeline.render(
    blocks_config=doc_blocks_config,
    setup_result=setup_result,
)

# save the rendered document to a file
pipeline.save_as_file(
    surface=setup_result.surface,
    surface_config=img_surface_config,
    output_file_path=pathlib.Path("hello_world"),
)

# The output file will be saved as `hello_world.png` in the current working directory.

You can find the runnable version at scripts/mini_example.py, and more examples over at tenderness-examples. If you run into missing system libraries (Cairo, Pango, PyGObject), check the install guide.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tenderness-0.3.0.tar.gz (113.3 kB view details)

Uploaded Source

Built Distribution

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

tenderness-0.3.0-py3-none-any.whl (179.2 kB view details)

Uploaded Python 3

File details

Details for the file tenderness-0.3.0.tar.gz.

File metadata

  • Download URL: tenderness-0.3.0.tar.gz
  • Upload date:
  • Size: 113.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tenderness-0.3.0.tar.gz
Algorithm Hash digest
SHA256 898d5364ad33b17da1f08ab0f964e6951778f625aa365aa533d0faccaf821d37
MD5 733a9ba22143facefffaf480e7776910
BLAKE2b-256 b0b6547660cd31cb06b720d41e405fa127928151e841aac8d7f95fd26a19c749

See more details on using hashes here.

File details

Details for the file tenderness-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: tenderness-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 179.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.12.1 {"installer":{"name":"uv","version":"0.12.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for tenderness-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9f0044d554d62c34da33d9e1002a7153ece91a1e3cdcb4752b0c75db9bf2dba
MD5 9de7535e8d9ad11326317850bd848a62
BLAKE2b-256 02817f6b81691b5650f36e8825b0c004151b8d1eef226e13142075678a866b87

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page