27#include <QFontMetricsF> 
  159    res.mLastLineAscentOffset = res.mFirstLineAscentOffset;
 
  195    thisLineHeightUsingAscentDescent = std::max( thisLineHeightUsingAscentDescent, metrics.
maxBlockFixedItemHeight );
 
  198    documentMetrics.
currentLabelBaseline += verticalMarginBeforeBlock + thisLineHeightUsingAscentDescent;
 
  199    documentMetrics.
currentRectBaseline += verticalMarginBeforeBlock + thisLineHeightUsingLineSpacing;
 
  200    documentMetrics.
currentPointBaseline += verticalMarginBeforeBlock + thisLineHeightUsingLineSpacing;
 
  206    documentMetrics.
heightLabelMode += verticalMarginBeforeBlock + thisLineHeightUsingAscentDescent;
 
  207    documentMetrics.
heightPointRectMode += verticalMarginBeforeBlock + thisLineHeightUsingLineSpacing;
 
  208    documentMetrics.
heightCapHeightMode += verticalMarginBeforeBlock + thisLineHeightUsingLineSpacing;
 
  209    documentMetrics.
heightAscentMode += verticalMarginBeforeBlock + thisLineHeightUsingLineSpacing;
 
  255  res.mDocument.
append( outputBlock );
 
  268  if ( fragment.
isTab() )
 
  271    double nextTabStop = 0;
 
  275      nextTabStop = thisBlockMetrics.
blockXMax;
 
  276      for ( 
const double tabStop : std::as_const( documentMetrics.tabStopDistancesPainterUnits ) )
 
  278        if ( tabStop >= thisBlockMetrics.
blockXMax )
 
  280          nextTabStop = tabStop;
 
  289    const double fragmentWidth = nextTabStop - thisBlockMetrics.
blockXMax;
 
  292    thisBlockMetrics.
blockXMax += fragmentWidth;
 
  300    currentOutputBlock.
append( fragment );
 
  306    double fragmentHeightForVerticallyOffsetText = 0;
 
  307    double fragmentYMaxAdjust = 0;
 
  309    QFont updatedFont = font;
 
  312    QFontMetricsF fm( updatedFont );
 
  340            fm = QFontMetricsF( updatedFont );
 
  360            fm = QFontMetricsF( updatedFont );
 
  378                                      &fragmentHeightForVerticallyOffsetText,
 
  384      thisBlockMetrics.blockYMaxAdjustLabel = std::max( thisBlockMetrics.blockYMaxAdjustLabel, fragmentYMaxAdjust );
 
  385      thisBlockMetrics.blockHeightUsingAscentAccountingForVerticalOffset = std::max( std::max( thisBlockMetrics.maxBlockAscent, fragmentHeightForVerticallyOffsetText ), thisBlockMetrics.blockHeightUsingAscentAccountingForVerticalOffset );
 
  387      thisBlockMetrics.fragmentHorizontalAdvance << fragmentWidth;
 
  389      thisBlockMetrics.blockWidth += fragmentWidth;
 
  390      thisBlockMetrics.blockXMax += fragmentWidth;
 
  392      thisBlockMetrics.fragmentFonts << updatedFont;
 
  394      const double verticalOrientationFragmentHeight = thisBlockMetrics.isFirstNonTabFragment ? ( fm.ascent() / scaleFactor * fragment.
text().size() + ( fragment.
text().size() - 1 ) * updatedFont.letterSpacing() / scaleFactor )
 
  395          : ( fragment.text().size() * ( fm.ascent() / scaleFactor + updatedFont.letterSpacing() / scaleFactor ) );
 
  396      thisBlockMetrics.blockHeightVerticalOrientation += verticalOrientationFragmentHeight;
 
  398      thisBlockMetrics.isFirstNonTabFragment = 
false;
 
  404      double imageHeight = 0;
 
  405      double imageWidth = 0;
 
  412        const QSizeF originalSizeMmAt96Dpi = imageSize / 3.7795275590551185;
 
  414        imageWidth = originalSizeMmAt96Dpi.width() * pixelsPerMm;
 
  415        imageHeight = originalSizeMmAt96Dpi.height() * pixelsPerMm;
 
  422        imageWidth = originalImageSize.width() * imageHeight / originalImageSize.height();
 
  429        imageHeight = originalImageSize.height() * imageWidth / originalImageSize.width();
 
  439           && ( thisBlockMetrics.blockXMax + imageWidth > documentContext.
maximumWidth() )
 
  440           && !currentOutputBlock.
empty() )
 
  443        finalizeBlock( res, format, documentMetrics, currentOutputBlock, thisBlockMetrics );
 
  444        thisBlockMetrics.isFirstBlock = 
false;
 
  448      thisBlockMetrics.blockHeightUsingAscentDescent = std::max( thisBlockMetrics.blockHeightUsingAscentDescent, imageHeight + fm.descent() / scaleFactor );
 
  449      thisBlockMetrics.blockHeightUsingLineSpacing = std::max( thisBlockMetrics.blockHeightUsingLineSpacing, imageHeight + fm.leading() );
 
  451      thisBlockMetrics.maxBlockAscent = std::max( thisBlockMetrics.maxBlockAscent, imageHeight );
 
  452      thisBlockMetrics.maxBlockCapHeight = std::max( thisBlockMetrics.maxBlockCapHeight, imageHeight );
 
  453      thisBlockMetrics.fragmentAscent << imageHeight;
 
  454      thisBlockMetrics.fragmentDescent << 0;
 
  455      thisBlockMetrics.maxLineSpacing = std::max( thisBlockMetrics.maxLineSpacing, imageHeight + fm.leading() / scaleFactor );
 
  456      thisBlockMetrics.maxBlockLeading = std::max( thisBlockMetrics.maxBlockLeading, fm.leading() / scaleFactor );
 
  457      thisBlockMetrics.maxBlockMaxWidth = std::max( thisBlockMetrics.maxBlockMaxWidth, imageWidth );
 
  458      thisBlockMetrics.maxBlockFixedItemHeight = std::max( thisBlockMetrics.maxBlockFixedItemHeight, imageHeight );
 
  459      thisBlockMetrics.fragmentFixedHeights << imageHeight;
 
  460      updateCommonBlockMetrics( thisBlockMetrics, imageWidth, fragment );
 
  461      currentOutputBlock.
append( fragment );
 
  465      const double fragmentHeightUsingAscentDescent = ( fm.ascent() + fm.descent() ) / scaleFactor;
 
  466      const double fragmentHeightUsingLineSpacing = fm.lineSpacing() / scaleFactor;
 
  468      auto finalizeTextFragment = [fragmentHeightUsingAscentDescent,
 
  469                                   fragmentHeightUsingLineSpacing,
 
  473                                   &updateCommonBlockMetrics
 
  476        thisBlockMetrics.blockHeightUsingAscentDescent = std::max( thisBlockMetrics.blockHeightUsingAscentDescent, fragmentHeightUsingAscentDescent );
 
  478        thisBlockMetrics.blockHeightUsingLineSpacing = std::max( thisBlockMetrics.blockHeightUsingLineSpacing, fragmentHeightUsingLineSpacing );
 
  479        const double ascent = fm.ascent() / scaleFactor;
 
  480        thisBlockMetrics.fragmentAscent << ascent;
 
  481        thisBlockMetrics.maxBlockAscent = std::max( thisBlockMetrics.maxBlockAscent, ascent );
 
  482        thisBlockMetrics.maxBlockAscentForTextFragments = std::max( thisBlockMetrics.maxBlockAscentForTextFragments, ascent );
 
  484        thisBlockMetrics.maxBlockCapHeight = std::max( thisBlockMetrics.maxBlockCapHeight, fm.capHeight() / scaleFactor );
 
  486        const double descent = fm.descent() / scaleFactor;
 
  487        thisBlockMetrics.fragmentDescent << descent;
 
  489        thisBlockMetrics.maxBlockDescent = std::max( thisBlockMetrics.maxBlockDescent, descent );
 
  490        thisBlockMetrics.maxBlockMaxWidth = std::max( thisBlockMetrics.maxBlockMaxWidth, fm.maxWidth() / scaleFactor );
 
  492        if ( ( fm.lineSpacing() / scaleFactor ) > thisBlockMetrics.maxLineSpacing )
 
  494          thisBlockMetrics.maxLineSpacing = fm.lineSpacing() / scaleFactor;
 
  495          thisBlockMetrics.maxBlockLeading = fm.leading() / scaleFactor;
 
  497        thisBlockMetrics.fragmentFixedHeights << -1;
 
  498        updateCommonBlockMetrics( thisBlockMetrics, fragmentWidth, fragment );
 
  499        currentOutputBlock.append( fragment );
 
  502      double fragmentWidth = fm.horizontalAdvance( fragment.text() ) / scaleFactor;
 
  506           && ( thisBlockMetrics.blockXMax + fragmentWidth > documentContext.
maximumWidth() ) )
 
  511        const QStringList words = fragment.text().split( 
' ' );
 
  512        QStringList linesToProcess;
 
  513        QStringList wordsInCurrentLine;
 
  514        double remainingWidthInCurrentLine = documentContext.
