Skip to content

Commit

Permalink
WIP: make tracing more usable
Browse files Browse the repository at this point in the history
  • Loading branch information
khaledhosny committed Oct 18, 2023
1 parent 1a7d36e commit 87d5fc2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 11 additions & 1 deletion src/uharfbuzz/_harfbuzz.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ cdef extern from "Python.h":


cdef int msgcallback(hb_buffer_t *buffer, hb_font_t *font, const char* message, void* userdata) noexcept:
ret = (<object>userdata)(message.decode('utf-8'))
ret = (<object>userdata)(message.decode('utf-8'), Buffer.from_ptr(buffer))
if ret is None:
return 1
return ret
Expand Down Expand Up @@ -150,6 +150,15 @@ cdef class Buffer:
cdef Buffer inst = cls()
return inst

@staticmethod
cdef Buffer from_ptr(hb_buffer_t* hb_buffer):
"""Create Buffer from a pointer."""

cdef Buffer wrapper = Buffer.__new__(Buffer)
wrapper._hb_buffer = hb_buffer_reference(hb_buffer)
wrapper._message_callback = None
return wrapper

def __len__(self) -> int:
return hb_buffer_get_length(self._hb_buffer)

Expand Down Expand Up @@ -1663,6 +1672,7 @@ class SubsetFlags(IntFlag):
NOTDEF_OUTLINE = HB_SUBSET_FLAGS_NOTDEF_OUTLINE
GLYPH_NAMES = HB_SUBSET_FLAGS_GLYPH_NAMES
NO_PRUNE_UNICODE_RANGES = HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES
NO_LAYOUT_CLOSURE = HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE
cdef class SubsetInput:
Expand Down
4 changes: 2 additions & 2 deletions src/uharfbuzz/charfbuzz.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ cdef extern from "hb.h":
hb_buffer_cluster_level_t cluster_level)
hb_buffer_cluster_level_t hb_buffer_get_cluster_level(hb_buffer_t *buffer)
void hb_buffer_destroy(hb_buffer_t* buffer)
hb_buffer_t* hb_buffer_reference(hb_buffer_t* buffer)
ctypedef hb_bool_t (*hb_buffer_message_func_t) (
hb_buffer_t *buffer,
hb_font_t *font,
Expand Down Expand Up @@ -681,8 +682,7 @@ cdef extern from "hb-subset.h":
HB_SUBSET_FLAGS_NOTDEF_OUTLINE
HB_SUBSET_FLAGS_GLYPH_NAMES
HB_SUBSET_FLAGS_NO_PRUNE_UNICODE_RANGES
# Not supported yet: HB_SUBSET_FLAGS_PATCH_MODE
# Not supported yet: HB_SUBSET_FLAGS_OMIT_GLYF
HB_SUBSET_FLAGS_NO_LAYOUT_CLOSURE
ctypedef enum hb_subset_sets_t:
HB_SUBSET_SETS_GLYPH_INDEX
HB_SUBSET_SETS_UNICODE
Expand Down

0 comments on commit 87d5fc2

Please sign in to comment.