Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QPicture to QPixmap creates text problems

QPicture to QPixmap creates text problems

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 3.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    adler.robert
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DerManu
      wrote on last edited by
      #2
      • 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?
      1 Reply Last reply
      0
      • A Offline
        A Offline
        adler.robert
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          DerManu
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adler.robert
            wrote on last edited by
            #5

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

            1 Reply Last reply
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved