freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 164f5df: Use 'librsvg' conditionally.


From: Werner Lemberg
Subject: [freetype2-demos] master 164f5df: Use 'librsvg' conditionally.
Date: Wed, 26 Jan 2022 00:29:45 -0500 (EST)

branch: master
commit 164f5dfd429bce40cac2eedbfa4fbbc6f04665ee
Author: Werner Lemberg <wl@gnu.org>
Commit: Werner Lemberg <wl@gnu.org>

    Use 'librsvg' conditionally.
    
    * src/ftcommon.c, src/rsvg-port.c: Guard SVG code with `HAVE_LIBRSVG`.
---
 Makefile        |  3 ++-
 meson.build     |  1 +
 src/ftcommon.c  | 12 +++---------
 src/rsvg-port.c | 19 +++++++++++++++++++
 src/rsvg-port.h | 10 ++++++++++
 5 files changed, 35 insertions(+), 10 deletions(-)

diff --git a/Makefile b/Makefile
index be364ef..5c816dc 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 9a5b957..f2df6a2 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 a9f26fa..64768bb 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 1216630..eea3f0a 100644
--- a/src/rsvg-port.c
+++ b/src/rsvg-port.c
@@ -16,6 +16,11 @@
  *
  */
 
+#include <ft2build.h>
+#include FT_OTSVG_H
+
+#ifdef HAVE_LIBRSVG
+
 #include <cairo.h>
 #include <librsvg/rsvg.h>
 #include <stdlib.h>
@@ -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 87a3885..efcc1e1 100644
--- a/src/rsvg-port.h
+++ b/src/rsvg-port.h
@@ -19,6 +19,11 @@
 #ifndef RSVG_PORT_H
 #define RSVG_PORT_H
 
+#include <ft2build.h>
+#include FT_OTSVG_H
+
+#ifdef HAVE_LIBRSVG
+
 #include <cairo.h>
 #include <librsvg/rsvg.h>
 #include <ft2build.h>
@@ -57,6 +62,11 @@
                          FT_Bool       cache,
                          FT_Pointer   *state );
 
+#endif /* HAVE_LIBRSVG */
+
+
+  extern SVG_RendererHooks  rsvg_hooks;
+
 #endif /* RSVG_PORT_H */
 
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]