[gimp] plug-ins: lookup WMF fonts on same prefix when relocatable bundle.



commit 4ff856f68d167ff83a75bf9fc0208de41625bde9
Author: Jehan <jehan girinstud io>
Date:   Wed Jun 27 04:22:20 2018 +0200

    plug-ins: lookup WMF fonts on same prefix when relocatable bundle.
    
    When ENABLE_RELOCATABLE_RESOURCES is set, override libwmf fontdir. This
    is actually an alternate version of MR !9 by Alex Samorukov assuming a
    bundled GIMP on a single prefix rather than depending on an environment
    variable.
    This especially makes the relocatable feature more discoverable (rather
    than some random environment variable for which you'd need to read the
    code to discover it then make some wrapper script for GIMP).

 plug-ins/common/file-wmf.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/plug-ins/common/file-wmf.c b/plug-ins/common/file-wmf.c
index a5c7091355..9c6793a0f3 100644
--- a/plug-ins/common/file-wmf.c
+++ b/plug-ins/common/file-wmf.c
@@ -310,6 +310,7 @@ load_wmf_size (const gchar *filename,
   guint           width   = -1;
   guint           height  = -1;
   gboolean        success = TRUE;
+  char*           wmffontdirs[2] = { NULL, NULL };
 
   file = g_mapped_file_new (filename, FALSE, NULL);
   if (! file)
@@ -318,7 +319,16 @@ load_wmf_size (const gchar *filename,
   flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
   api_options.function = wmf_gd_function;
 
+#ifdef ENABLE_RELOCATABLE_RESOURCES
+  wmffontdirs[0] = g_build_filename (gimp_installation_directory (),
+                                     "share/libwmf/fonts", NULL);
+  flags |= WMF_OPT_FONTDIRS;
+  api_options.fontdirs = wmffontdirs;
+#endif
+
   err = wmf_api_create (&API, flags, &api_options);
+  if (wmffontdirs[0])
+    g_free (wmffontdirs[0]);
   if (err != wmf_E_None)
     success = FALSE;
 
@@ -771,6 +781,7 @@ wmf_get_pixbuf (const gchar *filename,
   guint           file_height;
   wmfD_Rect       bbox;
   gint           *gd_pixels = NULL;
+  char*           wmffontdirs[2] = { NULL, NULL };
 
   file = g_mapped_file_new (filename, FALSE, NULL);
   if (! file)
@@ -779,7 +790,16 @@ wmf_get_pixbuf (const gchar *filename,
   flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
   api_options.function = wmf_gd_function;
 
+#ifdef ENABLE_RELOCATABLE_RESOURCES
+  wmffontdirs[0] = g_build_filename (gimp_installation_directory (),
+                                     "share/libwmf/fonts", NULL);
+  flags |= WMF_OPT_FONTDIRS;
+  api_options.fontdirs = wmffontdirs;
+#endif
+
   err = wmf_api_create (&API, flags, &api_options);
+  if (wmffontdirs[0])
+    g_free (wmffontdirs[0]);
   if (err != wmf_E_None)
     goto _wmf_error;
 
@@ -878,6 +898,7 @@ wmf_load_file (const gchar  *filename,
   wmfAPI_Options  api_options;
   wmfD_Rect       bbox;
   gint           *gd_pixels = NULL;
+  char*           wmffontdirs[2] = { NULL, NULL };
 
   *width = *height = -1;
 
@@ -888,7 +909,16 @@ wmf_load_file (const gchar  *filename,
   flags = WMF_OPT_IGNORE_NONFATAL | WMF_OPT_FUNCTION;
   api_options.function = wmf_gd_function;
 
+#ifdef ENABLE_RELOCATABLE_RESOURCES
+  wmffontdirs[0] = g_build_filename (gimp_installation_directory (),
+                                     "share/libwmf/fonts/", NULL);
+  flags |= WMF_OPT_FONTDIRS;
+  api_options.fontdirs = wmffontdirs;
+#endif
+
   err = wmf_api_create (&API, flags, &api_options);
+  if (wmffontdirs[0])
+    g_free (wmffontdirs[0]);
   if (err != wmf_E_None)
     goto _wmf_error;
 


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