68 if ( maxinangle < 20.0 )
70 if ( 60.0 < maxinangle )
72 if ( maxoutangle > -20.0 )
74 if ( -95.0 > maxoutangle )
79 double labelHeight = mapScale * fm->height();
93 for (
const QString &grapheme : graphemes )
108 for (
int i = 0; i <
mClusters.count(); i++ )
112 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
115 charWidth = fm->horizontalAdvance(
mClusters[i] );
117 if ( curvedLabeling )
119 wordSpaceFix = qreal( 0.0 );
120 if (
mClusters[i] == QLatin1String(
" " ) )
124 wordSpaceFix = ( nxt <
mClusters.count() &&
mClusters[nxt] != QLatin1String(
" " ) ) ? wordSpacing : qreal( 0.0 );
128 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
137 wordSpaceFix -= wordSpacing;
140 #if QT_VERSION < QT_VERSION_CHECK(5, 11, 0)
141 charWidth = fm->width( QString(
mClusters[i] ) ) + wordSpaceFix;
143 charWidth = fm->horizontalAdvance( QString(
mClusters[i] ) ) + wordSpaceFix;
147 double labelWidth = mapScale * charWidth;
The QgsLabelFeature class describes a feature that should be used within the labeling engine.
pal::LabelInfo * mInfo
extra information for curved labels (may be nullptr)
QString mLabelText
text of the label
Perform transforms between map coordinates and device coordinates.
double mapUnitsPerPixel() const
Returns current map units per pixel.
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...
Represents a block of text consisting of one or more QgsTextFragment objects.
Stores information relating to individual character formatting.
Represents a document consisting of one or more QgsTextBlock objects.
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
QgsTextLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Construct text label feature.
void setDocument(const QgsTextDocument &document)
Sets the document for the label.
QList< QgsTextCharacterFormat > mCharacterFormats
QStringList mClusters
List of graphemes (used for curved labels)
QgsTextDocument document() const
Returns the document for the label.
QFontMetricsF * mFontMetrics
Metrics of the font for rendering.
QgsTextDocument mDocument
QgsTextCharacterFormat characterFormat(int partId) const
Returns the character format corresponding to the specified label part.
QFont mDefinedFont
Font for rendering.
void calculateInfo(bool curvedLabeling, QFontMetricsF *fm, const QgsMapToPixel *xform, double fontScale, double maxinangle, double maxoutangle)
calculate data for info(). setDefinedFont() must have been called already.
QString text(int partId) const
Returns the text component corresponding to a specified label part.
bool hasCharacterFormat(int partId) const
Returns true if the feature contains specific character formatting for the part with matching ID.
~QgsTextLabelFeature()
Clean up.
Optional additional info about label (for curved labels)
CharacterInfo * char_info
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features