Bug report #11830

QgsMapRendererSequentialJob is truncating text.

Added by Michael gledhill over 5 years ago. Updated over 1 year ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Labelling
Affected QGIS version:2.6.0 Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:20048

Description

I've been using the following python code for rendering, however it causes text to get partially displayed at the image edges.

def render(self, tile):
scale = self.scaleCalc.calculate(self.projector.transform(tile.toRectangle()), self.width)
self.settings.setExtent(self.projector.transform(tile.toRectangle()))
job = QgsMapRendererSequentialJob(self.settings)
job.start()
job.waitForFinished()
image = job.renderedImage()

I've tried to make a call to QgsMapRendererJob.drawLabeling(), as below, in an attempt to stop this behaviour, but this causes a crash.

def render(self, tile):
scale = self.scaleCalc.calculate(self.projector.transform(tile.toRectangle()), self.width)
self.settings.setExtent(self.projector.transform(tile.toRectangle()))
job = QgsMapRendererSequentialJob(self.settings) # added
labeler = QgsPalLabeling()
labeler.setShowingPartialsLabels(False)
painter = QPainter()
painter.setRenderHint(QPainter.Antialiasing)
QgsMapRendererJob.drawLabeling(self.settings, QgsRenderContext(), labeler, painter) # added - end
job.start()
job.waitForFinished()
image = job.renderedImage()

I'm new to QGIS and Python. I've not been able to find guidance on the calling convention to call the drawLabeling C++ function. Consequently, I don't know if the problem is an input error, a syntax error or a coding logic error.

History

#1 Updated by Giovanni Manghi over 3 years ago

  • Easy fix? set to No
  • Regression? set to No

#2 Updated by Giovanni Manghi over 1 year ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF