diff --git a/Makefile b/Makefile index be364ef787fa62c99fc0960bd33058a93bc62b10..5c816dc3f8c65e7db1d5790c74c7089551258a46 100644 --- a/Makefile +++ b/Makefile @@ -132,7 +132,8 @@ else # # For the pure `make` call (without using `configure`) we have to add # all needed cflags manually. - FT_DEMO_CFLAGS := $(shell pkg-config --cflags librsvg-2.0) + FT_DEMO_CFLAGS := $(shell pkg-config --cflags librsvg-2.0) \ + -DHAVE_LIBRSVG endif FT_INCLUDES := $(OBJ_BUILD) \ diff --git a/meson.build b/meson.build index 9a5b9578e6175bdc2190c398e97280b4c1e05598..f2df6a21492bfec5174033df3792ec68bce33b9b 100644 --- a/meson.build +++ b/meson.build @@ -77,6 +77,7 @@ ftcommon_lib = static_library('ftcommon', 'src/rsvg-port.c', 'src/rsvg-port.h', ], + c_args: [-DHAVE_LIBRSVG], dependencies: [libpng_dep, librsvg_dep, libfreetype2_dep], include_directories: graph_include_dir, link_with: [common_lib, graph_lib], diff --git a/src/ftcommon.c b/src/ftcommon.c index a9f26fa830aba6d55b70f3c550c26009d7bf45d9..64768bb18f9c8495aa5c0881ab683e7f9147cf3d 100644 --- a/src/ftcommon.c +++ b/src/ftcommon.c @@ -27,7 +27,6 @@ #include FT_BITMAP_H #include FT_FONT_FORMATS_H -#include FT_OTSVG_H /* error messages */ @@ -340,12 +339,6 @@ { FTDemo_Handle* handle; - SVG_RendererHooks hooks = { - (SVG_Lib_Init_Func)rsvg_port_init, - (SVG_Lib_Free_Func)rsvg_port_free, - (SVG_Lib_Render_Func)rsvg_port_render, - (SVG_Lib_Preset_Slot_Func)rsvg_port_preset_slot }; - handle = (FTDemo_Handle *)malloc( sizeof ( FTDemo_Handle ) ); if ( !handle ) @@ -357,8 +350,9 @@ if ( error ) PanicZ( "could not initialize FreeType" ); - /* XXX error handling? */ - FT_Property_Set( handle->library, "ot-svg", "svg-hooks", &hooks ); + /* The use of an external SVG rendering library is optional. */ + (void)FT_Property_Set( handle->library, + "ot-svg", "svg-hooks", &rsvg_hooks ); error = FTC_Manager_New( handle->library, 0, 0, 0, my_face_requester, 0, &handle->cache_manager ); diff --git a/src/rsvg-port.c b/src/rsvg-port.c index 12166303884e9f02cc1601f1cb9761f1654da5a1..eea3f0a0c2ad291f66eb92b3dc826b39356ff49b 100644 --- a/src/rsvg-port.c +++ b/src/rsvg-port.c @@ -16,6 +16,11 @@ * */ +#include +#include FT_OTSVG_H + +#ifdef HAVE_LIBRSVG + #include #include #include @@ -397,4 +402,18 @@ } + SVG_RendererHooks rsvg_hooks = { + (SVG_Lib_Init_Func)rsvg_port_init, + (SVG_Lib_Free_Func)rsvg_port_free, + (SVG_Lib_Render_Func)rsvg_port_render, + (SVG_Lib_Preset_Slot_Func)rsvg_port_preset_slot + }; + +#else /* !HAVE_LIBRSVG */ + + SVG_RendererHooks rsvg_hooks = { NULL, NULL, NULL, NULL }; + +#endif /* !HAVE_LIBRSVG */ + + /* End */ diff --git a/src/rsvg-port.h b/src/rsvg-port.h index 87a388577f8105e9adf4990842add9369db5d48f..efcc1e1b1c301b1080e500549bc10d26fe3bbc7f 100644 --- a/src/rsvg-port.h +++ b/src/rsvg-port.h @@ -19,6 +19,11 @@ #ifndef RSVG_PORT_H #define RSVG_PORT_H +#include +#include FT_OTSVG_H + +#ifdef HAVE_LIBRSVG + #include #include #include @@ -57,6 +62,11 @@ FT_Bool cache, FT_Pointer *state ); +#endif /* HAVE_LIBRSVG */ + + + extern SVG_RendererHooks rsvg_hooks; + #endif /* RSVG_PORT_H */