A user-friendlier way to use Harfbuzz in Python
Project description
vharfbuzz - A user-friendlier way to use Harfbuzz in Python
uharfbuzz is an awesome tool for shaping text in Python. But it wraps the Harfbuzz C interface quite closely, so still requires you to perform a bunch of boilerplate operations before you can get on with the shaping. This module allows you a slightly more high-level interface to the text shaping process. For example, rather than:
with open(sys.argv[1], 'rb') as fontfile:
fontdata = fontfile.read()
text = sys.argv[2]
face = hb.Face(fontdata)
font = hb.Font(face)
buf = hb.Buffer()
buf.add_str(text)
buf.guess_segment_properties()
features = {"kern": True, "liga": True}
hb.shape(font, buf, features)
with vharfbuzz
you can just say:
vhb = Vharfbuzz(sys.argv[1])
buf = vhb.shape(sys.argv[2], {"features": {"kern": True, "liga": True}})
The Vharfbuzz
class also contains a number of other helpful methods to perform common operations on Harfbuzz buffers. See Read The Docs for more information.
Installation
vharfbuzz is available from pypi
, so can be installed like so:
pip3 install vharfbuzz
If building from source, you can install it like so:
pip3 install -r requirements.txt
pip3 install .
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for vharfbuzz-0.3.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa2f406406b0cef15fb3cbd5548d9eb779a05916989088f92fa2d724984086a0 |
|
MD5 | 9cfc36a71f5588ee33acbd17b070c7f9 |
|
BLAKE2b-256 | adbb3b318bc920c189c6aef6f9b42a080c056ce5ca0a56a488ba52bc09de6449 |