|
25 | 25 | #include "qgsmaprender.h"
|
26 | 26 | #include "qgsvectorlayer.h"
|
27 | 27 |
|
| 28 | +#include "qgslabel.h" |
| 29 | +#include "qgslabelattributes.h" |
| 30 | + |
28 | 31 | #include <QGraphicsScene>
|
29 | 32 | #include <QGraphicsRectItem>
|
30 | 33 | #include <QPainter>
|
31 | 34 | #include <iostream>
|
32 | 35 | #include <cmath>
|
| 36 | + |
33 | 37 | // round isn't defined by default in msvc
|
34 | 38 | #ifdef _MSC_VER
|
35 | 39 | #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
|
221 | 225 | // should use size metrics.ascent() * 72.0 / mComposition->resolution();
|
222 | 226 | // We could add a factor for metrics.ascent()/size but it is variable
|
223 | 227 | // Add a parrameter in drawLables() ?
|
224 |
| - fontScale = 72.0 / mComposition->resolution(); |
| 228 | + |
| 229 | + QFont tempFont; |
| 230 | + tempFont.setFamily(vector->label()->layerAttributes()->family()); |
| 231 | + |
| 232 | + double size = vector->label()->layerAttributes()->size(); |
| 233 | + size = 25.4 * size / 72; |
| 234 | + |
| 235 | + tempFont.setPointSizeF(size); |
| 236 | + QFontMetricsF tempMetrics(tempFont); |
| 237 | + |
| 238 | + fontScale = tempMetrics.ascent() * 72.0 / mComposition->resolution(); |
| 239 | + //std::cout << "fontScale: " << fontScale << std::endl; |
| 240 | + |
| 241 | + fontScale *= mFontScale; |
| 242 | + |
| 243 | + //divide out the font size, since it will be multiplied back in when drawing the labels |
| 244 | + fontScale /= vector->label()->layerAttributes()->size(); |
| 245 | + |
225 | 246 | }
|
226 | 247 | vector->drawLabels ( painter, extent, transform, ct, fontScale );
|
227 | 248 | }
|
|
0 commit comments