Skip to main content

Streamlined Cython bindings for the harfbuzz shaping engine

Project description

[![Travis Build status](https://travis-ci.org/trufont/uharfbuzz.svg)](https://travis-ci.org/trufont/uharfbuzz)
[![Appveyor Build status](https://ci.appveyor.com/api/projects/status/ujynqhnvd7qbh1vh/branch/master?svg=true)](https://ci.appveyor.com/project/trufont/uharfbuzz/branch/master)

## uharfbuzz

Streamlined Cython bindings for the [HarfBuzz][hb] shaping engine.


### Example

```python
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}")
```


[hb]: https://github.com/harfbuzz/harfbuzz


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.1.1a2.zip (17.5 kB view hashes)

Uploaded Source

Built Distributions

uharfbuzz-0.1.1a2-cp36-cp36m-win_amd64.whl (212.3 kB view hashes)

Uploaded CPython 3.6m Windows x86-64

uharfbuzz-0.1.1a2-cp36-cp36m-win32.whl (185.6 kB view hashes)

Uploaded CPython 3.6m Windows x86

uharfbuzz-0.1.1a2-cp36-cp36m-manylinux1_x86_64.whl (318.8 kB view hashes)

Uploaded CPython 3.6m

uharfbuzz-0.1.1a2-cp36-cp36m-macosx_10_6_x86_64.whl (279.9 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