19#include <QTextBlockFormat>
24 set = format.hasProperty( QTextFormat::BlockAlignment );
25 if ( format.alignment() & Qt::AlignLeft )
29 else if ( format.alignment() & Qt::AlignRight )
33 else if ( format.alignment() & Qt::AlignHCenter )
37 else if ( format.alignment() & Qt::AlignJustify )
47 : mLineHeight( format.hasProperty( QTextFormat::LineHeight ) && format.lineHeightType() != QTextBlockFormat::ProportionalHeight ? format.lineHeight() : std::numeric_limits< double >::quiet_NaN() )
48 , mLineHeightPercentage( format.hasProperty( QTextFormat::LineHeight ) && format.lineHeightType() == QTextBlockFormat::ProportionalHeight ? ( format.lineHeight() / 100.0 ) : std::numeric_limits< double >::quiet_NaN() )
52 const double topMargin = format.hasProperty( QTextFormat::BlockTopMargin ) ? format.topMargin() : std::numeric_limits< double >::quiet_NaN();
53 const double leftMargin = format.hasProperty( QTextFormat::BlockLeftMargin ) ? format.leftMargin() : std::numeric_limits< double >::quiet_NaN();
54 const double rightMargin = format.hasProperty( QTextFormat::BlockRightMargin ) ? format.rightMargin() : std::numeric_limits< double >::quiet_NaN();
55 const double bottomMargin = format.hasProperty( QTextFormat::BlockBottomMargin ) ? format.bottomMargin() : std::numeric_limits< double >::quiet_NaN();
56 mMargins =
QgsMargins( leftMargin, topMargin, rightMargin, bottomMargin );
63 mHorizontalAlign = other.mHorizontalAlign;
64 mHasHorizontalAlignSet =
true;
67 if ( std::isnan( mLineHeight ) )
68 mLineHeight = other.mLineHeight;
69 if ( std::isnan( mLineHeightPercentage ) )
70 mLineHeightPercentage = other.mLineHeightPercentage;
72 if ( std::isnan( mMargins.
left() ) )
74 if ( std::isnan( mMargins.
right() ) )
76 if ( std::isnan( mMargins.
top() ) )
78 if ( std::isnan( mMargins.
bottom() ) )
94 return mLineHeightPercentage;
99 mLineHeightPercentage = height;
TextHorizontalAlignment
Text horizontal alignment.
The QgsMargins class defines the four margins of a rectangle.
void setBottom(double bottom)
Sets the bottom margin to bottom.
double top() const
Returns the top margin.
void setLeft(double left)
Sets the left margin to left.
double right() const
Returns the right margin.
double bottom() const
Returns the bottom margin.
void setRight(double right)
Sets the right margin to right.
void setTop(double top)
Sets the top margin to top.
double left() const
Returns the left margin.
Contains information about the context of a rendering operation.
Stores information relating to individual block formatting.
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),...
void overrideWith(const QgsTextBlockFormat &other)
Override all the default/unset properties of the current block format with the settings from another ...
void updateFontForFormat(QFont &font, const QgsRenderContext &context, double scaleFactor=1.0) const
Updates the specified font in place, applying block formatting options which are applicable on a font...
bool hasHorizontalAlignmentSet() const
Returns true if the format has an explicit horizontal alignment set.
void setLineHeightPercentage(double height)
Sets the line height percentage height (as fraction of font size from 0.0 to 1.0).
QgsTextBlockFormat()=default
void setLineHeight(double height)
Sets the font line height, in points.
Qgis::TextHorizontalAlignment convertTextBlockFormatAlign(const QTextBlockFormat &format, bool &set)