Blob Blame History Raw
diff -rupN pango-1.44.5/meson_options.txt pango-1.44.5-new/meson_options.txt
--- pango-1.44.5/meson_options.txt	2019-08-29 23:13:22.564353109 +0200
+++ pango-1.44.5-new/meson_options.txt	2019-08-29 23:12:38.284347109 +0200
@@ -14,3 +14,7 @@ option('use_fontconfig',
        description : 'Force using FontConfig where it is optional, on Windows and macOS.  This is ignored on platforms where it is required',
        type: 'boolean',
        value: 'false')
+option('delayload',
+       description: 'Makes the pangoft2 backend and the fontconfig/freetype dependencies optional at runtime (win32 only)',
+       type: 'boolean',
+       value: false)
diff -rupN pango-1.44.5/pango/meson.build pango-1.44.5-new/pango/meson.build
--- pango-1.44.5/pango/meson.build	2019-08-14 19:20:51.000000000 +0200
+++ pango-1.44.5-new/pango/meson.build	2019-08-29 23:10:24.870297387 +0200
@@ -226,6 +226,62 @@ if build_pangoft2
     link_args: common_ldflags,
   )
 
+  if get_option('delayload')
+    gendef = find_program('gendef', required: true)
+    dlltool = find_program('dlltool', required: true)
+
+    libpangoft2def = custom_target(
+      'pangoft2.def',
+      input: libpangoft2,
+      output: 'pangoft2.def',
+      command: [gendef, '-', '@INPUT@', '>', '@OUTPUT@']
+    )
+    libpangoft2dl = custom_target(
+      'pangoft2-delay-loaded-@0@'.format(pango_api_version),
+      input: libpangoft2def,
+      output: 'libpangoft2-delay-loaded-@0@.dll.a'.format(pango_api_version),
+      command: [dlltool, '--def', '@INPUT@', '--kill-at', '--output-delaylib', '@OUTPUT@']
+    )
+
+    libfontconfigdef = custom_target(
+      'fontconfig_delay_load.def',
+      input: join_paths(get_option('prefix'), get_option('bindir'), 'libfontconfig-1.dll'),
+      output: 'fontconfig_delay_load.def',
+      command: [gendef, '-', '@INPUT@', '>', '@OUTPUT@']
+    )
+    libfontconfigdl = custom_target(
+      'libfontconfig-delay-loaded.dll.a',
+      input: libfontconfigdef,
+      output: 'libfontconfig-delay-loaded.dll.a',
+      command: [dlltool, '--def', '@INPUT@', '--kill-at', '--output-delaylib', '@OUTPUT@']
+    )
+
+    libfreetypedef = custom_target(
+      'freetype_delay_load.def',
+      input: join_paths(get_option('prefix'), get_option('bindir'), 'libfreetype-6.dll'),
+      output: 'freetype_delay_load.def',
+      command: [gendef, '-', '@INPUT@', '>', '@OUTPUT@']
+    )
+    libfreetypedl = custom_target(
+      'libfreetype-delay-loaded.dll.a',
+      input: libfreetypedef,
+      output: 'libfreetype-delay-loaded.dll.a',
+      command: [dlltool, '--def', '@INPUT@', '--kill-at', '--output-delaylib', '@OUTPUT@']
+    )
+
+    libpangoft2dl_dep = declare_dependency(
+      link_with: libpangoft2dl
+    )
+    libfontconfigdl_dep = declare_dependency(
+      link_with: libfontconfigdl
+    )
+    libfreetypedl_dep = declare_dependency(
+      link_with: libfreetypedl
+    )
+
+  endif
+
+
   pangoft2_dep_sources = []
 
   if build_gir
@@ -458,7 +514,14 @@ if cairo_dep.found()
       'pangocairo-fcfontmap.c',
     ]
 
-    pangocairo_deps += libpangoft2_dep
+    # TODO does not work?
+    #if get_option('delayload')
+     # pangocairo_deps += libpangoft2dl_dep
+      # pangocairo_deps += libfontconfigdl_dep
+      # pangocairo_deps += libfreetypedl_dep
+    #else
+      pangocairo_deps += libpangoft2_dep
+    #endif
   endif
 
   if host_system == 'windows' and pango_font_backends.contains('win32')