@@ -178,25 +178,22 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
178
178
QFontMetrics metrics ( font );
179
179
180
180
// Fonts for rendering
181
+ double psTitleSize = titleMetrics.ascent () * 72.0 / mComposition ->resolution ();
182
+ double psSectionSize = sectionMetrics.ascent () * 72.0 / mComposition ->resolution ();
183
+ double psSize = metrics.ascent () * 72.0 / mComposition ->resolution ();
181
184
182
- // TODO: For output to Postscript the font must be scaled. But how?
183
- // The factor is an empirical value.
184
- // In any case, each font scales in in different way even if painter.scale()
185
- // is used instead of font size!!! -> Postscript is never exactly the same as
186
- // in preview.
187
- double psFontFactor = QgsComposition::psFontScaleFactor ();
188
-
189
- double psTitleSize = psFontFactor * 72.0 * mTitleFont .pointSizeFloat () / mComposition ->resolution ();
190
- double psSectionSize = psFontFactor * 72.0 * mSectionFont .pointSizeFloat () / mComposition ->resolution ();
191
- double psSize = psFontFactor * 72.0 * mFont .pointSizeFloat () / mComposition ->resolution ();
192
-
193
- double psTitleFontScale = psTitleSize / titleSize;
194
- double psSectionFontScale = psSectionSize / sectionSize;
195
- double psFontScale = psSize / size;
196
-
197
- titleFont.setPointSizeFloat ( titleSize );
198
- sectionFont.setPointSizeFloat ( sectionSize );
199
- font.setPointSizeFloat ( size );
185
+ if ( plotStyle () == QgsComposition::Postscript)
186
+ {
187
+ titleFont.setPointSizeFloat ( psTitleSize );
188
+ sectionFont.setPointSizeFloat ( psSectionSize );
189
+ font.setPointSizeFloat ( psSize );
190
+ }
191
+ else
192
+ {
193
+ titleFont.setPointSizeFloat ( titleSize );
194
+ sectionFont.setPointSizeFloat ( sectionSize );
195
+ font.setPointSizeFloat ( size );
196
+ }
200
197
201
198
// Not sure about Style Strategy, QFont::PreferMatch?
202
199
titleFont.setStyleStrategy ( (QFont::StyleStrategy) (QFont::PreferOutline | QFont::PreferAntialias) );
@@ -210,15 +207,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
210
207
painter->setPen ( mPen );
211
208
painter->setFont ( titleFont );
212
209
213
- if ( plotStyle () == QgsComposition::Postscript) {
214
- painter->save ();
215
- painter->translate ( (int ) (2 *mMargin ), y );
216
- painter->scale ( psTitleFontScale, psTitleFontScale );
217
- painter->drawText ( 0 , 0 , mTitle );
218
- painter->restore ();
219
- } else {
220
- painter->drawText ( (int ) (2 *mMargin ), y, mTitle );
221
- }
210
+ painter->drawText ( (int ) (2 *mMargin ), y, mTitle );
222
211
223
212
int width = 4 * mMargin + titleMetrics.width ( mTitle );
224
213
int height = mMargin + mSymbolSpace + titleMetrics.height (); // mSymbolSpace?
@@ -239,7 +228,6 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
239
228
240
229
int group = layerGroup ( layerId );
241
230
if ( group > 0 ) {
242
- // std::map<int,int>::iterator it= doneGroups.find();
243
231
if ( doneGroups.find (group) != doneGroups.end () ) {
244
232
continue ;
245
233
} else {
@@ -337,15 +325,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
337
325
painter->setPen ( mPen );
338
326
painter->setFont ( sectionFont );
339
327
340
- if ( plotStyle () == QgsComposition::Postscript) {
341
- painter->save ();
342
- painter->translate ( x, y );
343
- painter->scale ( psSectionFontScale, psSectionFontScale );
344
- painter->drawText ( 0 , 0 , sectionTitle );
345
- painter->restore ();
346
- } else {
347
- painter->drawText ( x, y, sectionTitle );
348
- }
328
+ painter->drawText ( x, y,sectionTitle );
349
329
350
330
int w = 3 *mMargin + sectionMetrics.width ( sectionTitle );
351
331
if ( w > width ) width = w;
@@ -418,15 +398,7 @@ QRect QgsComposerVectorLegend::render ( QPainter *p )
418
398
x = (int ) ( 2 *mMargin + mSymbolWidth );
419
399
y = (int ) ( localHeight + symbolHeight/2 + ( metrics.height ()/2 - metrics.descent ()) );
420
400
421
- if ( plotStyle () == QgsComposition::Postscript) {
422
- painter->save ();
423
- painter->translate ( x, y );
424
- painter->scale ( psFontScale, psFontScale );
425
- painter->drawText ( 0 , 0 , lab );
426
- painter->restore ();
427
- } else {
428
- painter->drawText ( x, y, lab );
429
- }
401
+ painter->drawText ( x, y, lab );
430
402
431
403
int w = 3 *mMargin + mSymbolWidth + metrics.width (lab);
432
404
if ( w > width ) width = w;
0 commit comments