Bug 127148

Summary: Label prints using too small a font size
Product: [Applications] kst Reporter: Andrew Walker <arwalker>
Component: generalAssignee: kst
Status: RESOLVED FIXED    
Severity: normal    
Priority: NOR    
Version: 1.x   
Target Milestone: ---   
Platform: Compiled Sources   
OS: Linux   
Latest Commit: Version Fixed In:

Description Andrew Walker 2006-05-11 18:03:32 UTC
Version:           HEAD (using KDE KDE 3.5.0)
Installed from:    Compiled From Sources
OS:                Linux

PROBLEM:
When printing a label the font size used is too small

STEPS TO PREDOCUE:
Start Kst
In the default window create a label
Ensure that "Auto Resize for Text" is unchecked
Print the window

RESULTS:
The font size used for printing is much too small

EXPECTED RESULTS:
The text size on the printed page should roughly correspond to the text size on the screen
Comment 1 Andrew Walker 2006-05-17 23:21:21 UTC
The problem here is that the non-"auto resize for text" label has a constant font size. This is marginally acceptable for display on the screen, but clearly collapses when exporting or printing. If we make the font size scale for printing and exporting then things would be greatly improved (though probably still a ways off from WYSIWYG). The (better) alternative would be to have the font size scale for screen display also (as they do in axes labels, legends, etc).
Comment 2 Andrew Walker 2006-05-24 23:45:35 UTC
SVN commit 544461 by arwalker:

BUG:127148 Scale the font size correctly when printing or exporting labels.

 M  +8 -2      kstviewlabel.cpp  


--- trunk/extragear/graphics/kst/src/libkstapp/kstviewlabel.cpp #544460:544461
@@ -69,7 +69,7 @@
   _justify = justify;
   _fontName = KstApp::inst()->defaultFont();
   _fontSize = 0;
-  _absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
+  _absFontSize = _fontSize + KstSettings::globalSettings()->plotFontSize;
   _standardActions |= Delete | Edit;
   _parsed = 0L;
   _labelMargin = 0;
@@ -95,7 +95,7 @@
   _justify = 0L;
   _fontName = KstApp::inst()->defaultFont();
   _fontSize = 0;
-  _absFontSize = _fontSize+KstSettings::globalSettings()->plotFontSize;
+  _absFontSize = _fontSize + KstSettings::globalSettings()->plotFontSize;
   _standardActions |= Delete | Edit;
   _parsed = 0L;
   reparse();
@@ -409,9 +409,13 @@
 void KstViewLabel::paintSelf(KstPainter& p, const QRegion& bounds) {
   p.save();
   if (p.type() == KstPainter::P_PRINT || p.type() == KstPainter::P_EXPORT) {
+    int absFontSizeOld = _absFontSize;
+    
     if (_autoResize) {
       adjustSizeForText(_parent->geometry());
     } else {
+      _absFontSize = int( double(absFontSizeOld) * ( double(_geom.width() + _geom.height()) / 
+                                                     double(_geomOld.width() + _geomOld.height()) ) );
       computeTextSize(_parsed);
     }
     KstBorderedViewObject::paintSelf(p, bounds);
@@ -424,6 +428,8 @@
     }
 
     drawToPainter(_parsed, p);
+    
+    _absFontSize = absFontSizeOld;
   } else {
     if (p.makingMask()) {
       p.setRasterOp(Qt::SetROP);