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

List:       koffice
Subject:    Re: Kprinter and KFormula troubles...
From:       Ulrich Kuettler <ulrich.kuettler () mailbox ! tu-dresden ! de>
Date:       2003-05-31 11:22:40
[Download RAW message or body]

On Saturday 31 May 2003 05:40, Rodolfo Conde Martínez wrote:
>
> 	I think you must be tired of hearing about me and issues with kformula :),
> here i go again:

Hi Rodolfo:

you're welcome. Your reports are always highly appreciated and an important 
force in kformula's development. :)

>
> 	First of all the latest kformula CVS is really great, the upper and lower
> indices stuff with the integral looks much better, but theres still trouble
> with the incremented parenthesis symbols (be it bracklets, parenthesis,
> abs, etc. ) but not when showing in kformula, but when printting, at least
> to PS and PDF, and i dont know if its kformula specific or kdeprint system,
> im sending a kformula file and a PDF file so you can check how the
> parenthesis get wrong in the PDF and theyre ok in kformula....

This is a bug I really don't know how to deal with. Here it doesn't look that 
bad but it isn't right either. The odd thing, however, is that the reported 
font metrics don't match the actual drawn glyph. I've attached a file showing 
what kformula prints including green rectangles that show the size these 
glyphs claim to have. All kformula knows are these rectangles. Everything 
else is up to the deep mysteries of QPainter's drawText method.

Can you please apply the attached patch to cmstyle.cc so that you'll have 
those green rectangles, too? I'm very interested to know whether you suffer 
the same metric mismatch bug or if there's still another problem.

But now I need to ask for advice: Why do the font metric and the drawn glyph 
disagree? Is this due to the font? Is it something in qt? And what does 
kprinter have to do with it?

Uli


["kformula_brackets2.pdf" (application/pdf)]
["cmstyle.cc.patch" (text/x-diff)]

Index: cmstyle.cc
===================================================================
RCS file: /home/kde/koffice/lib/kformula/cmstyle.cc,v
retrieving revision 1.2
diff -u -3 -p -r1.2 cmstyle.cc
--- cmstyle.cc	29 May 2003 15:04:15 -0000	1.2
+++ cmstyle.cc	31 May 2003 11:21:54 -0000
@@ -228,7 +228,6 @@ void CMArtwork::calcSizes( const Context
     setBaseline( -1 );
     cmChar = -1;
     luPt mySize = style.getAdjustedSize( tstyle );
-    //const SymbolTable& symbolTable = style.symbolTable();
     switch (getType()) {
     case LeftSquareBracket:
         if ( calcCMDelimiterSize( style, cmex_LeftSquareBracket,
@@ -314,15 +313,12 @@ void CMArtwork::calcSizes( const Context
         calcCurlyBracket( style, rightCurlyBracket, parentSize, mySize );
         break;
     case Integral:
-        //calcCharSize( style, qRound( 1.5*mySize ), integralChar );
         calcCharSize( style, QFont( "cmex10" ), mySize, cmex_Int );
         break;
     case Sum:
-        //calcCharSize( style, qRound( 1.5*mySize ), summationChar );
         calcCharSize( style, QFont( "cmex10" ), mySize, cmex_Sum );
         break;
     case Product:
-        //calcCharSize( style, qRound( 1.5*mySize ), productChar );
         calcCharSize( style, QFont( "cmex10" ), mySize, cmex_Prod );
         break;
     }
@@ -381,7 +377,6 @@ void CMArtwork::draw(QPainter& painter, 
         return;
 
     painter.setPen(style.getDefaultColor());
-    //const SymbolTable& symbolTable = style.symbolTable();
 
     switch (getType()) {
     case LeftSquareBracket:
@@ -469,23 +464,23 @@ void CMArtwork::draw(QPainter& painter, 
     case EmptyBracket:
         break;
     case Integral:
-        //drawCharacter(painter, style, myX, myY, qRound( 1.5*mySize ), integralChar);
         drawCharacter(painter, style, QFont( "cmex10" ), myX, myY, mySize, cmex_Int);
         break;
     case Sum:
-        //drawCharacter(painter, style, myX, myY, qRound( 1.5*mySize ), summationChar);
         drawCharacter(painter, style, QFont( "cmex10" ), myX, myY, mySize, cmex_Sum);
         break;
     case Product:
-        //drawCharacter(painter, style, myX, myY, qRound( 1.5*mySize ), productChar);
         drawCharacter(painter, style, QFont( "cmex10" ), myX, myY, mySize, cmex_Prod);
         break;
     }
 
     // debug
-    //painter.setBrush(Qt::NoBrush);
-    //painter.setPen(Qt::green);
-    //painter.drawRect(myX, myY, getWidth(), getHeight());
+//     painter.setBrush(Qt::NoBrush);
+//     painter.setPen(Qt::green);
+//     painter.drawRect( style.layoutUnitToPixelX( myX ),
+//                       style.layoutUnitToPixelY( myY ),
+//                       style.layoutUnitToPixelX( getWidth() ),
+//                       style.layoutUnitToPixelY( getHeight() ) );
 }
 
 
@@ -508,7 +503,6 @@ bool CMArtwork::calcCMDelimiterSize( con
                                      luPt parentSize )
 {
     QFont f( "cmex10" );
-    //f.setPointSizeFloat( context.layoutUnitToFontSize( i*fontSize, false ) );
     f.setPointSizeFloat( context.layoutUnitPtToPt( fontSize ) );
     QFontMetrics fm( f );
 
@@ -540,7 +534,6 @@ void CMArtwork::calcLargest( const Conte
                              uchar c, luPt fontSize )
 {
     QFont f( "cmex10" );
-    //f.setPointSizeFloat( context.layoutUnitToFontSize( i*fontSize, false ) );
     f.setPointSizeFloat( context.layoutUnitPtToPt( fontSize ) );
     QFontMetrics fm( f );
 
@@ -576,6 +569,16 @@ void CMArtwork::drawCMDelimiter( QPainte
     painter.drawText( style.layoutUnitToPixelX( x ),
                       style.layoutUnitToPixelY( y + getBaseline() ),
                       QString( QChar( cmChar ) ) );
+
+    // Debug
+    QFontMetrics fm( f );
+    LuPixelRect bound = fm.boundingRect( cmChar );
+    painter.setBrush(Qt::NoBrush);
+    painter.setPen(Qt::green);
+    painter.drawRect( style.layoutUnitToPixelX( x ),
+                      style.layoutUnitToPixelY( y ),
+                      fm.width( cmChar ),
+                      bound.height() );
 }
 
 


____________________________________
koffice mailing list
koffice@mail.kde.org
To unsubscribe please visit:
http://mail.kde.org/mailman/listinfo/koffice


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

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