dabo Commit
Revision 4385
Date: 2008-08-09 10:01:11 -0700 (Sat, 09 Aug 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4385

Changed:
U   trunk/dabo/ui/uiwx/dFont.py

Log:
Finally fixed the bug in the Mac font scaling logic. The problem is that when 
*any* font property changed, the font would be re-set, and the scaling factory 
re-applied, making the font size shrink. Now it keeps track of when it applies 
the scaling, and only re-applies it if a different FontSize value is passed.


Diff:
Modified: trunk/dabo/ui/uiwx/dFont.py
===================================================================
--- trunk/dabo/ui/uiwx/dFont.py 2008-08-08 20:06:01 UTC (rev 4384)
+++ trunk/dabo/ui/uiwx/dFont.py 2008-08-09 17:01:11 UTC (rev 4385)
@@ -16,6 +16,7 @@
                        self._nativeFont = 
wx.Font(dabo.settings.defaultFontSize, 
                                        wx.FONTFAMILY_DEFAULT, 
wx.FONTSTYLE_NORMAL, 
                                        wx.FONTWEIGHT_NORMAL)
+               self._macNonScaledSize = 0
        
                super(dFont, self).__init__(properties=properties, *args, 
**kwargs)
 
@@ -103,14 +104,18 @@
 
 
        def _getSize(self):
+               ret = None
                if self._useMacFontScaling():
-                       multiplier = .75
-               else:
-                       multiplier = 1          
-               if self._nativeFont:
-                       return multiplier * self._nativeFont.GetPointSize()
-               # No native font yet; return a reasonable default.
-               return 9
+                       ret = self._macNonScaledSize
+               if not ret:
+                       # Could be zero if it is the first time referenced when 
using Mac font scaling
+                       if self._nativeFont:
+                               return self._nativeFont.GetPointSize()
+                       else:
+                               # No native font yet; return a reasonable 
default.
+                               return 9
+               else:   
+                       return ret
 
        def _setSize(self, val):
                try:
@@ -120,8 +125,10 @@
                        # let the ValueError be raised.
                        val = float(val)
                if self._useMacFontScaling():
-                       self._macNonScaledSize = val
-                       val = val / .75
+                       # Make sure that the difference is less than float 
rounding errors.
+                       if abs(float(val) - float(self._macNonScaledSize)) < 
0.1:
+                               self._macNonScaledSize = val
+                               val = round(val/.75, 0)
                try:
                        self._nativeFont.SetPointSize(val)
                except ValueError:




_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/%(messageid)s

Reply via email to