[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    [PATCH] pointSize==-1 (KoGlobal)
From:       Nicolas Goutte <nicog () snafu ! de>
Date:       2001-12-19 22:50:23
[Download RAW message or body]

The attached patch is for the file lib/kofficeui/koGlobal.cc.

The patch calculate correctly the point size, even if the default font was 
set as pixel size. (QFontInfo does not do any converting.)

Doing it here in koGlobal.cc has the advantage to be centralized. This solves 
also the problem that I had described with the constructor of KWDocument on 
the 2001-12-08.

Have a nice day/evening/night!
["patch_koGlobal_cc.txt" (text/x-diff)]

--- koGlobal.cc.orig	Sat Dec 15 22:26:21 2001
+++ koGlobal.cc	Wed Dec 19 22:59:21 2001
@@ -22,7 +22,6 @@
 #include <klocale.h>
 #include <kprinter.h>
 #include <qfont.h>
-#include <qfontinfo.h>
 #include <kglobalsettings.h>
 
 int KoPageFormat::printerPageSize( KoFormat format )
@@ -385,9 +384,21 @@
 {
     QFont font;
     font = KGlobalSettings::generalFont();
-    // we have to use QFontInfo, in case the font was specified with a pixel size
-    //kdDebug()<<"QFontInfo(font).pointSize() :"<<QFontInfo(font).pointSize()<<endl;
     //kdDebug()<<"font.name() :"<<font.family ()<<endl;
-    font.setPointSize( QFontInfo(font).pointSize() );
+    const int size=font.pointSize();
+    // The font might be have defined by setPixelSize  (size==-1)
+    // We must calculate the result "by hand", as even QFontInfo does not do it for us.
+    if (size==-1)
+    {
+        float point=size;
+        // We calculate without using explicit type castings
+        point *= 72.0;
+        point /= QPaintDevice::x11AppDpiY();
+        font.setPointSizeFloat( point ); // The correct rounding is done by QT
+    }
+    else
+    {
+        font.setPointSize( size );
+    }
     return font;
 }

_______________________________________________
koffice-devel mailing list
koffice-devel@mail.kde.org
http://mail.kde.org/mailman/listinfo/koffice-devel

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic