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(fontdata)
font = hb.Font(face)
upem = face.upem

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

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
    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


Download files

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

Files for uharfbuzz, version 0.6.0
Filename, size File type Python version Upload date Hashes
Filename, size uharfbuzz-0.6.0-cp36-cp36m-macosx_10_9_x86_64.whl (464.3 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp36-cp36m-manylinux1_x86_64.whl (480.0 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp36-cp36m-manylinux2010_x86_64.whl (480.0 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp36-cp36m-win32.whl (258.8 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp36-cp36m-win_amd64.whl (298.7 kB) File type Wheel Python version cp36 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp37-cp37m-macosx_10_9_x86_64.whl (463.7 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp37-cp37m-manylinux1_x86_64.whl (479.7 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp37-cp37m-manylinux2010_x86_64.whl (479.7 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp37-cp37m-win32.whl (258.6 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp37-cp37m-win_amd64.whl (298.8 kB) File type Wheel Python version cp37 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp38-cp38-macosx_10_9_x86_64.whl (464.5 kB) File type Wheel Python version cp38 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp38-cp38-manylinux1_x86_64.whl (480.6 kB) File type Wheel Python version cp38 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp38-cp38-manylinux2010_x86_64.whl (480.6 kB) File type Wheel Python version cp38 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp38-cp38-win32.whl (259.4 kB) File type Wheel Python version cp38 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0-cp38-cp38-win_amd64.whl (299.2 kB) File type Wheel Python version cp38 Upload date Hashes View hashes
Filename, size uharfbuzz-0.6.0.zip (26.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page