#font-rendering #png #svg #text-rendering

text-to-png

A simple way to render text to a png image with basic options

4 releases (2 breaking)

0.3.0 Dec 16, 2025
0.2.0 Mar 5, 2022
0.1.1 Nov 8, 2021
0.1.0 Oct 25, 2021

#516 in Encoding

Download history 168/week @ 2025-11-21 109/week @ 2025-11-28 133/week @ 2025-12-05 86/week @ 2025-12-12 90/week @ 2025-12-19 44/week @ 2025-12-26 41/week @ 2026-01-02 25/week @ 2026-01-09 63/week @ 2026-01-16 81/week @ 2026-01-23 46/week @ 2026-01-30 22/week @ 2026-02-06 603/week @ 2026-02-13 237/week @ 2026-02-20 125/week @ 2026-02-27 199/week @ 2026-03-06

1,166 downloads per month
Used in 7 crates

MIT/Apache

290KB
1.5K SLoC

Text To Png

This crate provides a really simple interface for rendering basic text to a png image.

Features

  • 100% Rust! We use usvg for path vectoring, resvg for rasterizing, and tiny-skia for png conversion
  • Built-in, monospace font courtesy of Ryoichi Tsunekawa
  • Flexible color specification, "Aquamarine", "#4506AE", "EEE", 0
  • Text baseline height is provided for alignment consistency
  • Accepts true-type font files or true-type font collection files

Example

Default Font

use text_to_png::TextRenderer;

let renderer = TextRenderer::default();

let text_png = renderer.render_text_to_png_data(
    "Rénder this, brö",
    64,
    "Dark Turquoise");

Writing the &[u8] data returned in text_png.data to a text.png yields:

Rendered Text Image

Custom Font

use text_to_png::TextRenderer;

let renderer = TextRenderer::try_new_with_ttf_font_data(include_bytes!("../tests/resources/Because I am Happy Regular.ttf"))
    .expect("Example font is definitely loadable");

let text_png = renderer.render_text_to_png_data(
    "Custom Fonts are Cool!",
    52,
    0x439EC2);

Writing the &[u8] data returned in text_png.data to a text.png yields:

Rendered Text Image

CLI

See the CLI Readme

Dependencies

~9.5MB
~192K SLoC