maximumWidth() - thisBlockMetrics.blockXMax;
 
  515        for ( 
const QString &word : words )
 
  517          const double wordWidth = fm.horizontalAdvance( word ) / scaleFactor;
 
  518          if ( wordWidth > remainingWidthInCurrentLine )
 
  521            if ( !wordsInCurrentLine.isEmpty() )
 
  522              linesToProcess << wordsInCurrentLine.join( 
' ' );
 
  523            wordsInCurrentLine.clear();
 
  524            linesToProcess << word;
 
  525            remainingWidthInCurrentLine = documentContext.
maximumWidth();
 
  529            wordsInCurrentLine.append( word );
 
  532        if ( !wordsInCurrentLine.isEmpty() )
 
  533          linesToProcess << wordsInCurrentLine.join( 
' ' );
 
  535        remainingWidthInCurrentLine = documentContext.
maximumWidth() - thisBlockMetrics.blockXMax;
 
  536        for ( 
int lineIndex = 0; lineIndex < linesToProcess.size(); ++lineIndex )
 
  538          QString remainingText = linesToProcess.at( lineIndex );
 
  539          int lastPos = remainingText.lastIndexOf( 
' ' );
 
  540          while ( lastPos > -1 )
 
  543            if ( ( fm.horizontalAdvance( remainingText ) / scaleFactor ) <= remainingWidthInCurrentLine )
 
  548            const double widthTextToLastPos = fm.horizontalAdvance( remainingText.left( lastPos ) ) / scaleFactor;
 
  549            if ( widthTextToLastPos <= remainingWidthInCurrentLine )
 
  553              thisLineFragment.
setText( remainingText.left( lastPos ) );
 
  554              finalizeTextFragment( thisBlockMetrics, thisLineFragment, widthTextToLastPos );
 
  556              finalizeBlock( res, format, documentMetrics, currentOutputBlock, thisBlockMetrics );
 
  557              thisBlockMetrics.isFirstBlock = 
false;
 
  558              remainingWidthInCurrentLine = documentContext.
maximumWidth();
 
  559              remainingText = remainingText.mid( lastPos + 1 );
 
  562            lastPos = remainingText.lastIndexOf( 
' ', lastPos - 1 );
 
  566          if ( ( fm.horizontalAdvance( remainingText ) / scaleFactor ) > remainingWidthInCurrentLine && !currentOutputBlock.empty() )
 
  568            finalizeBlock( res, format, documentMetrics, currentOutputBlock, thisBlockMetrics );
 
  569            thisBlockMetrics.isFirstBlock = 
false;
 
  570            remainingWidthInCurrentLine = documentContext.
maximumWidth();
 
  575          thisLineFragment.
setText( remainingText );
 
  576          finalizeTextFragment( thisBlockMetrics, thisLineFragment, fm.horizontalAdvance( remainingText ) / scaleFactor );
 
  578          if ( lineIndex < linesToProcess.size() - 1 )
 
  581            finalizeBlock( res, format, documentMetrics, currentOutputBlock, thisBlockMetrics );
 
  582            thisBlockMetrics.isFirstBlock = 
