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 Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

uharfbuzz-0.1.1a1-cp36-cp36m-win_amd64.whl (212.3 kB view details)

Uploaded CPython 3.6m Windows x86-64

uharfbuzz-0.1.1a1-cp36-cp36m-win32.whl (185.6 kB view details)

Uploaded CPython 3.6m Windows x86

File details

Details for the file uharfbuzz-0.1.1a1-cp36-cp36m-win_amd64.whl.

File metadata

File hashes

Hashes for uharfbuzz-0.1.1a1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 5512ccfca66fcb2ad1e5b6f8912efd27b8a4038692755809100ed819b90e8d48
MD5 f7d65474ce1681d7013b7df34c4e89f7
BLAKE2b-256 e39287843c9954ab55f86dc60f34f7acfbc95620c7d07ebafb3f297eb784dd3e

See more details on using hashes here.

File details

Details for the file uharfbuzz-0.1.1a1-cp36-cp36m-win32.whl.

File metadata

File hashes

Hashes for uharfbuzz-0.1.1a1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 1e2c8098fca17c89bac0c49d90e81ccff89552c2b34f76179d7472e5d7456541
MD5 555edd0a8d884d0931b030247a8d87c0
BLAKE2b-256 3bbd74f312f22fed575f1eb4c9e8164864328ecc8596384b5ccdeff89142f5a5

See more details on using hashes here.

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