diff --git a/src/core/annotations/qgsannotationpointtextitem.cpp b/src/core/annotations/qgsannotationpointtextitem.cpp index 440083fd08e..5311d840edc 100644 --- a/src/core/annotations/qgsannotationpointtextitem.cpp +++ b/src/core/annotations/qgsannotationpointtextitem.cpp @@ -88,7 +88,7 @@ void QgsAnnotationPointTextItem::render( QgsRenderContext &context, QgsFeedback QgsTextRenderer::drawText( pt, - angle * M_PI / 180.0, QgsTextRenderer::convertQtHAlignment( mAlignment ), - displayText.split( '\n' ), context, mTextFormat ); + mTextFormat.allowHtmlFormatting() ? QStringList{displayText }: displayText.split( '\n' ), context, mTextFormat ); } bool QgsAnnotationPointTextItem::writeXml( QDomElement &element, QDomDocument &document, const QgsReadWriteContext &context ) const @@ -165,8 +165,8 @@ QgsRectangle QgsAnnotationPointTextItem::boundingBox( QgsRenderContext &context { const QString displayText = QgsExpression::replaceExpressionText( mText, &context.expressionContext(), &context.distanceArea() ); - const double widthInPixels = QgsTextRenderer::textWidth( context, mTextFormat, displayText.split( '\n' ) ); - const double heightInPixels = QgsTextRenderer::textHeight( context, mTextFormat, displayText.split( '\n' ) ); + const double widthInPixels = QgsTextRenderer::textWidth( context, mTextFormat, mTextFormat.allowHtmlFormatting() ? QStringList{displayText }: displayText.split( '\n' ) ); + const double heightInPixels = QgsTextRenderer::textHeight( context, mTextFormat, mTextFormat.allowHtmlFormatting() ? QStringList{displayText }: displayText.split( '\n' ) ); // text size has already been calculated using any symbology reference scale factor above -- we need // to temporarily remove the reference scale here or we'll be undoing the scaling diff --git a/src/core/annotations/qgsannotationrectangletextitem.cpp b/src/core/annotations/qgsannotationrectangletextitem.cpp index 3a1bf49c0ce..be0883ec95b 100644 --- a/src/core/annotations/qgsannotationrectangletextitem.cpp +++ b/src/core/annotations/qgsannotationrectangletextitem.cpp @@ -96,7 +96,7 @@ void QgsAnnotationRectangleTextItem::render( QgsRenderContext &context, QgsFeedb context.setFlag( Qgis::RenderContextFlag::ApplyScalingWorkaroundForTextRendering, true ); QgsTextRenderer::drawText( innerRect, 0, QgsTextRenderer::convertQtHAlignment( mAlignment ), - displayText.split( '\n' ), context, mTextFormat, true, + mTextFormat.allowHtmlFormatting() ? QStringList{displayText }: displayText.split( '\n' ), context, mTextFormat, true, QgsTextRenderer::convertQtVAlignment( mAlignment ), Qgis::TextRendererFlag::WrapLines ); context.setFlag( Qgis::RenderContextFlag::ApplyScalingWorkaroundForTextRendering, prevWorkaroundFlag );