Results 1 to 6 of 6

Thread: QPrinter & QPainter Font Differences Between LInux and WIndows

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #2
    Join Date
    Jan 2006
    Posts
    132
    Qt products
    Qt4
    Platforms
    Windows
    Thanked 16 Times in 16 Posts

    Default Re: QPrinter & QPainter Font Differences Between LInux and WIndows

    I ran into similar issue lately. It turned out that QTextDocument will allways assume (logical) screen resolution when painting, and that is probably different between windows and linux. On windows (where I'm working) the logical screen resolution is 96 DPI.

    In my case everything was fine when printing in default QPrinter::ScreenResolution mode, but everything was far too small when printing with QPrinter::HighResolution.

    My workaround was to scale the QPainter so QTextDocument could paint believing that the resolution is = screen resolution, and QPainter would "fix" it by its transformation.

    Here a snippet of code:

    Qt Code:
    1. int screenResolution = Bps::screenResolution();
    2. qreal oldWidth = prv_->mDocument.textWidth();
    3. if (prv_->mResolution>0 && prv_->mResolution != screenResolution) {
    4. qreal f = prv_->mResolution / screenResolution;
    5. aPainter->scale(f, f);
    6. prv_->mDocument.setTextWidth(oldWidth / f);
    7. } // if
    8. prv_->mDocument.drawContents(aPainter);
    9. prv_->mDocument.setTextWidth(oldWidth);
    To copy to clipboard, switch view to plain text mode 
    Last edited by seneca; 14th January 2009 at 14:05.

Similar Threads

  1. Replies: 1
    Last Post: 25th December 2007, 10:35
  2. QPainter & QPrinter on linux (fedora 7)
    By wbt_ph in forum Qt Programming
    Replies: 4
    Last Post: 20th October 2007, 15:37
  3. Font Problem Porting from Windows to Linux
    By rajeshs in forum Qt Programming
    Replies: 1
    Last Post: 13th July 2007, 10:25

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.