[Kst] extragear/graphics/kst/kst

George Staikos staikos at kde.org
Thu Oct 6 18:16:58 CEST 2005


SVN commit 467864 by staikos:

avoid QFont construction and metrics calls if we don't need them


 M  +6 -3      labelrenderer.cpp  
 M  +6 -0      labelrenderer.h  


--- trunk/extragear/graphics/kst/kst/labelrenderer.cpp #467863:467864
@@ -42,10 +42,13 @@
         rc.size /= 2;
       }
     }
-    QFont f = rc.font();
-    f.setPointSize(rc.size);
-    rc.setFont(f);
 
+    if (rc.fontSize() != rc.size) {
+      QFont f = rc.font();
+      f.setPointSize(rc.size);
+      rc.setFont(f);
+    }
+
     if (fi->group) { // groups have no contents
       fi = fi->next;
       continue;
--- trunk/extragear/graphics/kst/kst/labelrenderer.h #467863:467864
@@ -41,6 +41,7 @@
   }
 
   inline void setFont(const QFont& f) {
+    _fontSize = f.pointSize();
     if (p) {
       p->setFont(f);
       _ascent = p->fontMetrics().ascent();
@@ -55,6 +56,10 @@
     }
   }
 
+  inline int fontSize() const {
+    return _fontSize;
+  }
+
   inline int fontAscent() const {
     return _ascent;
   }
@@ -89,6 +94,7 @@
     QFontMetrics _fm;
     int _ascent, _descent, _height; // caches to avoid performance problem
                                     // with QFont*
+    int _fontSize;
 };
 
 


More information about the Kst mailing list