diff options
| author | Vijay Marcel <vijaymarcel@outlook.com> | 2024-09-13 06:24:01 +0900 | 
|---|---|---|
| committer | Willy Sudiarto Raharjo <willysr@slackbuilds.org> | 2024-09-14 23:36:39 +0700 | 
| commit | 91bb08bdd0268ade497a18546d09d22451028834 (patch) | |
| tree | 7ef785ce7ed38fa4ac263670133c8fa480812d69 /python/python3-uharfbuzz/example.py | |
| parent | 5fb98c13b2aee75912f16e98cc23209179992ade (diff) | |
python/python3-uharfbuzz: Updated for version 0.39.5.
Signed-off-by: Andrew Clemons <andrew.clemons@gmail.com>
Signed-off-by: Willy Sudiarto Raharjo <willysr@slackbuilds.org>
Diffstat (limited to 'python/python3-uharfbuzz/example.py')
| -rw-r--r-- | python/python3-uharfbuzz/example.py | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/python/python3-uharfbuzz/example.py b/python/python3-uharfbuzz/example.py new file mode 100644 index 0000000000..124b8644a1 --- /dev/null +++ b/python/python3-uharfbuzz/example.py @@ -0,0 +1,32 @@ +#!/usr/bin/python3 + +import sys + +import uharfbuzz as hb + + +fontfile = sys.argv[1] +text = sys.argv[2] + +blob = hb.Blob.from_file_path(fontfile) +face = hb.Face(blob) +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) + +infos = buf.glyph_infos +positions = buf.glyph_positions + +for info, pos in zip(infos, positions): +    gid = info.codepoint +    glyph_name = font.glyph_to_string(gid) +    cluster = info.cluster +    x_advance = pos.x_advance +    x_offset = pos.x_offset +    y_offset = pos.y_offset +    print(f"{glyph_name} gid{gid}={cluster}@{x_advance},{y_offset}+{x_advance}") | 
