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
[![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)
Built Distributions
Close
Hashes for uharfbuzz-0.1.1a2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90a6953db321baadf0d0de1df4cedc32645c5fd5af80a022710181710d2bec41 |
|
MD5 | 4151115a2aac38edc8fc2cd0a24314ed |
|
BLAKE2b-256 | 4444adee6e433813f494fd250a7ff8121b22214541256130786fcbca6216eecc |
Close
Hashes for uharfbuzz-0.1.1a2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d7b2270bac7c36b97a23ac53273a4db9b9d80a8669461a93b4c6ae922310acb |
|
MD5 | c5cb3938c57653afe991ba54339447a6 |
|
BLAKE2b-256 | 3e026a718504cb5bc1445bf2e02ff9d8b7b01ca2a9d966177de494e178dc19fa |
Close
Hashes for uharfbuzz-0.1.1a2-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 537ffcba5c385ce7b10dd6e12cfb91a850d89a42029cfbaaf283a3ce2f3fc006 |
|
MD5 | a8ca5dea5efaba1bd92f6e573cdd1ee2 |
|
BLAKE2b-256 | 5849a255803631500fa7f9a7f38b8cac46ab1fd5848050c25bdde6428489e758 |
Close
Hashes for uharfbuzz-0.1.1a2-cp36-cp36m-macosx_10_6_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e2af51ac539a917c5cb3067592fdc9a7f4afaebef0279c37cf9c6d065fa24b1 |
|
MD5 | 9b5ae33c5ac131372812c3d1a8d372c5 |
|
BLAKE2b-256 | e9eb022abca79f207044d681aedef40e2981e8cf309cb56089b83e4d0ff5cbee |