Typf's command-line interface provides fast text rendering from the terminal.
# Simple text rendering
typf render "Hello World" -f font.ttf -o hello.png
# Use specific backends
typf render "Text" -f font.ttf --shaper harfbuzz --renderer skia -o text.png
# Python CLI (identical syntax)
typfpy render "Hello World" -f font.ttf -o hello.png# Build from source
git clone https://github.com/fontlaborg/typf.git
cd typf
./build.sh
# Install Python bindings
cd bindings/python
uv sync
maturin developShow available backends and system information.
typf info [--shapers] [--renderers] [--formats]
Options:
--shapers Show available shaper backends
--renderers Show available renderer backends
--formats Show supported export formatsMain command for text rendering.
typf render [OPTIONS] <TEXT>
Arguments:
<TEXT> Text to render
Options:
-f, --font <FONT> Font file path [required]
-o, --output <OUTPUT> Output file path
-s, --size <SIZE> Font size in pixels [default: 32]
-w, --width <WIDTH> Image width [default: auto]
-h, --height <HEIGHT> Image height [default: auto]
--shaper <SHAPER> Text shaper backend [none|hb|icu-hb|mac]
--renderer <RENDERER> Rendering backend [opixa|skia|zeno|json|mac|cg]
--format <FORMAT> Output format [png|svg|pnm|json]
-c, --color <COLOR> Text color (RRGGBBAA hex) [default: 000000FF]
-b, --background <COLOR> Background color (RRGGBBAA hex) [default: 00000000]
--direction <DIR> Text direction [ltr|rtl|ttb] [default: auto]
--language <LANG> Language code [default: auto]
--script <SCRIPT> Unicode script [default: auto]
-F, --features <FEATURES> Font features (comma-separated)
--dpi <DPI> Output resolution [default: 72]
-v, --verbose Show detailed output# Basic rendering
typf render "Hello World" -f Roboto.ttf -o hello.png
# Large text for printing
typf render "Print Title" -f serif.ttf -s 48 --dpi 300 -o title.png
# SVG export
typf render "Vector Text" -f sans.ttf --format svg -o vector.svg
# Custom colors (hex format)
typf render "Red Text" -f font.ttf -c FF0000FF -b F0F0F0FF -o red.png
# Using specific backends
typf render "Hi-Quality" -f font.ttf --shaper harfbuzz --renderer skia -o high.png
# Complex script with proper settings
typf render "مرحبا بالعالم" -f arabic.ttf --shaper harfbuzz --language ar --script Arab --direction rtl -o arabic.png
# Font features
typf render "Ligatures" -f font.ttf -F "liga,kern,dlig" -o features.pngRender multiple texts from a JSONL file.
typf batch [OPTIONS] --input <INPUT> --output-dir <OUTPUT_DIR>
Options:
-i, --input <INPUT> Input JSONL file path
-o, --output-dir <OUTPUT_DIR> Output directory
-f, --font <FONT> Default font file path
--format <FORMAT> Default output format [default: png]
--size <SIZE> Default font size [default: 32]Each line contains a JSON object:
{"text": "Hello World", "size": 24, "output": "hello.png"}
{"text": "Big Title", "size": 48, "output": "title.png", "shaper": "harfbuzz"}
{"text": "مرحبا", "language": "ar", "script": "Arab", "direction": "rtl", "output": "arabic.png"}# Create jobs file
cat > jobs.jsonl << 'EOF'
{"text": "Title", "size": 72, "output": "title.png"}
{"text": "Subtitle", "size": 48, "output": "subtitle.png"}
{"text": "Body", "size": 16, "output": "body.png"}
EOF
# Process all jobs
typf batch -i jobs.jsonl -o ./rendered/Create ~/.config/typf/config.toml:
[default]
font = "~/fonts/Roboto-Regular.ttf"
size = 16
width = 800
height = 600
format = "png"
shaper = "harfbuzz"
renderer = "opixa"
[colors]
text = "0,0,0,255"
background = "255,255,255,0"
[performance]
cache_size = "100MB"
parallel_jobs = 4export Typf_FONT=~/fonts/MyFont.ttf
export Typf_SIZE=24
export Typf_OUTPUT_DIR=./output
export Typf_CONFIG=~/my-typf-config.toml- Command line flags (highest)
- Environment variables
- Config file
- Defaults (lowest)
# List available backends
typf --list-backends
Shapers:
- none No shaping (identity mapping)
- harfbuzz HarfBuzz text shaper
- icu-harfbuzz ICU + HarfBuzz composition
- coretext macOS CoreText (macOS only)
- directwrite Windows DirectWrite (Windows only)
Renderers:
- opixa Pure Rust rasterizer
- skia Skia graphics library
- coregraphics macOS CoreGraphics (macOS only)
- directwrite Windows DirectWrite (Windows only)
- zeno Vector graphics renderer# Use specific shaper
typf render "Text" --font font.ttf --shaper harfbuzz
# Use specific renderer
typf render "Text" --font font.ttf --renderer skia
# Combine backends
typf render "Text" --font font.ttf --shaper icu-harfbuzz --renderer zeno
# Auto-select best available
typf render "Text" --font font.ttf # Uses defaults| Format | Extension | Type | Features |
|---|---|---|---|
| PNG | .png | Raster | Transparency, compression |
| SVG | .svg | Vector | Scalable, web-friendly |
| Document | Print-optimized, fonts | ||
| PNM | .pnm/.pbm/.pgm | Raster | Simple, uncompressed |
| JSON | .json | Data | Debug information |
# PNG with quality
typf render "Text" --font font.ttf --output image.png --png-quality 9
# SVG with embedded fonts
typf render "Text" --font font.ttf --output vector.svg --svg-embed-fonts
# PDF with metadata
typf render "Report" --font font.ttf --output doc.pdf --pdf-title "Report" --pdf-author "Me"# Hex colors
typf render "Text" --font font.ttf --color "#FF0000" --background "#FFFFFF"
# RGB/RGBA tuples
typf render "Text" --font font.ttf --color "255,0,0,255" --background "240,240,240,128"
# Named colors
typf render "Text" --font font.ttf --color red --background white
# Transparent background
typf render "Text" --font font.ttf --background transparentblack,white,red,green,blue,yellow,cyan,magentagray,grey,lightgray,darkgrayorange,purple,brown,pinktransparent
# Use multiple threads
typf batch --input texts.txt --template "out_{line}.png" --jobs 8
# Benchmark with parallel processing
typf benchmark --iterations 1000 --parallel# Enable caching (default)
typf render "Cached text" --font font.ttf --cache
# Disable caching
typf render "One-time text" --font font.ttf --no-cache
# Clear cache
typf cache clear# Limit memory usage
typf render "Large text" --font font.ttf --memory-limit 1GB
# Stream large files
typf batch --input huge.txt --template "out_{line}.png" --stream0- Success1- General error2- Font loading error3- Backend unavailable4- Invalid configuration5- I/O error
$ typf render "Test" --font nonexistent.ttf
Error: Font loading failed: File not found: nonexistent.ttf
$ typf render "Test" --font font.ttf --shaper nonexistent
Error: Backend unavailable: Shaper 'nonexistent' not compiled
$ typf render "Test" --font font.ttf --output invalid.xyz
Error: Invalid configuration: Unsupported output format: xyz# Show debug information
typf render "Debug" --font font.ttf --verbose
# Test backends
typf benchmark --test-backends
# Check font support
typf font info font.ttf --verbose#!/bin/bash
# Generate previews for all fonts
for font in ~/fonts/*.ttf; do
basename=$(basename "$font" .ttf)
typf quick "$basename Sample" --font "$font" --output "previews/$basename.png"
done# Makefile for text assets
TEXTS = $(wildcard texts/*.txt)
IMAGES = $(TEXTS:texts/%.txt=output/%.png)
output/%.png: texts/%.txt
typf render "$$(cat $<)" --font Roboto.ttf --output $@
all: $(IMAGES)
clean:
rm -f output/*.png# GitHub Actions example
- name: Render text assets
run: |
typf batch \
--input assets/texts.txt \
--template "generated/{line}.png" \
--config ci/typf-config.toml
typf benchmark \
--font Roboto.ttf \
--output performance.json
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: text-assets
path: generated/If you're upgrading from Typf v1.x, the CLI has changed significantly:
Before (v1.x):
typf "Hello" --font font.ttf --output hello.png --size 48
python -m typfpy render "Hello" hello.png --font=/path/to/font.ttfAfter (v2.0.0):
typf render "Hello" -f font.ttf -o hello.png -s 48
typfpy render "Hello" -f /path/to/font.ttf -o hello.png- Subcommands: Now uses
info,render,batchsubcommands - Option names: Shortened (
--output→-o,--font→-f,--size→-s) - Python CLI: Renamed from
python -m typfpytotypfpy - Features: Enhanced with Unicode escapes, color parsing, font features
- Unicode escape sequences:
\u{1F44B}for emoji - Color format: RRGGBBAA hex (e.g.,
FF0000FFfor red) - Font features:
-F "liga,kern,dlig" - Better backend detection and selection
For complete migration details, see the main repository's CLI_MIGRATION.md file.
The CLI provides fast, scriptable text rendering from the command line. Use batch mode for bulk processing, benchmark for performance testing, and the REPL for interactive experimentation.