Skip to content
Permalink
Browse files

Respect render context antialiasing setting in text renderer

  • Loading branch information
nyalldawson committed Oct 24, 2016
1 parent 76c12ba commit 4282474c260be20701f627a309c8ca0a87087343
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/core/qgstextrenderer.cpp
@@ -1869,6 +1869,10 @@ void QgsTextRenderer::drawBuffer( QgsRenderContext& context, const QgsTextRender
{
p->setCompositionMode( buffer.blendMode() );
}
if ( context.flags() & QgsRenderContext::Antialiasing )
{
p->setRenderHint( QPainter::Antialiasing );
}

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

drawShadow( context, component, format );
p->restore();
@@ -2121,6 +2129,10 @@ void QgsTextRenderer::drawBackground( QgsRenderContext& context, QgsTextRenderer
{
p->setCompositionMode( background.blendMode() );
}
if ( context.flags() & QgsRenderContext::Antialiasing )
{
p->setRenderHint( QPainter::Antialiasing );
}
p->translate( component.center.x(), component.center.y() );
p->rotate( component.rotation );
double xoff = QgsTextRenderer::scaleToPixelContext( background.offset().x(), context, background.offsetUnit(), false, background.offsetMapUnitScale() );
@@ -2185,6 +2197,10 @@ void QgsTextRenderer::drawBackground( QgsRenderContext& context, QgsTextRenderer
return;

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

p->save();
p->setRenderHints( QPainter::Antialiasing | QPainter::SmoothPixmapTransform );
p->setRenderHint( QPainter::SmoothPixmapTransform );
if ( context.flags() & QgsRenderContext::Antialiasing )
{
p->setRenderHint( QPainter::Antialiasing );
}
if ( context.useAdvancedEffects() )
{
p->setCompositionMode( shadow.blendMode() );
@@ -2456,6 +2476,10 @@ void QgsTextRenderer::drawTextInternal( TextPart drawType,
Q_FOREACH ( const QString& line, textLines )
{
context.painter()->save();
if ( context.flags() & QgsRenderContext::Antialiasing )
{
context.painter()->setRenderHint( QPainter::Antialiasing );
}
context.painter()->translate( component.origin );
if ( !qgsDoubleNear( component.rotation, 0.0 ) )
context.painter()->rotate( -component.rotation * 180 / M_PI );

0 comments on commit 4282474

Please sign in to comment.
You can’t perform that action at this time.