diff --git a/src/subset/hb-glyph-to-svg-path.cc b/src/subset/hb-glyph-to-svg-path.cc index 24f19f1..a65789f 100644 --- a/src/subset/hb-glyph-to-svg-path.cc +++ b/src/subset/hb-glyph-to-svg-path.cc @@ -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; } \ No newline at end of file diff --git a/src/subset/hb-glyph-to-svg-path.h b/src/subset/hb-glyph-to-svg-path.h index d1170b4..d2bd3e6 100644 --- a/src/subset/hb-glyph-to-svg-path.h +++ b/src/subset/hb-glyph-to-svg-path.h @@ -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); +} \ No newline at end of file