mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-16 00:05:45 -04:00
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
This commit is contained in:
parent
136b608d5c
commit
09aa281719
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user