skillfed

uharfbuzz

Streamlined Cython bindings for the harfbuzz shaping engine

uharfbuzz v0.56.0 960.3K downloads/30d#4,636 on PyPI108
Permissive license Apache License 2.0 Active released

What it is and what it does

uharfbuzz is a Python wrapper around the HarfBuzz text shaping engine, a C library that converts Unicode text and font files into positioned glyphs. It handles complex typography tasks like kerning (adjusting spacing between letter pairs), ligature substitution (combining characters like 'fi' into a single glyph), and script-specific shaping rules. The package bundles minimal HarfBuzz sources by default, so installation requires no separate system dependency—though you can opt into using a system-provided HarfBuzz build if needed.

You load a font file, create a buffer with text, apply shaping with optional features, then iterate over the resulting glyph infos and positions to extract advance widths, offsets, and glyph IDs. It's a thin, direct binding to HarfBuzz's core API, exposing the shaping pipeline without abstraction layers. The package is actively maintained, supports current Python versions (3.10+), and offers prebuilt wheels for major platforms.

Use it for:

  • Render text to screen or image with proper kerning and ligatures in graphics or game engines.
  • Build font inspection tools that need to map characters to glyphs and measure their positions.
  • Implement complex script support (Arabic, Devanagari, etc.) where character-to-glyph mapping is non-trivial.
  • Generate PDF or vector output with correct text layout and glyph positioning.
  • Validate font behavior by programmatically shaping test strings and inspecting glyph metrics.

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Cython bindings for HarfBuzz that shape text using font files, converting character strings into positioned glyphs with kerning and ligature support.

Yes. The package is actively maintained, has no known vulnerabilities, offers permissive licensing, and provides prebuilt wheels for common platforms. Install friction is moderate but manageable. Choose it if you need direct, low-level control over text shaping and glyph positioning; it's the standard Python binding for HarfBuzz.

Install

uharfbuzz on PyPI

pip

pip install uharfbuzz

uv

uv add uharfbuzz

poetry

poetry add uharfbuzz

Installing uharfbuzz

Before you install

Medium install friction due to compiled C extensions. Prebuilt wheels available for common platforms (CPython 3.10+, PyPy 3.11) and architectures. Alternatively, can build against system HarfBuzz via USE_SYSTEM_LIBS=1 if pkg-config is available. Package is actively maintained with recent releases.

License in practice

Apache License 2.0 is permissive; you may use, modify, and distribute this package freely in commercial or private projects provided you include the license notice.

Quickstart

import uharfbuzz as hb

blob = hb.Blob.from_file_path('font.ttf')
face = hb.Face(blob)
font = hb.Font(face)
buf = hb.Buffer()
buf.add_str('Hello')
buf.guess_segment_properties()
hb.shape(font, buf, {"kern": True})
for info, pos in zip(buf.glyph_infos, buf.glyph_positions):
    print(f"glyph {info.codepoint}: x_advance={pos.x_advance}")

Requires Python 3.10 or later. If building from source against system HarfBuzz, pkg-config and HarfBuzz development headers must be available.

Verify before relying

  • Whether prebuilt wheels cover all deployment targets you need beyond the listed platforms (macOS, Linux, Windows, WebAssembly).
  • Performance characteristics when shaping large volumes of text or complex scripts.

Package facts

License Apache License 2.0 (permissive)
Python support supports the current Python release (>=3.10)
Install friction medium — platform-specific wheel
Runtime dependencies none
Maintenance actively maintained — 14 days since the last release
Last repo commit
First released
Downloads 960,306/month — #4,636 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: uharfbuzz-0.56.0-cp310-abi3-macosx_10_9_universal2.whl; uharfbuzz-0.56.0-cp310-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; uharfbuzz-0.56.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; uharfbuzz-0.56.0-cp310-abi3-musllinux_1_2_aarch64.whl; uharfbuzz-0.56.0-cp310-abi3-musllinux_1_2_x86_64.whl; uharfbuzz-0.56.0-cp310-abi3-pyemscripten_2025_0_wasm32.whl; uharfbuzz-0.56.0-cp310-abi3-pyemscripten_2026_0_wasm32.whl; uharfbuzz-0.56.0-cp310-abi3-win32.whl; uharfbuzz-0.56.0-cp310-abi3-win_amd64.whl; uharfbuzz-0.56.0-pp311-pypy311_pp73-macosx_10_15_x86_64.whl; uharfbuzz-0.56.0-pp311-pypy311_pp73-macosx_11_0_arm64.whl; uharfbuzz-0.56.0-pp311-pypy311_pp73-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl; uharfbuzz-0.56.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl; uharfbuzz-0.56.0-pp311-pypy311_pp73-win_amd64.whl

Tags

text shaping harfbuzzfont glyph positioningtext rendering with fontsharfbuzz python bindingskerning ligature shapingfont layout engineunicode text layout
text-shapingtypographyfont-rendering

More Linguistic packages