Skip to main content

Streamlined Cython bindings for the harfbuzz shaping engine

Project description

Githun CI Status PyPI

uharfbuzz

Streamlined Cython bindings for the HarfBuzz shaping engine.

Example

import sys

import uharfbuzz as hb


fontfile = sys.argv[1]
text = sys.argv[2]

blob = hb.Blob.from_file_path(fontfile)
face = hb.Face(blob)
font = hb.Font(face)

buf = hb.Buffer()
buf.add_str(text)
buf.guess_segment_properties()

features = {"kern": True, "liga": True}
hb.shape(font, buf, features)

infos = buf.glyph_infos
positions = buf.glyph_positions

for info, pos in zip(infos, positions):
    gid = info.codepoint
    glyph_name = font.glyph_to_string(gid)
    cluster = info.cluster
    x_advance = pos.x_advance
    x_offset = pos.x_offset
    y_offset = pos.y_offset
    print(f"{glyph_name} gid{gid}={cluster}@{x_advance},{y_offset}+{x_advance}")

Installation

When building the uharfbuzz package, it automatically incorporates minimal HarfBuzz sources so you don't have to install the native HarfBuzz library.

However, if you want to use uharfbuzz with your system-provided HarfBuzz (e.g., if you built it from sources with custom configuration), you can set USE_SYSTEM_LIBS=1 environment variable (see example below).

USE_SYSTEM_LIBS=1 pip install uharfbuzz --no-binary :uharfbuzz:

harfbuzz installation is found using pkg-config, so you must have harfbuzz's .pc files in your system. If you've built it from sources, meson installs them automatically. Otherwise, you may want to install harfbuzz development package, like harfbuzz-devel on Fedora-derived distros.

Note: you must build HarfBuzz with experimental API support enabled.

How to make a release

Use git tag -a to make a new annotated tag, or git tag -s for a GPG-signed annotated tag, if you prefer.

Name the new tag with with a leading ‘v’ followed by three MAJOR.MINOR.PATCH digits, like in semantic versioning. Look at the existing tags for examples.

In the tag message write some short release notes describing the changes since the previous tag. The subject line will be the release name and the message body will be the release notes.

Finally, push the tag to the remote repository (e.g. assuming upstream is called origin):

$ git push origin v0.4.3

This will trigger the CI to build the distribution packages and upload them to the Python Package Index automatically, if all the tests pass successfully. The CI will also automatically create a new Github Release and use the content of the annotated git tag for the release notes.

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

uharfbuzz-0.39.5b1.tar.gz (1.5 MB view hashes)

Uploaded Source

Built Distributions

uharfbuzz-0.39.5b1-pp310-pypy310_pp73-win_amd64.whl (1.2 MB view hashes)

Uploaded PyPy Windows x86-64

uharfbuzz-0.39.5b1-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-pp310-pypy310_pp73-macosx_11_0_arm64.whl (1.2 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-pp310-pypy310_pp73-macosx_10_15_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

uharfbuzz-0.39.5b1-pp39-pypy39_pp73-win_amd64.whl (1.2 MB view hashes)

Uploaded PyPy Windows x86-64

uharfbuzz-0.39.5b1-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-pp39-pypy39_pp73-macosx_11_0_arm64.whl (1.2 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-pp39-pypy39_pp73-macosx_10_15_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy macOS 10.15+ x86-64

uharfbuzz-0.39.5b1-pp38-pypy38_pp73-win_amd64.whl (1.2 MB view hashes)

Uploaded PyPy Windows x86-64

uharfbuzz-0.39.5b1-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-pp38-pypy38_pp73-macosx_11_0_arm64.whl (1.2 MB view hashes)

Uploaded PyPy macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-pp38-pypy38_pp73-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-pp37-pypy37_pp73-win_amd64.whl (1.2 MB view hashes)

Uploaded PyPy Windows x86-64

uharfbuzz-0.39.5b1-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-pp37-pypy37_pp73-macosx_10_9_x86_64.whl (1.3 MB view hashes)

Uploaded PyPy macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp313-cp313-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.13 Windows x86-64

uharfbuzz-0.39.5b1-cp313-cp313-win32.whl (944.4 kB view hashes)

Uploaded CPython 3.13 Windows x86

uharfbuzz-0.39.5b1-cp313-cp313-musllinux_1_2_x86_64.whl (16.0 MB view hashes)

Uploaded CPython 3.13 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.13 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp313-cp313-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.13 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp313-cp313-macosx_10_13_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.13 macOS 10.13+ x86-64

uharfbuzz-0.39.5b1-cp313-cp313-macosx_10_13_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.13 macOS 10.13+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp312-cp312-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.12 Windows x86-64

uharfbuzz-0.39.5b1-cp312-cp312-win32.whl (945.9 kB view hashes)

Uploaded CPython 3.12 Windows x86

uharfbuzz-0.39.5b1-cp312-cp312-musllinux_1_2_x86_64.whl (16.0 MB view hashes)

Uploaded CPython 3.12 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp312-cp312-macosx_11_0_arm64.whl (1.4 MB view hashes)

Uploaded CPython 3.12 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp312-cp312-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp312-cp312-macosx_10_9_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.12 macOS 10.9+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp311-cp311-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

uharfbuzz-0.39.5b1-cp311-cp311-win32.whl (946.3 kB view hashes)

Uploaded CPython 3.11 Windows x86

uharfbuzz-0.39.5b1-cp311-cp311-musllinux_1_2_x86_64.whl (15.1 MB view hashes)

Uploaded CPython 3.11 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp311-cp311-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp311-cp311-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp311-cp311-macosx_10_9_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.11 macOS 10.9+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp310-cp310-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

uharfbuzz-0.39.5b1-cp310-cp310-win32.whl (944.8 kB view hashes)

Uploaded CPython 3.10 Windows x86

uharfbuzz-0.39.5b1-cp310-cp310-musllinux_1_2_x86_64.whl (15.0 MB view hashes)

Uploaded CPython 3.10 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp310-cp310-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp310-cp310-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp310-cp310-macosx_10_9_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.10 macOS 10.9+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp39-cp39-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

uharfbuzz-0.39.5b1-cp39-cp39-win32.whl (944.9 kB view hashes)

Uploaded CPython 3.9 Windows x86

uharfbuzz-0.39.5b1-cp39-cp39-musllinux_1_2_x86_64.whl (15.0 MB view hashes)

Uploaded CPython 3.9 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp39-cp39-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp39-cp39-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp39-cp39-macosx_10_9_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.9 macOS 10.9+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp38-cp38-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

uharfbuzz-0.39.5b1-cp38-cp38-win32.whl (947.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

uharfbuzz-0.39.5b1-cp38-cp38-musllinux_1_2_x86_64.whl (15.0 MB view hashes)

Uploaded CPython 3.8 musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp38-cp38-macosx_11_0_arm64.whl (1.3 MB view hashes)

Uploaded CPython 3.8 macOS 11.0+ ARM64

uharfbuzz-0.39.5b1-cp38-cp38-macosx_10_9_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp38-cp38-macosx_10_9_universal2.whl (2.8 MB view hashes)

Uploaded CPython 3.8 macOS 10.9+ universal2 (ARM64, x86-64)

uharfbuzz-0.39.5b1-cp37-cp37m-win_amd64.whl (1.2 MB view hashes)

Uploaded CPython 3.7m Windows x86-64

uharfbuzz-0.39.5b1-cp37-cp37m-win32.whl (940.2 kB view hashes)

Uploaded CPython 3.7m Windows x86

uharfbuzz-0.39.5b1-cp37-cp37m-musllinux_1_2_x86_64.whl (14.9 MB view hashes)

Uploaded CPython 3.7m musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp37-cp37m-macosx_10_9_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.7m macOS 10.9+ x86-64

uharfbuzz-0.39.5b1-cp36-cp36m-win_amd64.whl (1.3 MB view hashes)

Uploaded CPython 3.6m Windows x86-64

uharfbuzz-0.39.5b1-cp36-cp36m-win32.whl (1.0 MB view hashes)

Uploaded CPython 3.6m Windows x86

uharfbuzz-0.39.5b1-cp36-cp36m-musllinux_1_2_x86_64.whl (14.9 MB view hashes)

Uploaded CPython 3.6m musllinux: musl 1.2+ x86-64

uharfbuzz-0.39.5b1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.5 MB view hashes)

Uploaded CPython 3.6m manylinux: glibc 2.17+ x86-64

uharfbuzz-0.39.5b1-cp36-cp36m-macosx_10_9_x86_64.whl (1.4 MB view hashes)

Uploaded CPython 3.6m macOS 10.9+ x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page