QGIS API Documentation
3.16.0-Hannover (43b64b13f3)
|
Go to the documentation of this file.
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;
void setDocument(const QgsTextDocument &document)
Sets the document for the label.
QString text(int partId) const
Returns the text component corresponding to a specified label part.
Optional additional info about label (for curved labels)
double mapUnitsPerPixel() const
Returns current map units per pixel.
bool hasCharacterFormat(int partId) const
Returns true if the feature contains specific character formatting for the part with matching ID.
~QgsTextLabelFeature()
Clean up.
QFontMetricsF * mFontMetrics
Metrics of the font for rendering.
QgsTextCharacterFormat characterFormat(int partId) const
Returns the character format corresponding to the specified label part.
QFont mDefinedFont
Font for rendering.
Stores information relating to individual character formatting.
QStringList mClusters
List of graphemes (used for curved labels)
std::unique_ptr< GEOSGeometry, GeosDeleter > unique_ptr
Scoped GEOS pointer.
QList< QgsTextCharacterFormat > mCharacterFormats
Stores a fragment of text along with formatting overrides to be used when rendering the fragment.
bool qgsDoubleNear(double a, double b, double epsilon=4 *std::numeric_limits< double >::epsilon())
Compare two doubles (but allow some difference)
QString mLabelText
text of the label
QgsTextDocument mDocument
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.
Represents a block of text consisting of one or more QgsTextFragment objects.
CharacterInfo * char_info
Perform transforms between map coordinates and device coordinates.
Represents a document consisting of one or more QgsTextBlock objects.
QgsTextDocument document() const
Returns the document for the label.
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)
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
QgsTextLabelFeature(QgsFeatureId id, GEOSGeometry *geometry, const QSizeF &size)
Construct text label feature.
static QStringList splitToGraphemes(const QString &text)
Splits a text string to a list of graphemes, which are the smallest allowable character divisions in ...