false;
 
  583            remainingWidthInCurrentLine = documentContext.
maximumWidth();
 
  590        finalizeTextFragment( thisBlockMetrics, fragment, fragmentWidth );
 
  600  const QFont font = format.
scaledFont( context, scaleFactor, &res.mIsNullSize );
 
  613  const QList< QgsTextFormat::Tab > tabPositions = format.
tabPositions();
 
  619      ? tab.position() * font.pixelSize() / scaleFactor
 
  626  res.mFragmentFonts.reserve( documentMetrics.
blockSize );
 
  628  for ( 
int blockIndex = 0; blockIndex < documentMetrics.
blockSize; blockIndex++ )
 
  635    const int fragmentSize = block.
size();
 
  670    for ( 
int fragmentIndex = 0; fragmentIndex < fragmentSize; ++fragmentIndex )
 
  673      processFragment( res, format, context, documentContext, scaleFactor, documentMetrics, thisBlockMetrics, font, fragment, outputBlock );
 
  676    finalizeBlock( res, format, documentMetrics, outputBlock, thisBlockMetrics );
 
  688  if ( !res.mBaselineOffsetsLabelMode.isEmpty() )
 
  690    const double labelModeBaselineAdjust = res.mBaselineOffsetsLabelMode.constLast() + res.mLastLineAscentOffset;
 
  691    const double pointModeBaselineAdjust = res.mBaselineOffsetsPointMode.constLast();
 
  692    for ( 
int i = 0; i < documentMetrics.
blockSize; ++i )
 
  694      res.mBaselineOffsetsLabelMode[i] -= labelModeBaselineAdjust;
 
  695      res.mBaselineOffsetsPointMode[i] -= pointModeBaselineAdjust;
 
  699  if ( !res.mBlockMaxCharacterWidth.isEmpty() )
 
  701    QList< double > adjustedRightToLeftXOffsets;
 
  702    double currentOffset = 0;
 
  703    const int size = res.mBlockMaxCharacterWidth.size();
 
  705    double widthVerticalOrientation = 0;
 
  706    for ( 
int i = 0; i < size; ++i )
 
  708      const double rightToLeftBlockMaxCharacterWidth = res.mBlockMaxCharacterWidth[size - 1 - i ];
 
  711      adjustedRightToLeftXOffsets << currentOffset;
 
  712      currentOffset += rightToLeftLineSpacing;
 
  715        widthVerticalOrientation += rightToLeftBlockMaxCharacterWidth;
 
  717        widthVerticalOrientation += rightToLeftLineSpacing;
 
  719    std::reverse( adjustedRightToLeftXOffsets.begin(), adjustedRightToLeftXOffsets.end() );
 
  720    res.mVerticalOrientationXOffsets = adjustedRightToLeftXOffsets;
 
 
  738  switch ( orientation )
 
  745          return mDocumentSizePointRectMode;
 
  748          return mDocumentSizeCapHeightMode;
 
  751          return mDocumentSizeAscentMode;
 
  754          return mDocumentSizeLabelMode;
 
  759      return mDocumentSizeVerticalOrientation;
 
 
  769  switch ( orientation )
 
  781          return mOuterBoundsLabelMode;
 
 
  795  return mBlockWidths.value( blockIndex );
 
 
  800  return mBlockHeights.value( blockIndex );
 
 
  805  return mFirstLineCapHeight;
 
 
  810  double verticalAdjustmentForBlockMargins = 0;
 
  811  for ( 
int i = 0; i < blockIndex; ++i )
 
  813    double marginBeforeBlock = 0;
 
  814    verticalAdjustmentForBlockMargins += marginBeforeBlock;
 
  820      return mBaselineOffsetsRectMode.value( blockIndex ) + verticalAdjustmentForBlockMargins;
 
  822      return mBaselineOffsetsCapHeightMode.value( blockIndex ) + verticalAdjustmentForBlockMargins;
 
  824      return mBaselineOffsetsAscentBased.value( blockIndex ) + verticalAdjustmentForBlockMargins;
 
  826      return mBaselineOffsetsPointMode.value( blockIndex ) + verticalAdjustmentForBlockMargins;
 
  828      return mBaselineOffsetsLabelMode.value( blockIndex ) + verticalAdjustmentForBlockMargins;
 
 
  835  return mFragmentHorizontalAdvance.value( blockIndex ).value( fragmentIndex );
 
 
  845      return mFragmentVerticalOffsetsRectMode.value( blockIndex ).value( fragmentIndex );
 
  847      return mFragmentVerticalOffsetsPointMode.value( blockIndex ).value( fragmentIndex );
 
  849      return mFragmentVerticalOffsetsLabelMode.value( blockIndex ).value( fragmentIndex );
 
 
  856  return mFragmentFixedHeights.value( blockIndex ).value( fragmentIndex );
 
 
  861  return mFragmentAscent.value( blockIndex ).value( fragmentIndex );
 
 
  866  return mFragmentDescent.value( blockIndex ).value( fragmentIndex );
 
 
  871  return mVerticalOrientationXOffsets.value( blockIndex );
 
 
  876  return mBlockMaxCharacterWidth.value( blockIndex );
 
 
  881  return mBlockMaxDescent.value( blockIndex );
 
 
  886  return mBlockMaxAscent.value( blockIndex );
 
 
  891  return mFragmentFonts.value( blockIndex ).value( fragmentIndex );
 
 
  896  if ( blockIndex < 0 )
 
  897    return mVerticalMarginsBetweenBlocks.value( 0 );
 
  899  return mVerticalMarginsBetweenBlocks.value( blockIndex + 1 );
 
 
  904  return mLeftBlockMargins.value( blockIndex );
 
 
  909  return mRightBlockMargins.value( blockIndex );
 
 
