Alan W. Irwin wrote:
> On 2009-04-06 00:53-0700 Alan W. Irwin wrote:
>   
> To everyone here who would like to help out with testing:
>
> To help understand what I suspect is a qt device driver character alignment
> issue, I would appreciate some specific testing of example 3 using -dev
> pngqt to see if there is any platform/set of fonts where you get good
> character alignment unlike the pngqt result for example 3 that I attached
> earlier in this thread.
>
> Alan
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> High Quality Requirements in a Collaborative Environment.
> Download a free trial of Rational Requirements Composer Now!
> http://p.sf.net/sfu/www-ibm-com
> _______________________________________________
> Plplot-devel mailing list
> Plplot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/plplot-devel
>   

Alan,

Looking in plcore, I realized that plplot switched to the "Symbol" font
before plotting a symbol, which is not supported in our driver (not
declared as a StyleHint in Qt), and was just ignored, dropping through
the "switch" statements to the default, which was helvetica. I've
changed this part, so that requesting a "symbol" font just keeps the
settings of the previous font. And everything gets aligned properly now
in example 3.

A patch is attached.

Alban
Index: drivers/qt.h
===================================================================
--- drivers/qt.h        (revision 9796)
+++ drivers/qt.h        (working copy)
@@ -175,7 +175,7 @@
        protected:
        
                // Returns font with the good size for a QPicture's resolution
-               QFont getFont(PLUNICODE code);
+               QFont getFont(PLUNICODE code, const QFont& oldFont=QFont());
                // Draws text in a QPicture using a sub-QPicture (!), updates 
the current xOffset
                void drawTextInPicture(QPainter*, const QString&);
                // Gets the QPicture displaying text, with the base chrht char 
height
Index: drivers/qt.cpp
===================================================================
--- drivers/qt.cpp      (revision 9796)
+++ drivers/qt.cpp      (working copy)
@@ -252,7 +252,7 @@
 }
 
 
-QFont QtPLDriver::getFont(PLUNICODE unicode)
+QFont QtPLDriver::getFont(PLUNICODE unicode, const QFont& oldFont)
 {
        // Get new font parameters
        unsigned char fontFamily, fontStyle, fontWeight;
@@ -266,9 +266,10 @@
        f.setPointSizeF(currentFontSize*currentFontScale<4 ? 4 : 
currentFontSize*currentFontScale);
 
        switch(fontFamily) {
-         case 1:       f.setFamily("Times"); f.setStyleHint(QFont::Serif); 
break;
+         case 1: f.setFamily("Times"); f.setStyleHint(QFont::Serif); break;
          case 2: f.setFamily("Courier"); f.setStyleHint(QFont::TypeWriter); 
break;
-         case 0: case3: case4: default: f.setFamily("Helvetica"); 
f.setStyleHint(QFont::SansSerif); break;
+         case 0: case3: f.setFamily("Helvetica"); 
f.setStyleHint(QFont::SansSerif); break;
+         case 4: default: f.setFamily(oldFont.family()); 
f.setStyleHint(oldFont.styleHint()); break; // Do nothing
        }
        if(fontStyle) f.setItalic(true);
        if(fontWeight) f.setWeight(QFont::Bold);
@@ -396,7 +397,7 @@
 
                        currentString.clear();
                        fci=text[i];
-                       p.setFont(getFont(fci));
+                       p.setFont(getFont(fci, p.font()));
                }
                ++i;
        }
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Plplot-devel mailing list
Plplot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/plplot-devel

Reply via email to