[GRASS-SVN] r48194 - grass/trunk/gui/wxpython/gui_modules

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Sep 7 21:49:36 EDT 2011


Author: cmbarton
Date: 2011-09-07 18:49:36 -0700 (Wed, 07 Sep 2011)
New Revision: 48194

Modified:
   grass/trunk/gui/wxpython/gui_modules/psmap.py
Log:
Improved error trapping for wx.Font creation

Modified: grass/trunk/gui/wxpython/gui_modules/psmap.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/psmap.py	2011-09-08 00:21:45 UTC (rev 48193)
+++ grass/trunk/gui/wxpython/gui_modules/psmap.py	2011-09-08 01:49:36 UTC (rev 48194)
@@ -711,23 +711,25 @@
             weight = wx.FONTWEIGHT_NORMAL
         
         try:
-            fn = wx.Font(pointSize=fontsize, family=family, style=style, weight=weight, face=face)
-            return fn
+            fn = wx.Font(pointSize=fontsize, family=wx.FONTFAMILY_DEFAULT, 
+                         style=wx.FONTSTYLE_NORMAL, weight=wx.FONTWEIGHT_NORMAL)
         except:
-            return False
+            fn = wx.Font(pointSize=10, family=family, style=style, weight=weight, face=face)
+
+        return fn
        
+       
     def getTextExtent(self, textDict):
         #fontsize = str(fontsize if fontsize >= 4 else 4)
         dc = wx.PaintDC(self) # dc created because of method GetTextExtent, which pseudoDC lacks
        
         fn = self.makePSFont(textDict)
 
-        if fn:
+        try:
             dc.SetFont(fn)
             w,h,lh = dc.GetMultiLineTextExtent(textDict['text'])
             return (w,h)
-#            return dc.GetTextExtent(textDict['text'])
-        else:
+        except:
             return (0,0)
     
     def getInitMap(self):



More information about the grass-commit mailing list