Hi all,

I want to print a form with lines/graphics and text, passing millimeters as coordinates to the painter functions.
To achive this I use SetWindow() on the painter object.
This works perfectly for the lines, but when I try to print some text, the font-size is way too big.
I had a look at the font object properties while debugging, and the point-size was 10 points, but the pixel-size was 167!
How can I make the font print at 10 points, while maintaining the millimeter coordinate system?

Example code:
Qt Code:
  1. printer = new QPrinter(QPrinter::PrinterResolution);
  2. ...
  3. //set pens and fonts
  4. QPen pen03;
  5. pen03.setWidthF(0.3);
  6.  
  7. QPen pen01;
  8. pen01.setWidthF(0.1);
  9.  
  10. QFont arial10("Arial", 10, QFont::Normal);
  11.  
  12. //draw the form
  13. QPainter painter;
  14. painter.begin(printer);
  15. painter.setWindow(QRect(0, 0, 210, 297)); //set coordinates in millimeters
  16.  
  17. painter.setPen(pen03);
  18. painter.drawLine(QLine(20, 50, 195, 50));
  19. painter.drawLine(QLine(195, 50, 195, 280));
  20. painter.drawLine(QLine(195, 280, 20, 280));
  21. painter.drawLine(QLine(20, 280, 20, 50));
  22. painter.drawLine(QLine(20, 57, 195, 57));
  23.  
  24. painter.setPen(pen01);
  25. painter.drawLine(QLine((wordX - 5), 50, (wordX - 5), 280));
  26. painter.drawLine(QLine((explX - 5), 50, (explX - 5), 280));
  27.  
  28. painter.setFont(arial10);
  29. painter.drawText(150, 50, "Testing"); // the font printed is *not* 10 points.
  30. ...
  31. painter.end();
To copy to clipboard, switch view to plain text mode