QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Stores information relating to individual character formatting. More...
#include <qgstextcharacterformat.h>
Public Types | |
enum class | BooleanValue { NotSet , SetTrue , SetFalse } |
Status values for boolean format properties. More... | |
Public Member Functions | |
QgsTextCharacterFormat ()=default | |
QgsTextCharacterFormat (const QTextCharFormat &format) | |
Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat format. | |
QString | family () const |
Returns the font family name, or an empty string if the family is not set and should be inherited. | |
double | fontPercentageSize () const |
Returns the font percentage size (as fraction of inherited font size), or -1 if the font size percentage is not set. | |
double | fontPointSize () const |
Returns the font point size, or -1 if the font size is not set and should be inherited. | |
int | fontWeight () const |
Returns the font weight, or -1 if the font weight is not set and should be inherited. | |
bool | hasVerticalAlignmentSet () const |
Returns true if the format has an explicit vertical alignment set. | |
QString | imagePath () const |
Returns the path to the image to render, if the format applies to a document image fragment. | |
QSizeF | imageSize () const |
Returns the image size, if the format applies to a document image fragment. | |
BooleanValue | italic () const |
Returns whether the format has italic enabled. | |
BooleanValue | overline () const |
Returns whether the format has overline enabled. | |
void | overrideWith (const QgsTextCharacterFormat &other) |
Override all the default/unset properties of the current character format with the settings from another format. | |
void | setFamily (const QString &family) |
Sets the font family name. | |
void | setFontPercentageSize (double size) |
Sets the font percentage size (as fraction of inherited font size). | |
void | setFontPointSize (double size) |
Sets the font point size. | |
void | setFontWeight (int fontWeight) |
Sets the font weight. | |
void | setHasVerticalAlignmentSet (bool set) |
Sets whether the format has an explicit vertical alignment set. | |
void | setImagePath (const QString &path) |
Sets the path to the image to render, if the format applies to a document image fragment. | |
void | setImageSize (const QSizeF &size) |
Sets the image size, if the format applies to a document image fragment. | |
void | setItalic (BooleanValue enabled) |
Sets whether the format has italic enabled. | |
void | setOverline (BooleanValue enabled) |
Sets whether the format has overline enabled. | |
void | setStrikeOut (BooleanValue enabled) |
Sets whether the format has strikethrough enabled. | |
void | setTextColor (const QColor &textColor) |
Sets the character's text color. | |
void | setUnderline (BooleanValue enabled) |
Sets whether the format has underline enabled. | |
void | setVerticalAlignment (Qgis::TextCharacterVerticalAlignment alignment) |
Sets the format vertical alignment. | |
void | setWordSpacing (double spacing) |
Sets the font word spacing, in points, or NaN if word spacing is not set and should be inherited. | |
BooleanValue | strikeOut () const |
Returns whether the format has strikethrough enabled. | |
QColor | textColor () const |
Returns the character's text color, or an invalid color if no color override is set and the default format color should be used. | |
BooleanValue | underline () const |
Returns whether the format has underline enabled. | |
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 font level when rendered in the given context. | |
Qgis::TextCharacterVerticalAlignment | verticalAlignment () const |
Returns the format vertical alignment. | |
double | wordSpacing () const |
Returns the font word spacing, in points, or NaN if word spacing is not set and should be inherited. | |
Stores information relating to individual character formatting.
These options encapsulate formatting options which override the default settings from a QgsTextFormat for individual characters (or sets of characters).
Definition at line 42 of file qgstextcharacterformat.h.
|
strong |
Status values for boolean format properties.
Enumerator | |
---|---|
NotSet | Property is not set. |
SetTrue | Property is set and |
SetFalse | Property is set and |
Definition at line 54 of file qgstextcharacterformat.h.
|
default |
QgsTextCharacterFormat::QgsTextCharacterFormat | ( | const QTextCharFormat & | format | ) |
Constructor for QgsTextCharacterFormat, based on the specified QTextCharFormat format.
Definition at line 45 of file qgstextcharacterformat.cpp.
QString QgsTextCharacterFormat::family | ( | ) | const |
Returns the font family name, or an empty string if the family is not set and should be inherited.
Definition at line 137 of file qgstextcharacterformat.cpp.
double QgsTextCharacterFormat::fontPercentageSize | ( | ) | const |
Returns the font percentage size (as fraction of inherited font size), or -1 if the font size percentage is not set.
Definition at line 127 of file qgstextcharacterformat.cpp.
double QgsTextCharacterFormat::fontPointSize | ( | ) | const |
Returns the font point size, or -1 if the font size is not set and should be inherited.
Definition at line 117 of file qgstextcharacterformat.cpp.
int QgsTextCharacterFormat::fontWeight | ( | ) | const |
Returns the font weight, or -1 if the font weight is not set and should be inherited.
Definition at line 265 of file qgstextcharacterformat.cpp.
|
inline |
Returns true
if the format has an explicit vertical alignment set.
If false
is returned then the vertical alignment will be inherited.
Definition at line 315 of file qgstextcharacterformat.h.
QString QgsTextCharacterFormat::imagePath | ( | ) | const |
Returns the path to the image to render, if the format applies to a document image fragment.
Definition at line 177 of file qgstextcharacterformat.cpp.
QSizeF QgsTextCharacterFormat::imageSize | ( | ) | const |
Returns the image size, if the format applies to a document image fragment.
The image size is always considered to be in Qgis::RenderUnit::Points.
Definition at line 187 of file qgstextcharacterformat.cpp.
QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::italic | ( | ) | const |
Returns whether the format has italic enabled.
Definition at line 255 of file qgstextcharacterformat.cpp.
QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::overline | ( | ) | const |
Returns whether the format has overline enabled.
Definition at line 167 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::overrideWith | ( | const QgsTextCharacterFormat & | other | ) |
Override all the default/unset properties of the current character format with the settings from another format.
This will replace any default/unset existing settings with the settings from other.
Any settings which are default/unset in other will be left unchanged.
other | The format to override with. |
Definition at line 76 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setFamily | ( | const QString & | family | ) |
Sets the font family name.
Set to an empty string if the family should be inherited.
Definition at line 142 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setFontPercentageSize | ( | double | size | ) |
Sets the font percentage size (as fraction of inherited font size).
Set size to -1 if the font percentange size is not set.
Definition at line 132 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setFontPointSize | ( | double | size | ) |
Sets the font point size.
Set size to -1 if the font size is not set and should be inherited.
Definition at line 122 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setFontWeight | ( | int | fontWeight | ) |
Sets the font weight.
Set weight to -1 if the font weight is not set and should be inherited.
Definition at line 270 of file qgstextcharacterformat.cpp.
|
inline |
Sets whether the format has an explicit vertical alignment set.
If set is false
then the vertical alignment will be inherited.
Definition at line 327 of file qgstextcharacterformat.h.
void QgsTextCharacterFormat::setImagePath | ( | const QString & | path | ) |
Sets the path to the image to render, if the format applies to a document image fragment.
Definition at line 182 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setImageSize | ( | const QSizeF & | size | ) |
Sets the image size, if the format applies to a document image fragment.
The image size is always considered to be in Qgis::RenderUnit::Points.
Definition at line 192 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setItalic | ( | QgsTextCharacterFormat::BooleanValue | enabled | ) |
Sets whether the format has italic enabled.
Definition at line 260 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setOverline | ( | QgsTextCharacterFormat::BooleanValue | enabled | ) |
Sets whether the format has overline enabled.
Definition at line 172 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setStrikeOut | ( | BooleanValue | enabled | ) |
Sets whether the format has strikethrough enabled.
Definition at line 152 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setTextColor | ( | const QColor & | textColor | ) |
Sets the character's text color.
Set color to an invalid color if no color override is desired and the default format color should be used.
Definition at line 112 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::setUnderline | ( | BooleanValue | enabled | ) |
Sets whether the format has underline enabled.
Definition at line 162 of file qgstextcharacterformat.cpp.
|
inline |
Sets the format vertical alignment.
This property is only respected if hasVerticalAlignmentSet() is true
.
Definition at line 351 of file qgstextcharacterformat.h.
void QgsTextCharacterFormat::setWordSpacing | ( | double | spacing | ) |
Sets the font word spacing, in points, or NaN if word spacing is not set and should be inherited.
Definition at line 280 of file qgstextcharacterformat.cpp.
QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::strikeOut | ( | ) | const |
Returns whether the format has strikethrough enabled.
Definition at line 147 of file qgstextcharacterformat.cpp.
QColor QgsTextCharacterFormat::textColor | ( | ) | const |
Returns the character's text color, or an invalid color if no color override is set and the default format color should be used.
Definition at line 107 of file qgstextcharacterformat.cpp.
QgsTextCharacterFormat::BooleanValue QgsTextCharacterFormat::underline | ( | ) | const |
Returns whether the format has underline enabled.
Definition at line 157 of file qgstextcharacterformat.cpp.
void QgsTextCharacterFormat::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 font level when rendered in the given context.
The optional scaleFactor parameter can specify a font size scaling factor. It is recommended to set this to QgsTextRenderer::calculateScaleFactorForFormat() and then manually calculations based on the resultant font metrics. Failure to do so will result in poor quality text rendering at small font sizes.
Definition at line 197 of file qgstextcharacterformat.cpp.
|
inline |
Returns the format vertical alignment.
This property is only respected if hasVerticalAlignmentSet() is true
.
Definition at line 339 of file qgstextcharacterformat.h.
double QgsTextCharacterFormat::wordSpacing | ( | ) | const |
Returns the font word spacing, in points, or NaN if word spacing is not set and should be inherited.
Definition at line 275 of file qgstextcharacterformat.cpp.