Skip to content

Commit

Permalink
Merge pull request #189 from harfbuzz/paint-cleanup
Browse files Browse the repository at this point in the history
Don’t pass font to pain functions
  • Loading branch information
khaledhosny authored Feb 3, 2024
2 parents f3e9145 + f0b5b96 commit 19ceb59
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/uharfbuzz/_harfbuzz.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1728,8 +1728,7 @@ cdef hb_bool_t _paint_color_glyph_func(
hb_font_t *font,
void *user_data) noexcept:
py_funcs = <PaintFuncs>user_data
py_font = Font.from_ptr(hb_font_reference(font))
if py_funcs._color_glyph_func(py_font, glyph, <object>paint_data):
if py_funcs._color_glyph_func(glyph, <object>paint_data):
return 1
return 0

Expand All @@ -1741,8 +1740,7 @@ cdef void _paint_push_clip_glyph_func(
hb_font_t *font,
void *user_data) noexcept:
py_funcs = <PaintFuncs>user_data
py_font = Font.from_ptr(hb_font_reference(font))
py_funcs._push_clip_glyph_func(py_font, glyph, <object>paint_data)
py_funcs._push_clip_glyph_func(glyph, <object>paint_data)


cdef void _paint_push_clip_rectangle_func(
Expand Down Expand Up @@ -1920,7 +1918,6 @@ cdef class PaintFuncs:

def set_color_glyph_func(self,
func: Callable[[
Font,
int, # gid
object, # paint_data
], bool]) -> None:
Expand All @@ -1930,7 +1927,6 @@ cdef class PaintFuncs:

def set_push_clip_glyph_func(self,
func: Callable[[
Font,
int, # gid
object, # paint_data
], None]) -> None:
Expand Down
4 changes: 2 additions & 2 deletions tests/test_uharfbuzz.py
Original file line number Diff line number Diff line change
Expand Up @@ -815,11 +815,11 @@ def pop_transform_func(conainer):
conainer.level -= 1
conainer.append(f"end transform")

def color_glyph_func(font, gid, conainer):
def color_glyph_func(gid, conainer):
conainer.append(f"paint color glyph {gid}; acting as failed")
return False

def push_clip_glyph_func(font, gid, conainer):
def push_clip_glyph_func(gid, conainer):
conainer.append(f"start clip glyph {gid}")
conainer.level += 1
return True
Expand Down

0 comments on commit 19ceb59

Please sign in to comment.