Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bind hb_ot_layout_lookup_get_glyph_alternates() #184

Merged
merged 4 commits into from
Jan 6, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/uharfbuzz/_harfbuzz.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1179,6 +1179,19 @@ def shape(font: Font, buffer: Buffer,
free(hb_features)


def ot_layout_lookup_get_glyph_alternates(
face: Face, lookup_index : int, glyph : hb_codepoint_t) -> List[int]:
cdef list alt_glyphs = []
cdef unsigned int start_offset = 0
cdef unsigned int alternate_count = STATIC_TAGS_ARRAY_SIZE
cdef hb_codepoint_t alternate_glyphs[STATIC_TAGS_ARRAY_SIZE]
while alternate_count == STATIC_TAGS_ARRAY_SIZE:
hb_ot_layout_lookup_get_glyph_alternates(face._hb_face, lookup_index, glyph, start_offset, &alternate_count, alternate_glyphs)
for i in range(alternate_count):
alt_glyphs.append(alternate_glyphs[i])
return alt_glyphs


def ot_layout_language_get_feature_tags(
face: Face, tag: str, script_index: int = 0,
language_index: int = 0xFFFF) -> List[str]:
Expand Down
8 changes: 7 additions & 1 deletion src/uharfbuzz/charfbuzz.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,14 @@ cdef extern from "hb.h":


cdef extern from "hb-ot.h":

# hb-ot-layout.h
unsigned int hb_ot_layout_lookup_get_glyph_alternates(
hb_face_t* face,
unsigned lookup_index,
hb_codepoint_t glyph,
unsigned start_offset,
unsigned * alternate_count,
hb_codepoint_t *alternate_glyphs)
unsigned int hb_ot_layout_language_get_feature_tags(
hb_face_t* face,
hb_tag_t table_tag,
Expand Down
Loading