Skip to content

Commit

Permalink
Fix rendering of vertical text buffer
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 10, 2022
1 parent ed84780 commit dc755b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core/textrenderer/qgstextrenderer.cpp
Expand Up @@ -385,8 +385,7 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
int fragmentIndex = 0;
for ( const QgsTextFragment &fragment : component.block )
{
const QFont fragmentFont = metrics.fragmentFont( component.blockIndex, fragmentIndex );

const QFont fragmentFont = metrics.fragmentFont( component.blockIndex, component.firstFragmentIndex + fragmentIndex );
const double letterSpacing = fragmentFont.letterSpacing() / scaleFactor;

const QFontMetricsF fragmentMetrics( fragmentFont );
Expand All @@ -400,6 +399,7 @@ double QgsTextRenderer::drawBuffer( QgsRenderContext &context, const QgsTextRend
partYOffset += letterSpacing;
}
partLastDescent = fragmentMetrics.descent() / scaleFactor;

fragmentIndex++;
}
height = partYOffset + partLastDescent;
Expand Down Expand Up @@ -1846,6 +1846,7 @@ void QgsTextRenderer::drawTextInternalVertical( QgsRenderContext &context, const
Component subComponent;
subComponent.block = QgsTextBlock( fragment );
subComponent.blockIndex = blockIndex;
subComponent.firstFragmentIndex = fragmentIndex;
subComponent.size = QSizeF( blockMaximumCharacterWidth, labelHeight + fragmentMetrics.descent() / fontScale );
subComponent.offset = QPointF( 0.0, currentBlockYOffset );
subComponent.rotation = -component.rotation * 180 / M_PI;
Expand Down
3 changes: 3 additions & 0 deletions src/core/textrenderer/qgstextrenderer.h
Expand Up @@ -238,6 +238,9 @@ class CORE_EXPORT QgsTextRenderer
//! Index of block
int blockIndex = 0;

//! Index of first fragment in block
int firstFragmentIndex = 0;

//! Current origin point for painting (generally current painter rotation point)
QPointF origin;
//! Whether to translate the painter to supplied origin
Expand Down

0 comments on commit dc755b6

Please sign in to comment.