Skip to content

Commit

Permalink
Fix #9057, offset value misplaced when exporting composer to image
Browse files Browse the repository at this point in the history
- Add unit test and control images
  • Loading branch information
dakcarto committed Feb 22, 2014
1 parent ef7a036 commit 7e33fde
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/core/qgspallabeling.cpp
Expand Up @@ -4591,8 +4591,8 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
p->save();
p->translate( QPointF( component.center().x(), component.center().y() ) );
p->rotate( component.rotation() );
double xoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.x(), context, tmpLyr.shapeOffsetUnits, true );
double yoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.y(), context, tmpLyr.shapeOffsetUnits, true );
double xoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.x(), context, tmpLyr.shapeOffsetUnits, false );
double yoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.y(), context, tmpLyr.shapeOffsetUnits, false );
p->translate( QPointF( xoff, yoff ) );
p->rotate( component.rotationOffset() );

Expand Down
19 changes: 19 additions & 0 deletions tests/src/python/test_qgspallabeling_tests.py
Expand Up @@ -58,6 +58,25 @@ def test_text_color(self):
self.lyr.textColor = Qt.blue
self.checkTest()

def test_background_rect(self):
self.lyr.shapeDraw = True
self.checkTest()

def test_background_rect_w_offset(self):
# Label rectangular background
# verify fix for issues
# http://hub.qgis.org/issues/9057
# http://gis.stackexchange.com/questions/86900
self.lyr.fontSizeInMapUnits = True
font = QFont(self._TestFont)
font.setPointSizeF(460)
self.lyr.textFont = font

self.lyr.shapeDraw = True
self.lyr.shapeOffsetUnits = QgsPalLayerSettings.MapUnits
self.lyr.shapeOffset = QPointF(-2900.0, -450.0 )
self.checkTest()

def test_partials_labels_enabled(self):
# Set Big font size
font = QFont(self._TestFont)
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7e33fde

Please sign in to comment.