Skip to content

Commit

Permalink
fix: fix svg c code extern problem
Browse files Browse the repository at this point in the history
  • Loading branch information
KonghaYao committed Nov 27, 2024
1 parent 0864641 commit 0e336aa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 18 deletions.
36 changes: 19 additions & 17 deletions src/subset/hb-glyph-to-svg-path.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,26 @@ close_path(hb_draw_funcs_t *dfuncs, user_data_t *draw_data, hb_draw_state_t *, v

static hb_draw_funcs_t *funcs = 0;


int hb_glyph_to_svg_path(hb_font_t *font, hb_codepoint_t glyph, char *buf, unsigned buf_size)
extern "C"
{
if (funcs == 0) /* not the best pattern for multi-threaded apps which is not a concern here */
int hb_glyph_to_svg_path(hb_font_t *font, hb_codepoint_t glyph, char *buf, unsigned buf_size)
{
funcs = hb_draw_funcs_create(); /* will be leaked */
hb_draw_funcs_set_move_to_func(funcs, (hb_draw_move_to_func_t)move_to, nullptr, nullptr);
hb_draw_funcs_set_line_to_func(funcs, (hb_draw_line_to_func_t)line_to, nullptr, nullptr);
hb_draw_funcs_set_quadratic_to_func(funcs, (hb_draw_quadratic_to_func_t)quadratic_to, nullptr, nullptr);
hb_draw_funcs_set_cubic_to_func(funcs, (hb_draw_cubic_to_func_t)cubic_to, nullptr, nullptr);
hb_draw_funcs_set_close_path_func(funcs, (hb_draw_close_path_func_t)close_path, nullptr, nullptr);
if (funcs == 0) /* not the best pattern for multi-threaded apps which is not a concern here */
{
funcs = hb_draw_funcs_create(); /* will be leaked */
hb_draw_funcs_set_move_to_func(funcs, (hb_draw_move_to_func_t)move_to, nullptr, nullptr);
hb_draw_funcs_set_line_to_func(funcs, (hb_draw_line_to_func_t)line_to, nullptr, nullptr);
hb_draw_funcs_set_quadratic_to_func(funcs, (hb_draw_quadratic_to_func_t)quadratic_to, nullptr, nullptr);
hb_draw_funcs_set_cubic_to_func(funcs, (hb_draw_cubic_to_func_t)cubic_to, nullptr, nullptr);
hb_draw_funcs_set_close_path_func(funcs, (hb_draw_close_path_func_t)close_path, nullptr, nullptr);
}

user_data_t draw_data(buf, buf_size);
hb_font_draw_glyph(font, glyph, funcs, &draw_data);
if (draw_data.failure)
return -1;

buf[draw_data.consumed] = '\0';
return draw_data.consumed;
}

user_data_t draw_data(buf, buf_size);
hb_font_draw_glyph(font, glyph, funcs, &draw_data);
if (draw_data.failure)
return -1;

buf[draw_data.consumed] = '\0';
return draw_data.consumed;
}
5 changes: 4 additions & 1 deletion src/subset/hb-glyph-to-svg-path.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#include "../../harfbuzz/src/hb.h"

int hb_glyph_to_svg_path(hb_font_t *font, hb_codepoint_t glyph, char *buf, unsigned buf_size);
extern "C"
{
int hb_glyph_to_svg_path(hb_font_t *font, hb_codepoint_t glyph, char *buf, unsigned buf_size);
}

0 comments on commit 0e336aa

Please sign in to comment.