Skip to content
Permalink
Browse files
Merge pull request #374 from bholland/master
Fix #6942
  • Loading branch information
NathanW2 committed Jan 4, 2013
2 parents 1bda31d + fb26989 commit fb763a7e4803d992664506e88bfd3353768b2883
Showing with 11 additions and 1 deletion.
  1. +7 −0 src/core/composer/qgscomposeritem.cpp
  2. +3 −0 src/core/composer/qgscomposeritem.h
  3. +1 −1 src/core/composer/qgscomposerlegend.cpp
@@ -837,6 +837,13 @@ double QgsComposerItem::fontAscentMillimeters( const QFont& font ) const
return ( fontMetrics.ascent() / FONT_WORKAROUND_SCALE );
}

double QgsComposerItem::fontDescentMillimeters( const QFont& font ) const
{
QFont metricsFont = scaledFontPixelSize( font );
QFontMetricsF fontMetrics( metricsFont );
return ( fontMetrics.descent() / FONT_WORKAROUND_SCALE );
}

double QgsComposerItem::pixelFontSize( double pointSize ) const
{
return ( pointSize * 0.3527 );
@@ -213,6 +213,9 @@ class CORE_EXPORT QgsComposerItem: public QObject, public QGraphicsRectItem
/**Returns the font ascent in Millimeters (considers upscaling and downscaling with FONT_WORKAROUND_SCALE*/
double fontAscentMillimeters( const QFont& font ) const;

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

/**Calculates font to from point size to pixel size*/
double pixelFontSize( double pointSize ) const;

@@ -212,7 +212,7 @@ QSizeF QgsComposerLegend::drawTitle( QPainter* painter, QPointF point, Qt::Align
{
// it does not draw the last world if rectangle width is exactly text width
double width = textWidthMillimeters( mTitleFont, *titlePart ) + 1;
double height = fontAscentMillimeters( mTitleFont );
double height = fontAscentMillimeters( mTitleFont ) + fontDescentMillimeters( mTitleFont );

double left = halignement == Qt::AlignLeft ? point.x() : point.x() - width / 2;

0 comments on commit fb763a7

Please sign in to comment.