Skip to content
Permalink
Browse files

Fixed a bug that was causing map label font sizes not to match

between the rendered preview and the printout. 


git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@7254 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
StevenB StevenB
StevenB authored and StevenB committed Oct 6, 2007
1 parent 397fb48 commit 25434f6ceae6fe11a5d52fc7845106a7f80d67bc
Showing with 22 additions and 1 deletion.
  1. +22 −1 src/app/composer/qgscomposermap.cpp
@@ -25,11 +25,15 @@
#include "qgsmaprender.h"
#include "qgsvectorlayer.h"

#include "qgslabel.h"
#include "qgslabelattributes.h"

#include <QGraphicsScene>
#include <QGraphicsRectItem>
#include <QPainter>
#include <iostream>
#include <cmath>

// round isn't defined by default in msvc
#ifdef _MSC_VER
#define round(x) ((x) >= 0 ? floor((x)+0.5) : floor((x)-0.5))
@@ -221,7 +225,24 @@ void QgsComposerMap::draw ( QPainter *painter, QgsRect &extent, QgsMapToPixel *t
// should use size metrics.ascent() * 72.0 / mComposition->resolution();
// We could add a factor for metrics.ascent()/size but it is variable
// Add a parrameter in drawLables() ?
fontScale = 72.0 / mComposition->resolution();

QFont tempFont;
tempFont.setFamily(vector->label()->layerAttributes()->family());

double size = vector->label()->layerAttributes()->size();
size = 25.4 * size / 72;

tempFont.setPointSizeF(size);
QFontMetricsF tempMetrics(tempFont);

fontScale = tempMetrics.ascent() * 72.0 / mComposition->resolution();
//std::cout << "fontScale: " << fontScale << std::endl;

fontScale *= mFontScale;

//divide out the font size, since it will be multiplied back in when drawing the labels
fontScale /= vector->label()->layerAttributes()->size();

}
vector->drawLabels ( painter, extent, transform, ct, fontScale );
}

0 comments on commit 25434f6

Please sign in to comment.
You can’t perform that action at this time.