Skip to content

Commit 4282474

Browse files
committed
Respect render context antialiasing setting in text renderer
1 parent 76c12ba commit 4282474

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/core/qgstextrenderer.cpp

+25-1
Original file line numberDiff line numberDiff line change
@@ -1869,6 +1869,10 @@ void QgsTextRenderer::drawBuffer( QgsRenderContext& context, const QgsTextRender
18691869
{
18701870
p->setCompositionMode( buffer.blendMode() );
18711871
}
1872+
if ( context.flags() & QgsRenderContext::Antialiasing )
1873+
{
1874+
p->setRenderHint( QPainter::Antialiasing );
1875+
}
18721876

18731877
// scale for any print output or image saving @ specific dpi
18741878
p->scale( component.dpiRatio, component.dpiRatio );
@@ -2103,6 +2107,10 @@ void QgsTextRenderer::drawBackground( QgsRenderContext& context, QgsTextRenderer
21032107
p->translate( QPointF( xoff, yoff ) );
21042108
p->rotate( component.rotationOffset );
21052109
p->translate( -sizeOut / 2, sizeOut / 2 );
2110+
if ( context.flags() & QgsRenderContext::Antialiasing )
2111+
{
2112+
p->setRenderHint( QPainter::Antialiasing );
2113+
}
21062114

21072115
drawShadow( context, component, format );
21082116
p->restore();
@@ -2121,6 +2129,10 @@ void QgsTextRenderer::drawBackground( QgsRenderContext& context, QgsTextRenderer
21212129
{
21222130
p->setCompositionMode( background.blendMode() );
21232131
}
2132+
if ( context.flags() & QgsRenderContext::Antialiasing )
2133+
{
2134+
p->setRenderHint( QPainter::Antialiasing );
2135+
}
21242136
p->translate( component.center.x(), component.center.y() );
21252137
p->rotate( component.rotation );
21262138
double xoff = QgsTextRenderer::scaleToPixelContext( background.offset().x(), context, background.offsetUnit(), false, background.offsetMapUnitScale() );
@@ -2185,6 +2197,10 @@ void QgsTextRenderer::drawBackground( QgsRenderContext& context, QgsTextRenderer
21852197
return;
21862198

21872199
p->save();
2200+
if ( context.flags() & QgsRenderContext::Antialiasing )
2201+
{
2202+
p->setRenderHint( QPainter::Antialiasing );
2203+
}
21882204
p->translate( QPointF( component.center.x(), component.center.y() ) );
21892205
p->rotate( component.rotation );
21902206
double xoff = QgsTextRenderer::scaleToPixelContext( background.offset().x(), context, background.offsetUnit(), false, background.offsetMapUnitScale() );
@@ -2353,7 +2369,11 @@ void QgsTextRenderer::drawShadow( QgsRenderContext& context, const QgsTextRender
23532369
-offsetDist * sin( angleRad + M_PI / 2 ) );
23542370

23552371
p->save();
2356-
p->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
2372+
p->setRenderHint( QPainter::SmoothPixmapTransform );
2373+
if ( context.flags() & QgsRenderContext::Antialiasing )
2374+
{
2375+
p->setRenderHint( QPainter::Antialiasing );
2376+
}
23572377
if ( context.useAdvancedEffects() )
23582378
{
23592379
p->setCompositionMode( shadow.blendMode() );
@@ -2456,6 +2476,10 @@ void QgsTextRenderer::drawTextInternal( TextPart drawType,
24562476
Q_FOREACH ( const QString& line, textLines )
24572477
{
24582478
context.painter()->save();
2479+
if ( context.flags() & QgsRenderContext::Antialiasing )
2480+
{
2481+
context.painter()->setRenderHint( QPainter::Antialiasing );
2482+
}
24592483
context.painter()->translate( component.origin );
24602484
if ( !qgsDoubleNear( component.rotation, 0.0 ) )
24612485
context.painter()->rotate( -component.rotation * 180 / M_PI );

0 commit comments

Comments
 (0)