TextLayoutMode
Text layout modes.
 
@ Labeling
Labeling-specific layout mode.
 
@ Point
Text at point of origin layout mode.
 
@ RectangleAscentBased
Similar to Rectangle mode, but uses ascents only when calculating font and line heights.
 
@ RectangleCapHeightBased
Similar to Rectangle mode, but uses cap height only when calculating font heights for the first line ...
 
@ Rectangle
Text within rectangle layout mode.
 
TextOrientation
Text orientations.
 
@ Vertical
Vertically oriented text.
 
@ RotationBased
Horizontally or vertically oriented text based on rotation (only available for map labeling)
 
@ Horizontal
Horizontally oriented text.
 
@ Normal
Adjacent characters are positioned in the standard way for text in the writing system in use.
 
@ SubScript
Characters are placed below the base line for normal text.
 
@ SuperScript
Characters are placed above the base line for normal text.
 
@ Percentage
Percentage of another measurement (e.g., canvas size, feature size)
 
@ Points
Points (e.g., for font sizes)
 
@ RenderBlocking
Render and load remote sources in the same thread to ensure rendering remote sources (svg and images)...
 
@ WrapLines
Automatically wrap long lines of text.
 
static QgsImageCache * imageCache()
Returns the application's image cache, used for caching resampled versions of raster images.
 
QSize originalSize(const QString &path, bool blocking=false) const
Returns the original size (in pixels) of the image at the specified path.
 
double top() const
Returns the top margin.
 
double right() const
Returns the right margin.
 
double bottom() const
Returns the bottom margin.
 
double left() const
Returns the left margin.
 
Contains information about the context of a rendering operation.
 
double scaleFactor() const
Returns the scaling factor for the render to convert painter units to physical sizes.
 
double convertToPainterUnits(double size, Qgis::RenderUnit unit, const QgsMapUnitScale &scale=QgsMapUnitScale(), Qgis::RenderSubcomponentProperty property=Qgis::RenderSubcomponentProperty::Generic) const
Converts a size from the specified units to painter units (pixels).
 
Qgis::RenderContextFlags flags() const
Returns combination of flags used for rendering.
 
double lineHeight() const
Returns the line height in points, or NaN if the line height is not set and should be auto calculated...
 
