Typf Python Bindings
High-performance text rendering for Python applications.
Version 5.1.0 requires standard CPython 3.11 or newer. Prebuilt stable ABI
wheels cover Linux (glibc and musl), macOS and Windows x64. Install the typf
distribution; both import typf and the compatible import typfpy work.
The typf and typfpy commands expose the same CLI.
Free-threaded CPython is outside this stable ABI wheel contract.
Installation
# Using uv (recommended)
uv pip install typf==5.1.0
# Or using pip
pip install typf==5.1.0
Or install from source with maturin:
cd bindings/py
# Using uv (recommended)
uv pip install maturin
maturin develop --release
# Or with uvx (no install needed)
uvx maturin develop --release
Quick Start
Python API
from typfpy import Typf, render_simple, export_image
# Simple text rendering (no font file needed)
image = render_simple("Hello, Typf!", size=48)
# Export to PNG
png_data = export_image(image, format="png")
with open("output.png", "wb") as f:
f.write(png_data)
# Advanced usage with real fonts
engine = Typf(shaper="harfbuzz", renderer="opixa")
image = engine.render_text(
"Typography is beautiful",
font_path="/System/Library/Fonts/Helvetica.ttc",
size=48,
color=(0, 0, 255, 255), # Blue text (RGBA)
background=(255, 255, 200, 255), # Light yellow background
padding=20
)
# Variable font instance (axis variations)
image = engine.render_text(
"Wide",
font_path="/path/to/variable-font.ttf",
size=48,
variations={"wdth": 125.0, "wght": 650.0},
)
# Access image data
print(f"Size: {image['width']}x{image['height']}")
print(f"Format: {image['format']}")
# Export to multiple formats
png_data = export_image(image, format="png")
svg_data = export_image(image, format="svg")
ppm_data = export_image(image, format="ppm")
Command Line Interface
The Click-based CLI provides a powerful command-line interface:
# Render text to PNG
typfpy render "Hello World" -o output.png
# Specify font and size
typfpy render "مرحبا" -f /path/to/arabic.ttf -s 64 -o output.png
# Custom colors (RRGGBBAA hex)
typfpy render "Red Text" -c FF0000FF -b FFFFFFFF -o output.png
# Choose renderer (linra-mac for best performance on macOS)
typfpy render "Text" --renderer=linra-mac -O svg -o output.svg
# Get system info and available backends
typfpy info
# Show available shapers
typfpy info --shapers
# Show available renderers
typfpy info --renderers
Features
- ✅ Professional text shaping with HarfBuzz
- ✅ High-performance rendering with SIMD optimizations
- ✅ Support for TrueType/OpenType fonts (including .ttc collections)
- ✅ Multiple export formats (PNG, SVG, PPM, PGM, PBM, JSON)
- ✅ Thread-safe for concurrent rendering
- ✅ Complex script support (Arabic, Hebrew, Devanagari, Thai, CJK)
- ✅ OpenType features (ligatures, kerning, small caps, etc.)
- ✅ Variable fonts with axis variations (
{"wght": 700, "wdth": 120}) - ✅ Click-based CLI for command-line usage
API Reference
typfpy.Typf
Main rendering engine.
from typfpy import Typf
engine = Typf(shaper="harfbuzz", renderer="opixa")
Parameters:
shaper(str): Shaping backend - "none" or "harfbuzz" (default: "harfbuzz")renderer(str): Rendering backend - "opixa" (default: "opixa")
Methods:
render_text(text, font_path, size=16.0, color=None, background=None, padding=10, variations=None)
Render text to an image.
Parameters:
text(str): Text to renderfont_path(str): Path to TrueType/OpenType font filesize(float): Font size in points (default: 16.0)color(tuple): Foreground color as (R, G, B, A) (default: black)background(tuple): Background color as (R, G, B, A) (default: transparent)padding(int): Padding in pixels (default: 10)variations(dict | None): Variable font axis settings, e.g.,{"wght": 700, "wdth": 120}
Returns: Dictionary with width, height, format, and data keys
Example:
image = engine.render_text(
"Hello",
"/path/to/font.ttf",
size=32,
color=(255, 0, 0, 255),
background=(255, 255, 255, 255),
padding=15,
variations={"wght": 700, "wdth": 110},
)
get_shaper() → str
Get current shaper name.
get_renderer() → str
Get current renderer name.
typfpy.FontInfo
Font information and metrics.
from typfpy import FontInfo
font = FontInfo("/path/to/font.ttf")
Attributes:
units_per_em(int): Font units per empath(str): Path to font file
Methods:
glyph_id(ch) → int | None
Get glyph ID for a character.
Example:
from typfpy import FontInfo
font = FontInfo("/System/Library/Fonts/Arial.ttf")
print(f"Units per em: {font.units_per_em}")
glyph_id = font.glyph_id('A')
print(f"Glyph ID for 'A': {glyph_id}")
Module Functions
typfpy.render_simple(text, size=16.0) → dict
Simple rendering with stub font (no font file needed).
Parameters:
text(str): Text to rendersize(float): Font size in points (default: 16.0)
Returns: Dictionary with width, height, format, and data keys
Example:
from typfpy import render_simple
image = render_simple("Quick test", size=48)
typfpy.export_image(image_data, format="ppm") → bytes
Export image to various formats.
Parameters:
image_data(dict): Image dictionary fromrender_text()orrender_simple()format(str): Output format - "png", "svg", "ppm", "pgm", "pbm", or "json" (default: "ppm")
Returns: Bytes of the exported image
Example:
from typfpy import render_simple, export_image
image = render_simple("Test")
png_bytes = export_image(image, format="png")
svg_bytes = export_image(image, format="svg")
with open("output.png", "wb") as f:
f.write(png_bytes)
Examples
See the examples/ directory for complete examples:
simple_render.py- Basic rendering with stub fontrender_with_font.py- Rendering with real font fileslong_text_handling.py- Strategies for long text (SVG, line wrapping)
CLI Commands
typfpy render
Render text to an image file.
typfpy render [TEXT] [OPTIONS]
Options:
-f, --font-file- Path to font file (.ttf, .otf, .ttc, .otc)-s, --font-size- Font size in pixels (default: 200)--shaper- Shaping backend: auto, none, hb, icu-hb, mac (default: auto)--renderer- Rendering backend: auto, opixa, linra-mac, linra-win (default: auto)-O, --format- Output format: pbm, png1, pgm, png4, png8, png, svg (default: png)-c, --foreground- Text color as RRGGBB or RRGGBBAA (default: 000000FF)-b, --background- Background color as RRGGBB or RRGGBBAA (default: FFFFFF00)-m, --margin- Margin in pixels (default: 10)-o, --output-file- Output file path (stdout if omitted)-q, --quiet- Silent mode
typfpy info
Display Typf version and available backends.
typfpy info [OPTIONS]
Options:
--shapers- List available shaping backends--renderers- List available rendering backends--formats- List available output formats
Development
Building from Source
# Install maturin
pip install maturin
# Build and install in development mode
cd bindings/py
maturin develop
# Build release wheel
maturin build --release
Running Tests
pytest
Platform Support
- macOS: ✅ Full support (x86_64, ARM64)
- Linux: ✅ Full support (x86_64, ARM64)
- Windows: ✅ Full support (x86_64)
Performance
Typf achieves industry-leading performance through:
- SIMD-optimized blending (10GB/s+ throughput)
- Multi-level caching (L1 < 50ns access)
- Parallel rendering with work-stealing
- Zero-copy font loading
License
EVALUATION LICENSE
Community project by FontLab - https://www.fontlab.org/
Metadata
Release files for typf 5.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| typf-5.1.0.tar.gz | 295.1 kB | Without provenance | Details for typf-5.1.0.tar.gz |
Built distributions (wheels)
Total release size: 33.1 MB
Release files / typf-5.1.0.tar.gz
| Download URL | typf-5.1.0.tar.gz |
|---|---|
| Size | 295.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0562cae6365e429163e9f04ebc768a168b8cd83ac58bb358d8853e049e0521c3
|
|
BLAKE2b-256 checksum How to use checksums |
e56276152dc55a7cf1f5a1c2b6a16e48c8f9bd167f06f6a92da52e5e0a7c5506
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-win_amd64.whl
| Download URL | typf-5.1.0-cp311-abi3-win_amd64.whl |
|---|---|
| Size | 4.8 MB |
| Tags | CPython 3.11 Windows x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
ff0fafab72bf50974bdc6a036f000547804e0fce18daf6f832abf4d1e650ded9
|
|
BLAKE2b-256 checksum How to use checksums |
b77d395dc62a27384ede1b4fd31cdb26fe44cb64dc7b5a16128794ca6d639a56
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-musllinux_1_2_x86_64.whl
| Download URL | typf-5.1.0-cp311-abi3-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 5.6 MB |
| Tags | CPython 3.11 Linux musl 1.2+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
f8de6864ab5576b8a87ebaa7678aaebab1d18c46fcbd051eaf9d8468dcde00a1
|
|
BLAKE2b-256 checksum How to use checksums |
76b48286562aa690c692fe72fa157d52d982c921e075272966ee309750ab2684
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-musllinux_1_2_aarch64.whl
| Download URL | typf-5.1.0-cp311-abi3-musllinux_1_2_aarch64.whl |
|---|---|
| Size | 5.3 MB |
| Tags | CPython 3.11 Linux musl 1.2+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
0da4e50dea9d3f8e8bfa6245f15faf72cfe013ce015c862d04f2214c52d9b140
|
|
BLAKE2b-256 checksum How to use checksums |
4bf1c38349e127a602d29182d2da56840caba3e034b7cd692e052761fd584031
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-manylinux_2_28_x86_64.whl
| Download URL | typf-5.1.0-cp311-abi3-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 4.6 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5f3dfc8a9846a2e3d773ae5b4cddc0e197c7a49759d5652881d0793840f0b4ba
|
|
BLAKE2b-256 checksum How to use checksums |
1236d3b561787a66a5faca9c1fa0c2a74a82b75cafa6d5e59ae9b7101021ca38
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-manylinux_2_28_aarch64.whl
| Download URL | typf-5.1.0-cp311-abi3-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 4.2 MB |
| Tags | CPython 3.11 Linux glibc 2.28+ ARM64 abi3 |
|
SHA-256 checksum How to use checksums |
398c6b4784a0940523230eb0e5bc095246df191a5c9769ffd41e854ac7264573
|
|
BLAKE2b-256 checksum How to use checksums |
492b3f5304440a100289ff6b59ddc2d0dfebe7037b5883313bfef0ec358ea0d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-macosx_11_0_arm64.whl
| Download URL | typf-5.1.0-cp311-abi3-macosx_11_0_arm64.whl |
|---|---|
| Size | 4.0 MB |
| Tags | CPython 3.11 abi3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
934d892568240f425d74f83951cfa94f663653af095fae1d53c59e14d8ad7a15
|
|
BLAKE2b-256 checksum How to use checksums |
cf5b0e7a795755fb894e5b30a824d9ed7cf33e04ce13f24bf980fadc78d98d00
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Release files / typf-5.1.0-cp311-abi3-macosx_10_12_x86_64.whl
| Download URL | typf-5.1.0-cp311-abi3-macosx_10_12_x86_64.whl |
|---|---|
| Size | 4.3 MB |
| Tags | CPython 3.11 abi3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
96975198fdedae6fde885769414307d321c75ae5699ee3a73d0f0aa5736c6bc2
|
|
BLAKE2b-256 checksum How to use checksums |
76850e70901c2d192d19606b0562d0578508d9ef3fb70eaa8a6eca488b9cbbc2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.18 {"installer":{"name":"uv","version":"0.12.18","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}
|
Security for typf 5.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.