Check for freetype2 version when PangoFT is used
authorРуслан Ижбулатов <lrn1986@gmail.com>
Thu, 11 Jan 2018 17:49:43 +0000 (17:49 +0000)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 28 Mar 2018 08:14:37 +0000 (16:14 +0800)
Check for freetype2 version, because pangoft works with any version
(pangoft availability does not indicate that ft2 is new enough), unlike
GTK.

On Windows, since pangoft is optional, we check for the presence of
freetype2 .pc file first after finding that we have pangoft, and then
check for FT_Get_Var_Design_Coordinates() manually by looking for the
freetype headers and .lib first, and then looking for the presence of
that symbol, since freetype2's Visual Studio build system does not
generate a .pc file for us.

https://bugzilla.gnome.org/show_bug.cgi?id=773299

gtk/meson.build
meson.build

index fa1f7b29086426a106455b70cec6714fd7df0a8f..45309bc1803bdf452eb6784a0579ea7f79f8bbcf 100644 (file)
@@ -873,7 +873,7 @@ gtk_deps = [
 ]
 
 if harfbuzz_dep.found() and pangoft_dep.found()
-  gtk_deps += [ harfbuzz_dep, ]
+  gtk_deps += [ harfbuzz_dep, pangoft_dep ]
 endif
 
 if x11_enabled
index 5831dfcbfef8b98d7e188b58630a51cc0c330a07..62df80db98e63a1f6f8bcc1670b61674d183b24b 100644 (file)
@@ -313,12 +313,42 @@ cairogobj_dep  = dependency('cairo-gobject', version: cairo_req, required : cc.g
 pango_dep      = dependency('pango', version: pango_req,
                             fallback : ['pango', 'libpango_dep'])
 
-if wayland_enabled or x11_enabled
+# Require PangoFT2 if on X11 or wayland
+require_pangoft2 = wayland_enabled or x11_enabled
+
+if require_pangoft2
   pangoft_dep  = dependency('pangoft2', fallback : ['pango', 'libpangoft2_dep'])
 else
   pangoft_dep  = dependency('pangoft2', required: false)
 endif
 
+if pangoft_dep.found()
+  # Need at least 2.7.1 for FT_Get_Var_Design_Coordinates()
+  # We get the dependency itself from pango, but pango doesn't care
+  # about ft2 version, so an extra check is needed.
+  ft2_dep      = dependency('freetype2', version: '>= 2.7.1', required: require_pangoft2)
+
+  # Fallback case: Look for the FreeType2 headers and library manually when its .pc
+  # file is not available, such as on Visual Studio
+  if not ft2_dep.found()
+    ft2lib = ft2_dep
+    if cc.has_header('ft2build.h')
+      ft2_libnames = ['freetype', 'freetypemt']
+      foreach lib: ft2_libnames
+        if not ft2_dep.found()
+          ft2lib = cc.find_library(lib)
+          # If the FreeType2 library is found, check for FT_Get_Var_Design_Coordinates()
+          if ft2lib.found()
+            if cc.has_function('FT_Get_Var_Design_Coordinates', dependencies: ft2lib)
+              ft2_dep = ft2lib
+            endif
+          endif
+        endif
+      endforeach
+    endif
+  endif
+endif
+
 pangocairo_dep = dependency('pangocairo', version: cairo_req,
                             fallback : ['pango', 'libpangocairo_dep'])
 pixbuf_dep     = dependency('gdk-pixbuf-2.0', version: gdk_pixbuf_req,