Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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 authored and StevenB committed Oct 6, 2007
1 parent 397fb48 commit 25434f6
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/app/composer/qgscomposermap.cpp
Expand Up @@ -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))
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 25434f6

Please sign in to comment.