Results 1 to 15 of 15

Thread: Font cutted in pdf print

  1. #1
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Font cutted in pdf print

    To export in pdf I use the following code
    Qt Code:
    1. void MyPlot::exportPDF()
    2. {
    3. QString fileName;
    4. fileName = QFileDialog::getSaveFileName(this, tr("blabla"), recentExportPath,"Acrobat ( *pdf)");
    5. QFileInfo fileInfo(fileName);
    6. recentExportPath = fileInfo.absoluteDir().absolutePath();
    7. if ( !fileName.isEmpty() ) {
    8. fileName = MyMath::checkFormat(fileName,"pdf");
    9. QPrinter printer(QPrinter::HighResolution);
    10. printer.setOutputFormat(QPrinter::PdfFormat);
    11. printer.setOutputFileName(fileName);
    12. printer.setCreator("Test");
    13. printer.setOrientation(QPrinter::Landscape);
    14. print(printer);
    15. QDesktopServices::openUrl(fileName);
    16.  
    17. }
    18. }
    To copy to clipboard, switch view to plain text mode 
    but the pdf has the font on the axes cutted, as shown in the figure.test.png
    The same result if I print on Adobe PDF printer.
    Any suggestion?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    What is "MyPlot"? How do you paint the labels on the scale?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    Qt Code:
    1. MyPlot::MyPlot( QWidget* par ) : QwtPlot(par )
    2. setAxisScale(QwtPlot::xBottom,-180*1.2,180*1.2);
    To copy to clipboard, switch view to plain text mode 
    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    What if you don't put the printer into high resolution mode?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    Yes, it works,but why?
    I would have not never thouht to such a thing.
    Regards

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    Quote Originally Posted by giusepped View Post
    Yes, it works,but why?
    Probably some sizes are calculated in points and other in pixels so when the resolution changes, one size changes and the other doesn't.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    which calculation are you referring to? in my code or qt code?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    In Qwt code, most likely.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    So, it sounds like to be a bug, isnt'it?
    G

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    Quote Originally Posted by giusepped View Post
    So, it sounds like to be a bug, isnt'it?
    I don't know. I'm against suggestions that if something acts differently than what I want to achieve then it's a bug. I have not seen your code nor analyzed Qwt code so I will not make any judgements. There could be a proper call available in Qwt that would give a correct result instead of an improper call you might have used.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #11
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    Thank you for the replies.
    And let me bother you a little bit more.
    As engineer I always stress myself in finding the meaning of things, especially whenever I do not understand them.
    In this case, I use a very classical coding, as suggested in many examples in the Qwt branch and also here in the forum.
    The plot I see on screen is perfect. So I guess that the calls to Qwt's plot functions are good. The export to pdf function is very simple: just prepare a printer, a painter and call the print function of Qwtplot. That's all.
    Regards

  12. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    Quote Originally Posted by giusepped View Post
    The plot I see on screen is perfect.
    This is the essence here. You would like to see the plot as it is displayed on screen. That's why you should use ScreenResolution instead of HighResolution. If you use HighResolution, you get a situation different than what you see on screen. So based on what you see you can't say whether Qwt code is correct for HighResolution or not.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  13. #13
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,325
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Font cutted in pdf print

    Quote Originally Posted by wysota View Post
    This is the essence here. You would like to see the plot as it is displayed on screen. That's why you should use ScreenResolution instead of HighResolution. If you use HighResolution, you get a situation different than what you see on screen. So based on what you see you can't say whether Qwt code is correct for HighResolution or not.
    Well in case of a plot widget a higher resolution is often important, when you want to identify points, that are close. And Qwt supports printing/exporting in non screen resolution since decades.

    Qwt draws the tick labels using QPainter::drawText(const QRect, ...). From your posted image it looks like the calculated bounding rectangle is not correct and someone ( Qwt isn't doing it ) clips against this rectangle. The calculation of the rectangle is done using the font system of Qt - maybe there is a mismatch with the font system used by the backend of your printer paint engine.

    First thing I woud try is to print to a pdf File instead of printing to the Adobe PDF printer. Then you can be sure that layout and render code use the same font system. If this doesn't help you should try a different font. Qwt 5.2 scales the fonts manually - maybe this results to something invalid and the best match algorithm of Qt ends up with a larger font.

    You could also try to use Qwt 6.x. It has a floating point based render engine, and because of this all manual scaling is replaced by using QPainter scaling.

    Uwe

  14. #14
    Join Date
    May 2008
    Posts
    276
    Thanks
    13
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Font cutted in pdf print

    Thank you for the replies.
    Sincerely, I do not know who and if there is something in my code doing a clipping.
    The only line I can see is the simple QwtPainter::setDeviceClipping(false);
    Beside x and y settings, in my code there is no other line that modifies QwtPlot's properties.
    This morning, I tried also to switch off any font setting. For example, I had Times Roman for xlabel and ylabel. I turn on back HighResolution and the printing to a pdf file gave me the same font effect.
    Where is Qwt 6?
    G

  15. #15
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Font cutted in pdf print

    Quote Originally Posted by Uwe View Post
    Well in case of a plot widget a higher resolution is often important, when you want to identify points, that are close. And Qwt supports printing/exporting in non screen resolution since decades.
    I didn't say you shouldn't use high resolution with plots or that Qwt didn't support it. I only say that if someone states "I want it to look exactly like on the screen" then it means ScreenResolution. And I also said that if you print in high resolution then you can't say whether the code is correct or not if you look at the results of screen resolution rendering.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Font Height and width based on font size
    By Ghufran in forum Qt Programming
    Replies: 1
    Last Post: 31st July 2010, 08:02
  2. Cancelling Long-running Print/Print Preview
    By ChrisW67 in forum Newbie
    Replies: 4
    Last Post: 16th June 2009, 23:05
  3. Change Font of QListWidget to Monospace Font
    By pospiech in forum Qt Programming
    Replies: 3
    Last Post: 25th July 2008, 18:23
  4. font incorrectly show - font break.
    By sgh in forum Qt Programming
    Replies: 9
    Last Post: 30th May 2008, 02:35
  5. Replies: 4
    Last Post: 18th December 2007, 08:31

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.