uharfbuzz
Streamlined Cython bindings for the harfbuzz shaping engine
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 uharfbuzzuv
uv add uharfbuzzpoetry
poetry add uharfbuzzInstalling 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
More Linguistic packages
Detects and normalizes text encoding from…
permissive · top 100 on PyPI
tiktokentiktoken is a fast BPE tokenizer that converts…
permissive · top 1,000 on PyPI
chardetDetects character encoding and language in byte…
permissive · top 1,000 on PyPI
text-unidecodeConverts Unicode text to ASCII by…
copyleft · top 1,000 on PyPI
larkLark is a parsing library that builds abstract…
permissive · top 1,000 on PyPI
tree-sitterPython bindings to the tree-sitter parsing…
permissive · top 1,000 on PyPI
freetype-pyProvides Python bindings to the FreeType font…
permissive · top 5,000 on PyPI
pyfigletRenders ASCII text as ASCII art using a variety…
permissive · top 5,000 on PyPI
pictexPicTex generates high-quality PNG, JPEG, WebP,…
permissive · top 15,000 on PyPI
cffsubrSubroutinizes CFF (Compact Font Format) font…
permissive · top 15,000 on PyPI
rendercv-fontsProvides a collection of fonts packaged for use…
permissive · top 15,000 on PyPI
esphome-glyphsetsProvides a lightweight glyph set library…
permissive · top 15,000 on PyPI
pymupdf-fontsProvides a collection of optional fonts…
unclear · top 15,000 on PyPI
fonttoolsfonttools manipulates font files in multiple…
permissive · top 1,000 on PyPI
arabic-reshaperReshapes Arabic text characters into their…
permissive · top 5,000 on PyPI
ManimPangoManimPango is a C binding for Pango using…
permissive · top 15,000 on PyPI