diff --git a/CMakeLists.txt b/CMakeLists.txt index 527552896..37756dfb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -212,9 +212,18 @@ option(FT_DISABLE_HARFBUZZ cmake_dependent_option(FT_DYNAMIC_HARFBUZZ "Load HarfBuzz library dynamically at runtime, if possible." ON "NOT FT_DISABLE_HARFBUZZ" OFF) +cmake_dependent_option(FT_USE_HARFBUZZ_CALLBACKS + "Let HarfBuzz library inject callback methods at runtime." OFF + "NOT FT_DISABLE_HARFBUZZ;NOT FT_DYNAMIC_HARFBUZZ" OFF) cmake_dependent_option(FT_REQUIRE_HARFBUZZ "Require HarfBuzz for improving auto-hinting of OpenType fonts." OFF "NOT FT_DISABLE_HARFBUZZ" OFF) +cmake_dependent_option(FT_USE_HARFBUZZ_CALLING_CONVENTION_CDECL + "use HarfBuzz library as cdecl." OFF + "NOT FT_DISABLE_HARFBUZZ" OFF) +cmake_dependent_option(FT_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL + "use HarfBuzz library as stdcall." OFF + "NOT FT_DISABLE_HARFBUZZ;NOT FT_USE_HARFBUZZ_CALLING_CONVENTION_CDECL" OFF) option(FT_DISABLE_BROTLI "Disable support of compressed WOFF2 fonts." OFF) @@ -282,10 +291,13 @@ if (NOT FT_DISABLE_HARFBUZZ) endif() endif() endif() + elseif(FT_USE_HARFBUZZ_CALLBACKS) + set(FT_HARFBUZZ_CALLBACKS_ENABLED TRUE) endif() - if (FT_DYNAMIC_HARFBUZZ_ENABLED) message(STATUS "Enabled dynamic loading of HarfBuzz library at runtime.") + elseif (FT_HARFBUZZ_CALLBACKS_ENABLED) + message(STATUS "Enable HarfBuzz to inject callbacks into FreeType.") elseif (FT_REQUIRE_HARFBUZZ) find_package(HarfBuzz ${HARFBUZZ_MIN_VERSION} REQUIRED) else () @@ -414,7 +426,7 @@ if (PNG_FOUND) "/\\* +(#define +FT_CONFIG_OPTION_USE_PNG) +\\*/" "\\1" FTOPTION_H "${FTOPTION_H}") endif () -if (HARFBUZZ_FOUND OR FT_DYNAMIC_HARFBUZZ_ENABLED) +if (HARFBUZZ_FOUND OR FT_DYNAMIC_HARFBUZZ_ENABLED OR FT_HARFBUZZ_CALLBACKS_ENABLED) string(REGEX REPLACE "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ) +\\*/" "\\1" FTOPTION_H "${FTOPTION_H}") @@ -422,7 +434,20 @@ if (HARFBUZZ_FOUND OR FT_DYNAMIC_HARFBUZZ_ENABLED) string(REGEX REPLACE "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC) +\\*/" "\\1" FTOPTION_H "${FTOPTION_H}") + elseif (FT_HARFBUZZ_CALLBACKS_ENABLED) + string(REGEX REPLACE + "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS) +\\*/" "\\1" + FTOPTION_H "${FTOPTION_H}") endif () + if (FT_USE_HARFBUZZ_CALLING_CONVENTION_CDECL) + string(REGEX REPLACE + "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL) +\\*/" "\\1" + FTOPTION_H "${FTOPTION_H}") + elseif(FT_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL) + string(REGEX REPLACE + "/\\* +(#define +FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL) +\\*/" "\\1" + FTOPTION_H "${FTOPTION_H}") + endif() endif () if (BROTLIDEC_FOUND) string(REGEX REPLACE @@ -625,7 +650,7 @@ if (FT_DYNAMIC_HARFBUZZ_ENABLED AND FT_NEED_LIBDL) target_link_libraries(freetype PRIVATE dl) list(APPEND PKGCONFIG_LIBS_PRIVATE " -ldl") endif () -if (HarfBuzz_FOUND AND (NOT FT_DYNAMIC_HARFBUZZ_ENABLED)) +if (HarfBuzz_FOUND AND (NOT FT_DYNAMIC_HARFBUZZ_ENABLED) AND (NOT FT_HARFBUZZ_CALLBACKS_ENABLED)) target_link_libraries(freetype PRIVATE HarfBuzz::HarfBuzz) list(APPEND PKGCONFIG_REQUIRES_PRIVATE "harfbuzz >= ${HARFBUZZ_MIN_VERSION}") endif () diff --git a/builds/unix/configure.raw b/builds/unix/configure.raw index 62be4672a..37d665e1b 100644 --- a/builds/unix/configure.raw +++ b/builds/unix/configure.raw @@ -441,7 +441,7 @@ fi # check for system libharfbuzz AC_ARG_WITH([harfbuzz], - [AS_HELP_STRING([--with-harfbuzz=@<:@yes|dynamic|no|auto@:>@], + [AS_HELP_STRING([--with-harfbuzz=@<:@yes|dynamic|no|callbacks|auto@:>@], [improve auto-hinting of OpenType fonts @<:@default=auto@:>@])], [], [with_harfbuzz=auto]) @@ -505,6 +505,14 @@ if test x"$have_harfbuzz" = xno; then ;; esac fi + + +have_harfbuzz_callbacks=no +if test x"$have_harfbuzz" = xno; then + if test x"$with_harfbuzz" = xcallbacks; then + have_harfbuzz_callbacks=yes + have_harfbuzz="yes (callbacks)" + fi fi if test x"$have_harfbuzz" = xno; then @@ -1203,6 +1211,25 @@ if test "$have_harfbuzz_dynamic" != no; then else ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC fi +if test "$have_harfbuzz_callbacks" != no; then + ftoption_set FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS +else + ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS +fi +AC_ARG_WITH([harfbuzz-calling-convention], + [AS_HELP_STRING([--with-harfbuzz-calling-convention=@<:@auto|cdecl|stdcall@:>@], + [calling convention of harfbuzz library @<:@default=auto@:>@])], + [], [with_harfbuzz_calling_convention=auto]) +if test x"$with_harfbuzz_calling_convention" = xcdecl; then + ftoption_set FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL +else + ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL +fi +if test x"$with_harfbuzz_calling_convention" = xstdcall; then + ftoption_set FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL +else + ftoption_unset FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL +fi if test "$have_brotli" != no; then CFLAGS="$CFLAGS $BROTLI_CFLAGS" LDFLAGS="$LDFLAGS $BROTLI_LIBS" diff --git a/include/freetype/config/ftoption.h b/include/freetype/config/ftoption.h index 073a507c0..b48277e32 100644 --- a/include/freetype/config/ftoption.h +++ b/include/freetype/config/ftoption.h @@ -317,6 +317,64 @@ FT_BEGIN_HEADER */ /* #define FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */ + /************************************************************************** + * + * HarfBuzz callbacks support. + * + * Define this macro if you want the HarfBuzz library to inject callback + * functions to FreeType + * + * This option has no effect if `FT_CONFIG_OPTION_USE_HARFBUZZ` is not + * defined. + * + * When this option is enabled, FreeType will not load or link to the + * HarfBuzz library. Instead, the HarfBuzz library is expected to set + * use property 'harfbuzz-callbacks' to pass callback functions into + * FreeType. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS */ + + /************************************************************************** + * + * HarfBuzz dynamic/callbacks calling convention. + * + * Define this macro if the HarfBuzz library is using cdecl calling + * convention + * + * This option has no effect if not using harfbuzz mode 'dynamic' or + * 'callbacks'. + * + * When this option is enabled, FreeType will consider loaded or + * injected HarfBuzz-related functions as __cdecl. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL */ + + /************************************************************************** + * + * HarfBuzz dynamic/callbacks calling convention. + * + * Define this macro if the HarfBuzz library is using stdcall calling + * convention + * + * This option has no effect if not using harfbuzz mode 'dynamic' or + * 'callbacks'. + * + * When this option is enabled, FreeType will consider loaded or + * injected HarfBuzz-related functions as __stdcall. + * + * If you use a build system like cmake or the `configure` script, + * options set by those programs have precedence, overwriting the value + * here with the configured one. + */ +/* #define FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL */ /************************************************************************** * diff --git a/src/autofit/ft-hb-decls.h b/include/freetype/ft-hb-decls.h similarity index 84% rename from src/autofit/ft-hb-decls.h rename to include/freetype/ft-hb-decls.h index 032d4d37a..db6976dd4 100644 --- a/src/autofit/ft-hb-decls.h +++ b/include/freetype/ft-hb-decls.h @@ -27,90 +27,90 @@ /* All HarfBuzz function declarations used by FreeType, taken */ /* from various public HarfBuzz header files. The wrapper macro */ - /* `HB_EXTERN` is defined in `ft-hb.h`. */ + /* `FT_HB_EXTERN` is defined in `ft-hb.h`. */ /* hb-blob.h */ -HB_EXTERN(hb_blob_t *, +FT_HB_EXTERN(hb_blob_t *, hb_blob_create,(const char *data, unsigned int length, hb_memory_mode_t mode, void *user_data, hb_destroy_func_t destroy)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_blob_destroy,(hb_blob_t *blob)) /* hb-buffer.h */ -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_buffer_add_utf8,(hb_buffer_t *buffer, const char *text, int text_length, unsigned int item_offset, int item_length)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_buffer_clear_contents,(hb_buffer_t *buffer)) -HB_EXTERN(hb_buffer_t *, +FT_HB_EXTERN(hb_buffer_t *, hb_buffer_create,(void)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_buffer_destroy,(hb_buffer_t *buffer)) -HB_EXTERN(hb_glyph_info_t *, +FT_HB_EXTERN(hb_glyph_info_t *, hb_buffer_get_glyph_infos,(hb_buffer_t *buffer, unsigned int *length)) -HB_EXTERN(hb_glyph_position_t *, +FT_HB_EXTERN(hb_glyph_position_t *, hb_buffer_get_glyph_positions,(hb_buffer_t *buffer, unsigned int *length)) -HB_EXTERN(unsigned int, +FT_HB_EXTERN(unsigned int, hb_buffer_get_length,(const hb_buffer_t *buffer)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_buffer_guess_segment_properties,(hb_buffer_t *buffer)) /* hb-face.h */ -HB_EXTERN(hb_face_t *, +FT_HB_EXTERN(hb_face_t *, hb_face_create,(hb_blob_t *blob, unsigned int index)) -HB_EXTERN(hb_face_t *, +FT_HB_EXTERN(hb_face_t *, hb_face_create_for_tables,(hb_reference_table_func_t reference_table_func, void *user_data, hb_destroy_func_t destroy)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_face_destroy,(hb_face_t *face)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_face_set_index,(hb_face_t *face, unsigned int index)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_face_set_upem,(hb_face_t *face, unsigned int upem)) /* hb-font.h */ -HB_EXTERN(hb_font_t *, +FT_HB_EXTERN(hb_font_t *, hb_font_create,(hb_face_t *face)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_font_destroy,(hb_font_t *font)) -HB_EXTERN(hb_face_t *, +FT_HB_EXTERN(hb_face_t *, hb_font_get_face,(hb_font_t *font)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_font_set_scale,(hb_font_t *font, int x_scale, int y_scale)) @@ -118,7 +118,7 @@ hb_font_set_scale,(hb_font_t *font, /* hb-ot-layout.h */ -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_ot_layout_collect_lookups,(hb_face_t *face, hb_tag_t table_tag, const hb_tag_t *scripts, @@ -126,7 +126,7 @@ hb_ot_layout_collect_lookups,(hb_face_t *face, const hb_tag_t *features, hb_set_t *lookup_indexes /* OUT */)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_ot_layout_lookup_collect_glyphs,(hb_face_t *face, hb_tag_t table_tag, unsigned int lookup_index, @@ -135,14 +135,14 @@ hb_ot_layout_lookup_collect_glyphs,(hb_face_t *face, hb_set_t *glyphs_after, /* OUT. May be NULL */ hb_set_t *glyphs_output /* OUT. May be NULL */)) -HB_EXTERN(hb_bool_t, +FT_HB_EXTERN(hb_bool_t, hb_ot_layout_lookup_would_substitute,(hb_face_t *face, unsigned int lookup_index, const hb_codepoint_t *glyphs, unsigned int glyphs_length, hb_bool_t zero_context)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_ot_tags_from_script_and_language,(hb_script_t script, hb_language_t language, unsigned int *script_count /* IN/OUT */, @@ -153,48 +153,48 @@ hb_ot_tags_from_script_and_language,(hb_script_t script, /* hb-set.h */ -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_set_add,(hb_set_t *set, hb_codepoint_t codepoint)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_set_clear,(hb_set_t *set)) -HB_EXTERN(hb_set_t *, +FT_HB_EXTERN(hb_set_t *, hb_set_create,(void)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_set_destroy,(hb_set_t *set)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_set_del,(hb_set_t *set, hb_codepoint_t codepoint)) -HB_EXTERN(hb_bool_t, +FT_HB_EXTERN(hb_bool_t, hb_set_has,(const hb_set_t *set, hb_codepoint_t codepoint)) -HB_EXTERN(hb_bool_t, +FT_HB_EXTERN(hb_bool_t, hb_set_is_empty,(const hb_set_t *set)) -HB_EXTERN(hb_bool_t, +FT_HB_EXTERN(hb_bool_t, hb_set_next,(const hb_set_t *set, hb_codepoint_t *codepoint)) -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_set_subtract,(hb_set_t *set, const hb_set_t *other)) /* hb-shape.h */ -HB_EXTERN(void, +FT_HB_EXTERN(void, hb_shape,(hb_font_t *font, hb_buffer_t *buffer, const hb_feature_t *features, unsigned int num_features)) -HB_EXTERN(hb_bool_t, +FT_HB_EXTERN(hb_bool_t, hb_version_atleast,(unsigned int major, unsigned int minor, unsigned int micro)) diff --git a/include/freetype/ft-hb-functype.h b/include/freetype/ft-hb-functype.h new file mode 100644 index 000000000..615461076 --- /dev/null +++ b/include/freetype/ft-hb-functype.h @@ -0,0 +1,70 @@ +/**************************************************************************** + * + * ft-hb-functype.h + * + * FreeType-HarfBuzz bridge (specification). + * + * Copyright (C) 2025 by + * 6ziv. + * + * This file is part of the FreeType project, and may only be used, + * modified, and distributed under the terms of the FreeType project + * license, LICENSE.TXT. By continuing to use, modify, or distribute + * this file you indicate that you have read the license and + * understand and accept it fully. + * + * + * Originally located in src/autofit/ft-hb.h + * Move to a public header so that external projects can rely on this. + * + */ + +#ifndef FT_HB_FUNCTYPE_H +#define FT_HB_FUNCTYPE_H + +#include +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) || \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) + +#include + +#if defined(FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL) + +#if defined( __GNUC__ ) +#define FT_HB_CALLBACK +#elif defined( _MSC_VER) +#define FT_HB_CALLBACK __cdecl +#endif + +#elif defined(FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL) /* FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL */ + +#if defined( __GNUC__ ) +#define FT_HB_CALLBACK __attribute__((stdcall)) +#elif defined( _MSC_VER) +#define FT_HB_CALLBACK __stdcall +#endif + +#endif /* FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL */ + +#ifndef FT_HB_CALLBACK +#define FT_HB_CALLBACK +#endif + +#define FT_HB_EXTERN( ret, name, args ) \ + typedef ret (FT_HB_CALLBACK *ft_ ## name ## _func_t) args; +#include +#undef FT_HB_EXTERN + +typedef struct ft_hb_funcs_t +{ + + #define FT_HB_EXTERN( ret, name, args ) \ + ft_ ## name ## _func_t name; +#include +#undef FT_HB_EXTERN + +} ft_hb_funcs_t; + +#endif + +#endif /* FT_HB_FUNCTYPE_H */ \ No newline at end of file diff --git a/src/autofit/ft-hb-types.h b/include/freetype/ft-hb-types.h similarity index 100% rename from src/autofit/ft-hb-types.h rename to include/freetype/ft-hb-types.h diff --git a/meson.build b/meson.build index eec558373..d95b61505 100644 --- a/meson.build +++ b/meson.build @@ -183,6 +183,9 @@ ft2_public_headers = files([ 'include/freetype/ttnameid.h', 'include/freetype/tttables.h', 'include/freetype/tttags.h', + 'include/freetype/ft-hb-types.h', + 'include/freetype/ft-hb-decls.h', + 'include/freetype/ft-hb-functype.h' ]) ft2_config_headers = files([ @@ -388,10 +391,31 @@ if not harfbuzz_dep.found() and \ endif endif +if harfbuzz_opt == 'callbacks' + ftoption_command += [ + '--enable=FT_CONFIG_OPTION_USE_HARFBUZZ', + '--enable=FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS', + ] +endif + if harfbuzz_opt == 'disabled' or harfbuzz_opt == 'auto' harfbuzz_opt = 'NO' endif +if harfbuzz_opt == 'dynamic' or harfbuzz_opt == 'callbacks' + harfbuzz_calling_convention = get_option('harfbuzz_calling_convention') + if harfbuzz_calling_convention == 'cdecl' + ftoption_command += [ + '--enable=FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_CDECL', + ] + endif + if harfbuzz_calling_convention == 'stdcall' + ftoption_command += [ + '--enable=FT_CONFIG_OPTION_USE_HARFBUZZ_CALLING_CONVENTION_STDCALL', + ] + endif +endif + # Brotli decompression support. brotli_dep = dependency('libbrotlidec', required: get_option('brotli')) diff --git a/meson_options.txt b/meson_options.txt index 67d0fa313..fdb9bf41f 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -24,12 +24,21 @@ option('bzip2', option('harfbuzz', type: 'combo', - choices: ['auto', 'enabled', 'dynamic', 'disabled'], + choices: ['auto', 'enabled', 'dynamic', 'disabled', 'callbacks'], value: 'auto', description: 'Use Harfbuzz library to improve auto-hinting;' + ' if available, many glyphs not directly addressable' + ' by a font\'s character map will be hinted also') +option('harfbuzz_calling_convention', + type: 'combo', + choices: ['auto', 'stdcall', 'cdecl'], + value: 'auto', + description: 'Calling-convention for HarfBuzz. Only used when using' + + ' harfbuzz=\'dynamic\' or harfbuzz=\'callbacks\'. If' + + ' unspecified or set to \'auto\', no specifier will' + + ' be added.') + option('mmap', type: 'feature', value: 'auto', diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c index 57d5d47df..b44681702 100644 --- a/src/autofit/afmodule.c +++ b/src/autofit/afmodule.c @@ -275,7 +275,16 @@ return error; } - +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) +#if defined ( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) +#error "Can not set both dynamic harfbuzz and injected harfbuzz callbacks" +#endif + else if ( !ft_strcmp( property_name, "harfbuzz-callbacks" ) ) + { + module->hb_funcs = (ft_hb_funcs_t*)value; + } +#endif FT_TRACE2(( "af_property_set: missing property `%s'\n", property_name )); return FT_THROW( Missing_Property ); @@ -362,7 +371,17 @@ return error; } - +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) +#if defined ( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) +#error "Can not set both dynamic harfbuzz and injected harfbuzz callbacks" +#endif + else if ( !ft_strcmp( property_name, "harfbuzz-callbacks" ) ) + { + ft_hb_funcs_t **val = (ft_hb_funcs_t **)value; + *val = module->hb_funcs; + } +#endif FT_TRACE2(( "af_property_get: missing property `%s'\n", property_name )); return FT_THROW( Missing_Property ); diff --git a/src/autofit/afmodule.h b/src/autofit/afmodule.h index 1f8a68122..695b4aa63 100644 --- a/src/autofit/afmodule.h +++ b/src/autofit/afmodule.h @@ -41,8 +41,9 @@ FT_BEGIN_HEADER FT_Bool no_stem_darkening; FT_Int darken_params[8]; -#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \ - defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \ + ( defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) || \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) ) ft_hb_funcs_t* hb_funcs; #endif diff --git a/src/autofit/ft-hb.c b/src/autofit/ft-hb.c index ed438da6a..889b749ee 100644 --- a/src/autofit/ft-hb.c +++ b/src/autofit/ft-hb.c @@ -131,14 +131,14 @@ goto Fail; /* Load all symbols we use. */ -#define HB_EXTERN( ret, name, args ) \ +#define FT_HB_EXTERN( ret, name, args ) \ { \ funcs->name = DLSYM( lib, name ); \ if ( !funcs->name ) \ goto Fail; \ } -#include "ft-hb-decls.h" -#undef HB_EXTERN +#include +#undef FT_HB_EXTERN #undef DLSYM @@ -179,6 +179,14 @@ #else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */ +#if defined( FT_CONFIG_OPTION_USE_HARFBUZZ ) && \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) + FT_LOCAL_DEF( FT_Bool ) + ft_hb_enabled( struct AF_FaceGlobalsRec_ *globals ) + { + return globals->module->hb_funcs != NULL; + } +#else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS*/ FT_LOCAL_DEF( FT_Bool ) ft_hb_enabled( struct AF_FaceGlobalsRec_ *globals ) { @@ -191,6 +199,8 @@ #endif } +#endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS */ + #endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */ diff --git a/src/autofit/ft-hb.h b/src/autofit/ft-hb.h index d2cc0482e..4b13aaab1 100644 --- a/src/autofit/ft-hb.h +++ b/src/autofit/ft-hb.h @@ -27,23 +27,13 @@ FT_BEGIN_HEADER #ifdef FT_CONFIG_OPTION_USE_HARFBUZZ -# include "ft-hb-types.h" +# include + +# if defined( FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC ) || \ + defined( FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS ) # ifdef FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC -# define HB_EXTERN( ret, name, args ) \ - typedef ret (*ft_ ## name ## _func_t) args; -# include "ft-hb-decls.h" -# undef HB_EXTERN - - typedef struct ft_hb_funcs_t - { -# define HB_EXTERN( ret, name, args ) \ - ft_ ## name ## _func_t name; -# include "ft-hb-decls.h" -# undef HB_EXTERN - } ft_hb_funcs_t; - struct AF_ModuleRec_; FT_LOCAL( void ) @@ -52,14 +42,16 @@ FT_BEGIN_HEADER FT_LOCAL( void ) ft_hb_funcs_done( struct AF_ModuleRec_ *af_module ); +# endif /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */ + # define hb( x ) globals->module->hb_funcs->hb_ ## x -# else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC */ +# else /* !FT_CONFIG_OPTION_USE_HARFBUZZ_DYNAMIC && !FT_CONFIG_OPTION_USE_HARFBUZZ_CALLBACKS*/ -# define HB_EXTERN( ret, name, args ) \ +# define FT_HB_EXTERN( ret, name, args ) \ ret name args; -# include "ft-hb-decls.h" -# undef HB_EXTERN +# include +# undef FT_HB_EXTERN # define hb( x ) hb_ ## x diff --git a/src/autofit/rules.mk b/src/autofit/rules.mk index 9e39db33c..45d9aae46 100644 --- a/src/autofit/rules.mk +++ b/src/autofit/rules.mk @@ -53,8 +53,7 @@ AUTOF_DRV_H := $(AUTOF_DRV_SRC:%c=%h) \ $(AUTOF_DIR)/afstyles.h \ $(AUTOF_DIR)/aftypes.h \ $(AUTOF_DIR)/afws-decl.h \ - $(AUTOF_DIR)/afws-iter.h \ - $(AUTOF_DIR)/ft-hb-decls.h + $(AUTOF_DIR)/afws-iter.h # AUTOF driver object(s)