[Skencil-commits] r791 - skencil/branches/skencil-0.6/src/Sketch/Base

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Nov 22 14:54:26 CET 2010


Author: igor_n
Date: 2010-11-22 14:54:26 +0100 (Mon, 22 Nov 2010)
New Revision: 791

Modified:
   skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py
Log:
improvement for cases when gtk values import is failed 

Modified: skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py
===================================================================
--- skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py	2010-11-22 13:48:11 UTC (rev 790)
+++ skencil/branches/skencil-0.6/src/Sketch/Base/gtkutils.py	2010-11-22 13:54:26 UTC (rev 791)
@@ -38,23 +38,26 @@
     font_size - font size integer value
     """
     
-    tmpfile = NamedTemporaryFile()
-    command = "import gtk;w = gtk.Window();w.realize();style=w.get_style(); print style.font_desc.to_string();"
-    os.system('python -c "%s" >%s 2>/dev/null' % (command, tmpfile.name))
-    
-    font = tmpfile.readline().strip()
-    
-    normal_font = process_gtk_font_string(font)
-    small_font = copy.deepcopy(normal_font)
-    small_font[2] -= 1
-    
-    large_font = copy.deepcopy(normal_font)
-    large_font[2] += 2
-    if not 'bold' in large_font[1]:
-        large_font[1].append('bold')
+    try:
+        tmpfile = NamedTemporaryFile()
+        command = "import gtk;w = gtk.Window();w.realize();style=w.get_style(); print style.font_desc.to_string();"
+        os.system('python -c "%s" >%s 2>/dev/null' % (command, tmpfile.name))
         
-    fixed_font = copy.deepcopy(normal_font)
-    fixed_font[0] = 'monospace'
+        font = tmpfile.readline().strip()
+        
+        normal_font = process_gtk_font_string(font)
+        small_font = copy.deepcopy(normal_font)
+        small_font[2] -= 1
+        
+        large_font = copy.deepcopy(normal_font)
+        large_font[2] += 2
+        if not 'bold' in large_font[1]:
+            large_font[1].append('bold')
+            
+        fixed_font = copy.deepcopy(normal_font)
+        fixed_font[0] = 'monospace'
+    except:
+        small_font=normal_font=large_font=fixed_font=['helvetica','','9']
     
     return [small_font, normal_font, large_font, fixed_font]
     



More information about the Skencil-commits mailing list