QPicture to QPixmap creates text problems



  • Hy!

    I wrote a program (withh Qt 4.8.0) which creates and shows documents via QPicture, QPixmap and QGraphicScene.

    That means: I created a page of the document as a QPicture and draw text und images. The I use a QPixmap and paint the QPicture in the pixmap to show it in the QGraphicsScene. I want to give the user the possibility to zoom in and zoom out. I do this with QPixmap setViewport.

    @
    double scale = arg1/100.0;

    scene.clear();
    scene.setSceneRect(0.0,0.0,596.0*scale,842.0*scale); //596 and 842 are the width and the size of my QPicture
    
    QPixmap pix((int)ceil(596.0*scale),(int)ceil(842.0*scale));
    pix.fill();
    QPainter paint;
    
    paint.begin(&pix);
    paint.setViewport(0,0,(int)ceil(596.0*scale*scale),(int)ceil(842.0*scale*scale));
    paint.drawPicture(0,0,pimgList->at(currentpage)); //a QList of QPicture, the pages
    paint.end();
    
    scene.addPixmap(pix);@
    

    This works fine if scale is 1,0. With other values of scale the text is being shifted a little bit. It seems that sometimes the character not correctly placed (a little bit to much to the left, or to the right). The word "Polyvinylclorid" is transformed to "Poly v iny lclorid".

    Can anybody help?

    Thanks a lot,
    Robert Adler



    • Is your text antialiased?
    • Does it happen with all fonts on your system?
    • Which graphicssystem is this?
    • Have you tried adding the text to a QPainterPath with scale 1.0 first and then drawing the path on the picture?


  • I tried with text aliased and antialiased: no difference.

    QPainterPath: no difference.

    Wich graphicssystem? Don't know. I work with Windows and "normal" settings.

    Different font works: I use "Segoe UI" now (DejaVu Sans works too). I get the same problem with "Helvetica", "Times", "MS Shell Dlg 2".

    I want to use Helvetica, but it doesn't work.



  • Looks like the font hinting of those fonts is broken and/or only available for certain discrete font sizes. I'm afraid there isn't much you can do about it except try to get working, non-MS versions of those fonts, if they exist.



  • Thanks a lot. For now I will use "Segoe UI". I have more time, I will look for another possibility.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.