[meld] Use native fonts on win32 instead of FontConfig (bgo#785313)



commit 698dd8f1e86553cd8377d1a92e348604b14f7740
Author: Vasily Galkin <galkin-vv ya ru>
Date:   Thu Oct 12 16:24:14 2017 +0300

    Use native fonts on win32 instead of FontConfig (bgo#785313)
    
    The version 1.34 selected as pangocairo_requirement is the first version
    with PangoCairo.FontMap.set_default behaviour identical to the version
    Pango 1.40 which was used for testing.
    It maybe works with previous versions too, but they are ancient.
    
    Code assumes that version requirement is satisfied if import of both
    Gtk and PangoCairo succeeds since Gtk 3.14 depends on Pango 1.36

 bin/meld |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 5c7c932..c8242e7 100755
--- a/bin/meld
+++ b/bin/meld
@@ -173,6 +173,7 @@ def check_requirements():
     gtk_requirement = (3, 14)
     glib_requirement = (2, 36, 0)
     gtksourceview_requirement = (3, 14, 0)
+    pangocairo_requirement = (1, 34)
 
     def missing_reqs(mod, ver, exception=None):
         if isinstance(exception, ImportError):
@@ -209,6 +210,13 @@ def check_requirements():
     except (ImportError, AssertionError) as e:
         missing_reqs("GtkSourceView", gtksourceview_requirement, e)
 
+    try:
+        gi.require_version("PangoCairo", "1.0")
+        from gi.repository import PangoCairo
+        # Only check that imports ok; the version is fine since Gtk loaded fine
+    except (ImportError, ValueError) as e:
+        missing_reqs("PangoCairo", pangocairo_requirement, e)
+
 
 def setup_resources():
     from gi.repository import GLib
@@ -347,5 +355,10 @@ if __name__ == '__main__':
         from gi.repository import GLib
         GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT,
                              lambda *args: meld.meldapp.app.quit(), None)
+    if sys.platform == 'win32':
+        # FontConfig on win32 at least with version <= 2.12.6 can cause several
+        # minutes 'hang' during first startup. So use native fonts backend.
+        from gi.repository import PangoCairo
+        PangoCairo.FontMap.set_default(PangoCairo.Win32FontMap()) 
     status = meld.meldapp.app.run(sys.argv)
     sys.exit(status)


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