Hi All

I'm working on a plugin which adds a custom plugin layer to the map.  This all 
works fine on the desktop, but goes horribly wrong in print composer and in 
printed outout.

What it comes down to is that I'm using QFontMetricsF to calculate the size of 
some text, which I'm then using for layout. On the screen this is fine.  In the 
printed output the rectangle returned by QFontMetricsF is about 1/3 the size of 
the printed text, which makes the layout pretty awful!  The test code I have is 
as follows:

            painter.save()
            painter.setPen(QPen())
            painter.setBrush(Qt.NoBrush)
            painter.translate(position.x(),position.y())
            painter.scale(fontFactor,fontFactor)
            painter.setFont(font)
            painter.drawText(QPointF(0.0,0.0),text)
            painter.drawRect(QFontMetricsF(font).boundingRect(text))
            painter.restore()

The result (after printing to PDF) is that the box printed by drawRect is about 
1/3 the size of the text printed by drawText.  This seems to be independent of 
the size and location of the map in print composer or the font used.  Also 
printing to PDF or PNG gives the same result.

At first sight this looks to me like a bug in Qt, but that seems unlikely?  Any 
thoughts please?

I'm running this on Ubuntu 11.10.  Qgis version information as follows:

QGIS version
1.8.0-Lisboa
QGIS code revision
exported
Compiled against Qt
4.7.4
Running against Qt
4.7.4
Compiled against GDAL/OGR
1.9.2
Running against GDAL/OGR
1.9.2
GEOS Version
3.3.3
PostgreSQL Client Version
9.1.6
SpatiaLite Version
2.4.0
QWT Version
5.2.2


Chris Crook

This message contains information, which is confidential and may be subject to 
legal privilege. If you are not the intended recipient, you must not peruse, 
use, disseminate, distribute or copy this message. If you have received this 
message in error, please notify us immediately (Phone 0800 665 463 or 
[email protected]) and destroy the original message. LINZ accepts no 
responsibility for changes to this email, or for any attachments, after its 
transmission from LINZ. Thank You.
_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to