Skip to content

Commit

Permalink
Fix clang warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Nov 14, 2022
1 parent 78e5f14 commit 255015b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/core/textrenderer/qgstextdocumentmetrics.cpp
Expand Up @@ -128,7 +128,7 @@ QgsTextDocumentMetrics QgsTextDocumentMetrics::calculateMetrics( const QgsTextDo
// the superscript in a smaller font size. BUT if the fragment format HAS a non -1 font size then it indicates
// that the document has an explicit font size for the super/subscript element, eg "my text<sup style="font-size: 6pt">2</sup>"
// which we should respect
updatedFont.setPixelSize( updatedFont.pixelSize() * SUPERSCRIPT_SUBSCRIPT_FONT_SIZE_SCALING_FACTOR );
updatedFont.setPixelSize( static_cast< int >( std::round( updatedFont.pixelSize() * SUPERSCRIPT_SUBSCRIPT_FONT_SIZE_SCALING_FACTOR ) ) );
fm = QFontMetricsF( updatedFont );
}

Expand All @@ -148,7 +148,7 @@ QgsTextDocumentMetrics QgsTextDocumentMetrics::calculateMetrics( const QgsTextDo
if ( fragmentFormat.fontPointSize() < 0 )
{
// see above!!
updatedFont.setPixelSize( updatedFont.pixelSize() * SUPERSCRIPT_SUBSCRIPT_FONT_SIZE_SCALING_FACTOR );
updatedFont.setPixelSize( static_cast< int>( std::round( updatedFont.pixelSize() * SUPERSCRIPT_SUBSCRIPT_FONT_SIZE_SCALING_FACTOR ) ) );
fm = QFontMetricsF( updatedFont );
}

Expand Down Expand Up @@ -365,7 +365,6 @@ QRectF QgsTextDocumentMetrics::outerBounds( Qgis::TextLayoutMode mode, Qgis::Tex
BUILTIN_UNREACHABLE

case Qgis::TextOrientation::Vertical:
return QRectF();
case Qgis::TextOrientation::RotationBased:
return QRectF(); // label mode only
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/textrenderer/qgstextrenderer.cpp
Expand Up @@ -1690,7 +1690,7 @@ void QgsTextRenderer::drawTextInternalHorizontal( QgsRenderContext &context, con
context.painter()->setRenderHint( QPainter::TextAntialiasing );

context.painter()->scale( 1 / fontScale, 1 / fontScale );
context.painter()->drawText( xOffset, yOffset, fragment.text() );
context.painter()->drawText( QPointF( xOffset, yOffset ), fragment.text() );
context.painter()->scale( fontScale, fontScale );

xOffset += metrics.fragmentHorizontalAdvance( blockIndex, fragmentIndex, mode );
Expand Down Expand Up @@ -1952,7 +1952,7 @@ void QgsTextRenderer::drawTextInternalVertical( QgsRenderContext &context, const
{
double partXOffset = ( blockMaximumCharacterWidth - ( fragmentMetrics.horizontalAdvance( part ) / fontScale - letterSpacing ) ) / 2;
context.painter()->scale( 1 / fontScale, 1 / fontScale );
context.painter()->drawText( partXOffset * fontScale, ( currentBlockYOffset + partYOffset ) * fontScale, part );
context.painter()->drawText( QPointF( partXOffset * fontScale, ( currentBlockYOffset + partYOffset ) * fontScale ), part );
context.painter()->scale( fontScale, fontScale );
partYOffset += fragmentMetrics.ascent() / fontScale + letterSpacing;
}
Expand Down

0 comments on commit 255015b

Please sign in to comment.