Skip to main content

Streamlined Cython bindings for the harfbuzz shaping engine

Project description

Travis Build status Appveyor Build status PyPI

uharfbuzz

Streamlined Cython bindings for the HarfBuzz shaping engine.

Example

import uharfbuzz as hb
import sys


with open(sys.argv[1], 'rb') as fontfile:
    fontdata = fontfile.read()

text = sys.argv[2]

face = hb.Face.create(fontdata)
font = hb.Font.create(face)
upem = face.upem

font.scale = (upem, upem)
hb.ot_font_set_funcs(font)

buf = hb.Buffer.create()

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
    cluster = info.cluster
    x_advance = pos.x_advance
    x_offset = pos.x_offset
    y_offset = pos.y_offset
    print(f"gid{gid}={cluster}@{x_advance},{x_offset}+{y_offset}")

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.3.0.zip (18.1 kB view hashes)

Uploaded Source

Built Distributions

uharfbuzz-0.3.0-cp37-cp37m-win_amd64.whl (259.1 kB view hashes)

Uploaded CPython 3.7m Windows x86-64

uharfbuzz-0.3.0-cp37-cp37m-win32.whl (222.8 kB view hashes)

Uploaded CPython 3.7m Windows x86

uharfbuzz-0.3.0-cp37-cp37m-manylinux1_x86_64.whl (419.9 kB view hashes)

Uploaded CPython 3.7m

uharfbuzz-0.3.0-cp37-cp37m-macosx_10_6_x86_64.whl (371.9 kB view hashes)

Uploaded CPython 3.7m macOS 10.6+ x86-64

uharfbuzz-0.3.0-cp36-cp36m-win_amd64.whl (259.0 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

uharfbuzz-0.3.0-cp36-cp36m-win32.whl (222.9 kB view hashes)

Uploaded CPython 3.6m Windows x86

uharfbuzz-0.3.0-cp36-cp36m-manylinux1_x86_64.whl (419.9 kB view hashes)

Uploaded CPython 3.6m

uharfbuzz-0.3.0-cp36-cp36m-macosx_10_6_x86_64.whl (372.4 kB view hashes)

Uploaded CPython 3.6m macOS 10.6+ 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