@@ -3211,6 +3211,7 @@ QgsPalLabeling::QgsPalLabeling()
3211
3211
mShowingShadowRects = false ;
3212
3212
mShowingAllLabels = false ;
3213
3213
mShowingPartialsLabels = p.getShowPartial ();
3214
+ mDrawOutlineLabels = true ;
3214
3215
}
3215
3216
3216
3217
QgsPalLabeling::~QgsPalLabeling ()
@@ -4443,6 +4444,11 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext& con
4443
4444
textp.setPen ( Qt::NoPen );
4444
4445
textp.setBrush ( tmpLyr.textColor );
4445
4446
textp.drawPath ( path );
4447
+ // TODO: why are some font settings lost on drawPicture() when using drawText() inside QPicture?
4448
+ // e.g. some capitalization options, but not others
4449
+ // textp.setFont( tmpLyr.textFont );
4450
+ // textp.setPen( tmpLyr.textColor );
4451
+ // textp.drawText( 0, 0, component.text() );
4446
4452
textp.end ();
4447
4453
4448
4454
if ( tmpLyr.shadowDraw && tmpLyr.shadowUnder == QgsPalLayerSettings::ShadowText )
@@ -4459,20 +4465,24 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QgsRenderContext& con
4459
4465
{
4460
4466
painter->setCompositionMode ( tmpLyr.blendMode );
4461
4467
}
4462
- // painter->setPen( Qt::NoPen );
4463
- // painter->setBrush( tmpLyr.textColor );
4464
- // painter->drawPath( path );
4465
4468
4466
4469
// scale for any print output or image saving @ specific dpi
4467
4470
painter->scale ( component.dpiRatio (), component.dpiRatio () );
4468
- _fixQPictureDPI ( painter );
4469
- painter->drawPicture ( 0 , 0 , textPict );
4470
-
4471
- // regular text draw, for testing optimization
4472
- // painter->setFont( tmpLyr.textFont );
4473
- // painter->setPen( tmpLyr.textColor );
4474
- // painter->drawText( 0, 0, multiLineList.at( i ) );
4475
4471
4472
+ if ( mDrawOutlineLabels )
4473
+ {
4474
+ // draw outlined text
4475
+ _fixQPictureDPI ( painter );
4476
+ painter->drawPicture ( 0 , 0 , textPict );
4477
+ }
4478
+ else
4479
+ {
4480
+ // draw text as text (for SVG and PDF exports)
4481
+ painter->setFont ( tmpLyr.textFont );
4482
+ painter->setPen ( tmpLyr.textColor );
4483
+ painter->setRenderHint ( QPainter::TextAntialiasing );
4484
+ painter->drawText ( 0 , 0 , component.text () );
4485
+ }
4476
4486
}
4477
4487
painter->restore ();
4478
4488
}
@@ -5004,6 +5014,8 @@ void QgsPalLabeling::loadEngineSettings()
5004
5014
" PAL" , " /ShowingAllLabels" , false , &saved );
5005
5015
mShowingPartialsLabels = QgsProject::instance ()->readBoolEntry (
5006
5016
" PAL" , " /ShowingPartialsLabels" , p.getShowPartial (), &saved );
5017
+ mDrawOutlineLabels = QgsProject::instance ()->readBoolEntry (
5018
+ " PAL" , " /DrawOutlineLabels" , true , &saved );
5007
5019
}
5008
5020
5009
5021
void QgsPalLabeling::saveEngineSettings ()
@@ -5016,6 +5028,7 @@ void QgsPalLabeling::saveEngineSettings()
5016
5028
QgsProject::instance ()->writeEntry ( " PAL" , " /ShowingShadowRects" , mShowingShadowRects );
5017
5029
QgsProject::instance ()->writeEntry ( " PAL" , " /ShowingAllLabels" , mShowingAllLabels );
5018
5030
QgsProject::instance ()->writeEntry ( " PAL" , " /ShowingPartialsLabels" , mShowingPartialsLabels );
5031
+ QgsProject::instance ()->writeEntry ( " PAL" , " /DrawOutlineLabels" , mDrawOutlineLabels );
5019
5032
}
5020
5033
5021
5034
void QgsPalLabeling::clearEngineSettings ()
@@ -5028,6 +5041,7 @@ void QgsPalLabeling::clearEngineSettings()
5028
5041
QgsProject::instance ()->removeEntry ( " PAL" , " /ShowingShadowRects" );
5029
5042
QgsProject::instance ()->removeEntry ( " PAL" , " /ShowingAllLabels" );
5030
5043
QgsProject::instance ()->removeEntry ( " PAL" , " /ShowingPartialsLabels" );
5044
+ QgsProject::instance ()->removeEntry ( " PAL" , " /DrawOutlineLabels" );
5031
5045
}
5032
5046
5033
5047
QgsLabelingEngineInterface* QgsPalLabeling::clone ()
@@ -5037,6 +5051,7 @@ QgsLabelingEngineInterface* QgsPalLabeling::clone()
5037
5051
lbl->mShowingCandidates = mShowingCandidates ;
5038
5052
lbl->mShowingShadowRects = mShowingShadowRects ;
5039
5053
lbl->mShowingPartialsLabels = mShowingPartialsLabels ;
5054
+ lbl->mDrawOutlineLabels = mDrawOutlineLabels ;
5040
5055
return lbl;
5041
5056
}
5042
5057
0 commit comments