double lineHeightPercentage() const
Returns the line height percentage size (as fraction of font size from 0.0 to 1.0),...
 
QgsMargins margins() const
Returns the block margins, in points.
 
Represents a block of text consisting of one or more QgsTextFragment objects.
 
int size() const
Returns the number of fragments in the block.
 
const QgsTextBlockFormat & blockFormat() const
Returns the block formatting for the fragment.
 
void clear()
Clears the block, removing all its contents.
 
void reserve(int count)
Reserves the specified count of fragments for optimised fragment appending.
 
void setBlockFormat(const QgsTextBlockFormat &format)
Sets the block format for the fragment.
 
void append(const QgsTextFragment &fragment)
Appends a fragment to the block.
 
const QgsTextFragment & at(int index) const
Returns the fragment at the specified index.
 
bool empty() const
Returns true if the block is empty.
 
Stores information relating to individual character formatting.
 
void updateFontForFormat(QFont &font, const QgsRenderContext &context, double scaleFactor=1.0) const
Updates the specified font in place, applying character formatting options which are applicable on a ...
 
QSizeF imageSize() const
Returns the image size, if the format applies to a document image fragment.
 
QString imagePath() const
Returns the path to the image to render, if the format applies to a document image fragment.
 
Qgis::TextCharacterVerticalAlignment verticalAlignment() const
Returns the format vertical alignment.
 
bool hasVerticalAlignmentSet() const
Returns true if the format has an explicit vertical alignment set.
 
double fontPointSize() const
Returns the font point size, or -1 if the font size is not set and should be inherited.
 
Contains pre-calculated metrics of a QgsTextDocument.
 
double verticalOrientationXOffset(int blockIndex) const
Returns the vertical orientation x offset for the specified block.
 
