Skip to content
Permalink
Browse files
Fix for bug grid annotation distance to map frame (#2899)
git-svn-id: http://svn.osgeo.org/qgis/trunk@15720 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
mhugent committed Apr 16, 2011
1 parent 136b608 commit 09aa28171917e7241f4a6f67e81c5e46741f45b4
@@ -226,6 +226,10 @@ class QgsComposerItem: QObject, QGraphicsRectItem
/**Returns the font width in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double textWidthMillimeters( const QFont& font, const QString& text ) const;

/**Returns the font height of a character in millimeters
@note this method was added in version 1.7*/
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const;

/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMillimeters( const QFont& font ) const;

@@ -803,6 +803,13 @@ double QgsComposerItem::textWidthMillimeters( const QFont& font, const QString&
return ( fontMetrics.width( text ) / FONT_WORKAROUND_SCALE );
}

double QgsComposerItem::fontHeightCharacterMM( const QFont& font, const QChar& c ) const
{
QFont metricsFont = scaledFontPixelSize( font );
QFontMetricsF fontMetrics( metricsFont );
return ( fontMetrics.boundingRect( c ).height() / FONT_WORKAROUND_SCALE );
}

double QgsComposerItem::fontAscentMillimeters( const QFont& font ) const
{
QFont metricsFont = scaledFontPixelSize( font );
@@ -187,9 +187,13 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
/**Like the above, but with a rectangle for multiline text*/
void drawText( QPainter* p, const QRectF& rect, const QString& text, const QFont& font, Qt::AlignmentFlag halignement = Qt::AlignLeft, Qt::AlignmentFlag valignement = Qt::AlignTop ) const;

/**Returns the font width in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
/**Returns the font width in millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double textWidthMillimeters( const QFont& font, const QString& text ) const;

/**Returns the font height of a character in millimeters
@note this method was added in version 1.7*/
double fontHeightCharacterMM( const QFont& font, const QChar& c ) const;

/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMillimeters( const QFont& font ) const;

@@ -947,7 +947,8 @@ void QgsComposerMap::drawCoordinateAnnotation( QPainter* p, const QPointF& pos,
{
Border frameBorder = borderForLineCoord( pos );
double textWidth = textWidthMillimeters( mGridAnnotationFont, annotationString );
double textHeight = fontAscentMillimeters( mGridAnnotationFont );
//relevant for annotations is the height of digits
double textHeight = fontHeightCharacterMM( mGridAnnotationFont, QChar( '0' ) );
double xpos = pos.x();
double ypos = pos.y();
int rotation = 0;

0 comments on commit 09aa281

Please sign in to comment.