Skip to content

Commit

Permalink
Bind hb_ot_layout_lookup_get_glyph_alternates()
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-99 committed Jan 4, 2024
1 parent e8bfad7 commit 0d93f3b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
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

0 comments on commit 0d93f3b

Please sign in to comment.