double fragmentVerticalOffset(int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const
Returns the vertical offset from a text block's baseline which should be applied to the fragment at t...
 
double blockMaximumDescent(int blockIndex) const
Returns the maximum descent encountered in the specified block.
 
double fragmentDescent(int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const
Returns the descent of the fragment at the specified block and fragment index.
 
QSizeF documentSize(Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const
Returns the overall size of the document.
 
double blockRightMargin(int blockIndex) const
Returns the margin for the right side of the specified block index.
 
double firstLineCapHeight() const
Returns the cap height for the first line of text.
 
static QgsTextDocumentMetrics calculateMetrics(const QgsTextDocument &document, const QgsTextFormat &format, const QgsRenderContext &context, double scaleFactor=1.0, const QgsTextDocumentRenderContext &documentContext=QgsTextDocumentRenderContext())
Returns precalculated text metrics for a text document, when rendered using the given base format and...
 
QFont fragmentFont(int blockIndex, int fragmentIndex) const
Returns the calculated font for the fragment at the specified block and fragment indices.
 
double blockMaximumCharacterWidth(int blockIndex) const
Returns the maximum character width for the specified block.
 
double baselineOffset(int blockIndex, Qgis::TextLayoutMode mode) const
Returns the offset from the top of the document to the text baseline for the given block index.
 
double fragmentFixedHeight(int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const
Returns the fixed height of the fragment at the specified block and fragment index,...
 
QRectF outerBounds(Qgis::TextLayoutMode mode, Qgis::TextOrientation orientation) const
Returns the outer bounds of the document, which is the documentSize() adjusted to account for any tex...
 
double blockLeftMargin(int blockIndex) const
Returns the margin for the left side of the specified block index.
 
double blockMaximumAscent(int blockIndex) const
Returns the maximum ascent encountered in the specified block.
 
double fragmentAscent(int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const
Returns the ascent of the fragment at the specified block and fragment index.
 
double blockHeight(int blockIndex) const
Returns the height of the block at the specified index.
 
double fragmentHorizontalAdvance(int blockIndex, int fragmentIndex, Qgis::TextLayoutMode mode) const
Returns the horizontal advance of the fragment at the specified block and fragment index.
 
bool isNullFontSize() const
Returns true if the metrics could not be calculated because the text format has a null font size.
 
const QgsTextDocument & document() const
Returns the document associated with the calculated metrics.
 
double blockWidth(int blockIndex) const
Returns the width of the block at the specified index.
 
double blockVerticalMargin(int blockIndex) const
Returns the vertical margin for the specified block index.
 
Encapsulates the context in which a text document is to be rendered.
 
Qgis::TextRendererFlags flags() const
Returns associated text renderer flags.
 
double maximumWidth() const
Returns the maximum width (in painter units) for rendered text.
 
Represents a document consisting of one or more QgsTextBlock objects.
 
const QgsTextBlock & at(int index) const
Returns the block at the specified index.
 
void reserve(int count)
Reserves the specified count of blocks for optimised block appending.
 
int size() const
Returns the number of blocks in the document.
 
void append(const QgsTextBlock &block)
Appends a block to the document.
 
Defines a tab position for a text format.
 
Container for all settings relating to text rendering.
 
QList< QgsTextFormat::Tab > tabPositions() const
Returns the list of tab positions for tab stops.
 
double lineHeight() const
Returns the line height for text.
 
double tabStopDistance() const
Returns the distance for tab stops.
 
QFont scaledFont(const QgsRenderContext &context, double scaleFactor=1.0, bool *isZeroSize=nullptr) const
Returns a font with the size scaled to match the format's size settings (including units and map unit...
 
Qgis::RenderUnit lineHeightUnit() const
Returns the units for the line height for text.
 
Qgis::RenderUnit tabStopDistanceUnit() const
Returns the units for the tab stop distance.
 
QgsMapUnitScale tabStopDistanceMapUnitScale() const
Returns the map unit scale object for the tab stop distance.
 
Stores a fragment of document along with formatting overrides to be used when rendering the fragment.
 
void setText(const QString &text)
Sets the text content of the fragment.
 
QString text() const
Returns the text content of the fragment.
 
void setCharacterFormat(const QgsTextCharacterFormat &format)
Sets the character format for the fragment.
 
const QgsTextCharacterFormat & characterFormat() const
Returns the character formatting for the fragment.
 
bool isImage() const
Returns true if the fragment represents an image.
 
bool isTab() const
Returns true if the fragment consists of just a tab character.
 
static constexpr double SUPERSCRIPT_SUBSCRIPT_FONT_SIZE_SCALING_FACTOR
Scale factor to use for super or subscript text which doesn't have an explicit font size set.
 
#define BUILTIN_UNREACHABLE
 
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
 
constexpr double SUPERSCRIPT_VERTICAL_BASELINE_ADJUSTMENT_FACTOR
 
constexpr double SUBSCRIPT_VERTICAL_BASELINE_ADJUSTMENT_FACTOR
 
double maxBlockFixedItemHeight
 
double maxBlockAscentForTextFragments
 
void resetCalculatedStats()
 
double blockHeightUsingLineSpacing
 
QList< QFont > fragmentFonts
 
QList< double > fragmentDescent
 
QList< double > fragmentFixedHeights
 
double lineHeightPainterUnits
 
QList< double > fragmentHorizontalAdvance
 
bool isFirstNonTabFragment
 
double blockHeightUsingAscentDescent
 
QFont previousNonSuperSubScriptFont
 
double blockHeightUsingAscentAccountingForVerticalOffset
 
QList< double > fragmentAscent
 
QList< double > fragmentVerticalOffsets
 
double blockYMaxAdjustLabel
 
double lineHeightPercentage
 
double blockHeightVerticalOrientation
 
double heightVerticalOrientation
 
double tabStopDistancePainterUnits
 
QList< double > tabStopDistancesPainterUnits
 
QVector< double > blockRightMargin
 
double heightCapHeightMode
 
double currentCapHeightBasedBaseline
 
QVector< double > blockLeftMargin
 
double currentLabelBaseline
 
QVector< double > blockVerticalLineSpacing
 
double currentRectBaseline
 
QVector< double > verticalMarginsBetweenBlocks
Calculated vertical margins between blocks.
 
double currentPointBaseline
 
double heightPointRectMode
 
double currentAscentBasedBaseline