Skip to content

Commit 7e33fde

Browse files
committed
Fix #9057, offset value misplaced when exporting composer to image
- Add unit test and control images
1 parent ef7a036 commit 7e33fde

File tree

8 files changed

+21
-2
lines changed

8 files changed

+21
-2
lines changed

src/core/qgspallabeling.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4591,8 +4591,8 @@ void QgsPalLabeling::drawLabelBackground( QgsRenderContext& context,
45914591
p->save();
45924592
p->translate( QPointF( component.center().x(), component.center().y() ) );
45934593
p->rotate( component.rotation() );
4594-
double xoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.x(), context, tmpLyr.shapeOffsetUnits, true );
4595-
double yoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.y(), context, tmpLyr.shapeOffsetUnits, true );
4594+
double xoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.x(), context, tmpLyr.shapeOffsetUnits, false );
4595+
double yoff = tmpLyr.scaleToPixelContext( tmpLyr.shapeOffset.y(), context, tmpLyr.shapeOffsetUnits, false );
45964596
p->translate( QPointF( xoff, yoff ) );
45974597
p->rotate( component.rotationOffset() );
45984598

tests/src/python/test_qgspallabeling_tests.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ def test_text_color(self):
5858
self.lyr.textColor = Qt.blue
5959
self.checkTest()
6060

61+
def test_background_rect(self):
62+
self.lyr.shapeDraw = True
63+
self.checkTest()
64+
65+
def test_background_rect_w_offset(self):
66+
# Label rectangular background
67+
# verify fix for issues
68+
# http://hub.qgis.org/issues/9057
69+
# http://gis.stackexchange.com/questions/86900
70+
self.lyr.fontSizeInMapUnits = True
71+
font = QFont(self._TestFont)
72+
font.setPointSizeF(460)
73+
self.lyr.textFont = font
74+
75+
self.lyr.shapeDraw = True
76+
self.lyr.shapeOffsetUnits = QgsPalLayerSettings.MapUnits
77+
self.lyr.shapeOffset = QPointF(-2900.0, -450.0 )
78+
self.checkTest()
79+
6180
def test_partials_labels_enabled(self):
6281
# Set Big font size
6382
font = QFont(self._TestFont)
7.83 KB
Loading
7.87 KB
Loading
8.75 KB
Loading
8.7 KB
Loading
7.83 KB
Loading
7.87 KB
Loading

0 commit comments

Comments
 (0)