QGIS API Documentation
3.12.1-București (121cc00ff0)
|
Container for all settings relating to text rendering. More...
#include <qgstextrenderer.h>
Public Types | |
enum | TextOrientation { HorizontalOrientation, VerticalOrientation, RotationBasedOrientation } |
Text orientation. More... | |
Public Member Functions | |
QgsTextFormat () | |
QgsTextFormat (const QgsTextFormat &other) | |
Copy constructor. More... | |
~QgsTextFormat () | |
QgsTextBackgroundSettings & | background () |
Returns a reference to the text background settings. More... | |
QgsTextBackgroundSettings | background () const |
Returns a reference to the text background settings. More... | |
QPainter::CompositionMode | blendMode () const |
Returns the blending mode used for drawing the text. More... | |
QgsTextBufferSettings & | buffer () |
Returns a reference to the text buffer settings. More... | |
QgsTextBufferSettings | buffer () const |
Returns a reference to the text buffer settings. More... | |
QColor | color () const |
Returns the color that text will be rendered in. More... | |
bool | containsAdvancedEffects () const |
Returns true if any component of the font format requires advanced effects such as blend modes, which require output in raster formats to be fully respected. More... | |
QgsPropertyCollection & | dataDefinedProperties () |
Returns a reference to the format's property collection, used for data defined overrides. More... | |
const QgsPropertyCollection & | dataDefinedProperties () const |
Returns a reference to the format's property collection, used for data defined overrides. More... | |
QFont | font () const |
Returns the font used for rendering text. More... | |
bool | fontFound () const |
Returns true if the specified font was found on the system, or false if the font was not found and a replacement was used instead. More... | |
double | lineHeight () const |
Returns the line height for text. More... | |
QgsTextMaskSettings & | mask () |
Returns a reference to the masking settings. More... | |
QgsTextMaskSettings | mask () const |
Returns a reference to the masking settings. More... | |
QString | namedStyle () const |
Returns the named style for the font used for rendering text (e.g., "bold"). More... | |
double | opacity () const |
Returns the text's opacity. More... | |
QgsTextFormat & | operator= (const QgsTextFormat &other) |
TextOrientation | orientation () const |
Returns the orientation of the text. More... | |
QColor | previewBackgroundColor () const |
Returns the background color for text previews. More... | |
void | readFromLayer (QgsVectorLayer *layer) |
Reads settings from a layer's custom properties (for QGIS 2.x projects). More... | |
void | readXml (const QDomElement &elem, const QgsReadWriteContext &context) |
Read settings from a DOM element. More... | |
QString | resolvedFontFamily () const |
Returns the family for the resolved font, ie if the specified font was not found on the system this will return the name of the replacement font. More... | |
QFont | scaledFont (const QgsRenderContext &context) const |
Returns a font with the size scaled to match the format's size settings (including units and map unit scale) for a specified render context. More... | |
void | setBackground (const QgsTextBackgroundSettings &backgroundSettings) |
Sets the text's background settings.q. More... | |
void | setBlendMode (QPainter::CompositionMode mode) |
Sets the blending mode used for drawing the text. More... | |
void | setBuffer (const QgsTextBufferSettings &bufferSettings) |
Sets the text's buffer settings. More... | |
void | setColor (const QColor &color) |
Sets the color that text will be rendered in. More... | |
void | setDataDefinedProperties (const QgsPropertyCollection &collection) |
Sets the format's property collection, used for data defined overrides. More... | |
void | setFont (const QFont &font) |
Sets the font used for rendering text. More... | |
void | setLineHeight (double height) |
Sets the line height for text. More... | |
void | setMask (const QgsTextMaskSettings &maskSettings) |
Sets the text's masking settings. More... | |
void | setNamedStyle (const QString &style) |
Sets the named style for the font used for rendering text. More... | |
void | setOpacity (double opacity) |
Sets the text's opacity. More... | |
void | setOrientation (TextOrientation orientation) |
Sets the orientation for the text. More... | |
void | setPreviewBackgroundColor (const QColor &color) |
Sets the background color that text will be rendered on for previews. More... | |
void | setShadow (const QgsTextShadowSettings &shadowSettings) |
Sets the text's drop shadow settings. More... | |
void | setSize (double size) |
Sets the size for rendered text. More... | |
void | setSizeMapUnitScale (const QgsMapUnitScale &scale) |
Sets the map unit scale object for the size. More... | |
void | setSizeUnit (QgsUnitTypes::RenderUnit unit) |
Sets the units for the size of rendered text. More... | |
QgsTextShadowSettings & | shadow () |
Returns a reference to the text drop shadow settings. More... | |
QgsTextShadowSettings | shadow () const |
Returns a reference to the text drop shadow settings. More... | |
double | size () const |
Returns the size for rendered text. More... | |
QgsMapUnitScale | sizeMapUnitScale () const |
Returns the map unit scale object for the size. More... | |
QgsUnitTypes::RenderUnit | sizeUnit () const |
Returns the units for the size of rendered text. More... | |
QMimeData * | toMimeData () const |
Returns new mime data representing the text format settings. More... | |
QFont | toQFont () const |
Returns a QFont matching the relevant settings from this text format. More... | |
void | updateDataDefinedProperties (QgsRenderContext &context) |
Updates the format by evaluating current values of data defined properties. More... | |
QDomElement | writeXml (QDomDocument &doc, const QgsReadWriteContext &context) const |
Write settings into a DOM element. More... | |
Static Public Member Functions | |
static QgsTextFormat | fromMimeData (const QMimeData *data, bool *ok=nullptr) |
Attempts to parse the provided mime data as a QgsTextFormat. More... | |
static QgsTextFormat | fromQFont (const QFont &font) |
Returns a text format matching the settings from an input font. More... | |
static QPixmap | textFormatPreviewPixmap (const QgsTextFormat &format, QSize size, const QString &previewText=QString(), int padding=0) |
Returns a pixmap preview for a text format. More... | |
Container for all settings relating to text rendering.
Definition at line 1203 of file qgstextrenderer.h.
Text orientation.
Definition at line 1208 of file qgstextrenderer.h.
QgsTextFormat::QgsTextFormat | ( | ) |
Definition at line 1774 of file qgstextrenderer.cpp.
QgsTextFormat::QgsTextFormat | ( | const QgsTextFormat & | other | ) |
Copy constructor.
other | source QgsTextFormat |
Definition at line 1779 of file qgstextrenderer.cpp.
QgsTextFormat::~QgsTextFormat | ( | ) |
Definition at line 1803 of file qgstextrenderer.cpp.
|
inline |
Returns a reference to the text background settings.
Definition at line 1250 of file qgstextrenderer.h.
|
inline |
Returns a reference to the text background settings.
Definition at line 1256 of file qgstextrenderer.h.
QPainter::CompositionMode QgsTextFormat::blendMode | ( | ) | const |
Returns the blending mode used for drawing the text.
Definition at line 1892 of file qgstextrenderer.cpp.
|
inline |
Returns a reference to the text buffer settings.
Definition at line 1231 of file qgstextrenderer.h.
|
inline |
Returns a reference to the text buffer settings.
Definition at line 1237 of file qgstextrenderer.h.
QColor QgsTextFormat::color | ( | ) | const |
Returns the color that text will be rendered in.
Definition at line 1872 of file qgstextrenderer.cpp.
bool QgsTextFormat::containsAdvancedEffects | ( | ) | const |
Returns true
if any component of the font format requires advanced effects such as blend modes, which require output in raster formats to be fully respected.
Definition at line 2285 of file qgstextrenderer.cpp.
QgsPropertyCollection & QgsTextFormat::dataDefinedProperties | ( | ) |
Returns a reference to the format's property collection, used for data defined overrides.
Definition at line 2302 of file qgstextrenderer.cpp.
const QgsPropertyCollection & QgsTextFormat::dataDefinedProperties | ( | ) | const |
Returns a reference to the format's property collection, used for data defined overrides.
Definition at line 2307 of file qgstextrenderer.cpp.
QFont QgsTextFormat::font | ( | ) | const |
Returns the font used for rendering text.
Note that the size of the font is not used, and size() should be called instead to determine the size of rendered text.
Definition at line 1808 of file qgstextrenderer.cpp.
|
inline |
Returns true
if the specified font was found on the system, or false
if the font was not found and a replacement was used instead.
Definition at line 1549 of file qgstextrenderer.h.
|
static |
Attempts to parse the provided mime data as a QgsTextFormat.
If data can be parsed as a text format, ok will be set to true
.
Definition at line 2257 of file qgstextrenderer.cpp.
|
static |
Returns a text format matching the settings from an input font.
Unlike setFont(), this method also handles the size and size units from font.
Definition at line 2208 of file qgstextrenderer.cpp.
double QgsTextFormat::lineHeight | ( | ) | const |
Returns the line height for text.
This is a number between 0.0 and 10.0 representing the leading between lines as a multiplier of line height.
Definition at line 1902 of file qgstextrenderer.cpp.
|
inline |
Returns a reference to the masking settings.
Definition at line 1288 of file qgstextrenderer.h.
|
inline |
Returns a reference to the masking settings.
Masks may be defined in contexts where the text is rendered over some map layers, for labeling especially.
Definition at line 1296 of file qgstextrenderer.h.
QString QgsTextFormat::namedStyle | ( | ) | const |
Returns the named style for the font used for rendering text (e.g., "bold").
Definition at line 1827 of file qgstextrenderer.cpp.
double QgsTextFormat::opacity | ( | ) | const |
Returns the text's opacity.
The opacity is a double value between 0 (fully transparent) and 1 (totally opaque).
Definition at line 1882 of file qgstextrenderer.cpp.
QgsTextFormat & QgsTextFormat::operator= | ( | const QgsTextFormat & | other | ) |
Definition at line 1791 of file qgstextrenderer.cpp.
QgsTextFormat::TextOrientation QgsTextFormat::orientation | ( | ) | const |
Returns the orientation of the text.
Definition at line 1912 of file qgstextrenderer.cpp.
QColor QgsTextFormat::previewBackgroundColor | ( | ) | const |
Returns the background color for text previews.
Definition at line 1922 of file qgstextrenderer.cpp.
void QgsTextFormat::readFromLayer | ( | QgsVectorLayer * | layer | ) |
Reads settings from a layer's custom properties (for QGIS 2.x projects).
layer | source vector layer |
Definition at line 1932 of file qgstextrenderer.cpp.
void QgsTextFormat::readXml | ( | const QDomElement & | elem, |
const QgsReadWriteContext & | context | ||
) |
Read settings from a DOM element.
Definition at line 2015 of file qgstextrenderer.cpp.
|
inline |
Returns the family for the resolved font, ie if the specified font was not found on the system this will return the name of the replacement font.
Definition at line 1557 of file qgstextrenderer.h.
QFont QgsTextFormat::scaledFont | ( | const QgsRenderContext & | context | ) | const |
Returns a font with the size scaled to match the format's size settings (including units and map unit scale) for a specified render context.
context | destination render context |
Definition at line 1813 of file qgstextrenderer.cpp.
|
inline |
Sets the text's background settings.q.
backgroundSettings | background settings |
Definition at line 1263 of file qgstextrenderer.h.
void QgsTextFormat::setBlendMode | ( | QPainter::CompositionMode | mode | ) |
Sets the blending mode used for drawing the text.
mode | blending mode |
Definition at line 1897 of file qgstextrenderer.cpp.
|
inline |
Sets the text's buffer settings.
bufferSettings | buffer settings |
Definition at line 1244 of file qgstextrenderer.h.
void QgsTextFormat::setColor | ( | const QColor & | color | ) |
Sets the color that text will be rendered in.
color | text color |
Definition at line 1877 of file qgstextrenderer.cpp.
void QgsTextFormat::setDataDefinedProperties | ( | const QgsPropertyCollection & | collection | ) |
Sets the format's property collection, used for data defined overrides.
collection | property collection. Existing properties will be replaced. |
Definition at line 2312 of file qgstextrenderer.cpp.
void QgsTextFormat::setFont | ( | const QFont & | font | ) |
Sets the font used for rendering text.
Note that the size of the font is not used, and setSize() should be called instead to explicitly set the size of rendered text.
font | desired font |
Definition at line 1822 of file qgstextrenderer.cpp.
void QgsTextFormat::setLineHeight | ( | double | height | ) |
Sets the line height for text.
height | a number between 0.0 and 10.0 representing the leading between lines as a multiplier of line height. |
Definition at line 1907 of file qgstextrenderer.cpp.
|
inline |
Sets the text's masking settings.
Masks may be defined in contexts where the text is rendered over some map layers, for labeling especially.
maskSettings | mask settings |
Definition at line 1305 of file qgstextrenderer.h.
void QgsTextFormat::setNamedStyle | ( | const QString & | style | ) |
Sets the named style for the font used for rendering text.
style | named style, e.g., "bold" |
Definition at line 1836 of file qgstextrenderer.cpp.
void QgsTextFormat::setOpacity | ( | double | opacity | ) |
Sets the text's opacity.
opacity | opacity as a double value between 0 (fully transparent) and 1 (totally opaque) |
Definition at line 1887 of file qgstextrenderer.cpp.
void QgsTextFormat::setOrientation | ( | TextOrientation | orientation | ) |
Sets the orientation for the text.
Definition at line 1917 of file qgstextrenderer.cpp.
void QgsTextFormat::setPreviewBackgroundColor | ( | const QColor & | color | ) |
Sets the background color that text will be rendered on for previews.
Definition at line 1927 of file qgstextrenderer.cpp.
|
inline |
Sets the text's drop shadow settings.
shadowSettings | shadow settings |
Definition at line 1282 of file qgstextrenderer.h.
void QgsTextFormat::setSize | ( | double | size | ) |
Sets the size for rendered text.
size | size of rendered text. Units are set using setSizeUnit() |
Definition at line 1867 of file qgstextrenderer.cpp.
void QgsTextFormat::setSizeMapUnitScale | ( | const QgsMapUnitScale & | scale | ) |
Sets the map unit scale object for the size.
This is only used if the sizeUnit() is set to QgsUnitTypes::RenderMapUnit.
Definition at line 1857 of file qgstextrenderer.cpp.
void QgsTextFormat::setSizeUnit | ( | QgsUnitTypes::RenderUnit | unit | ) |
Sets the units for the size of rendered text.
unit | size units |
Definition at line 1847 of file qgstextrenderer.cpp.
|
inline |
Returns a reference to the text drop shadow settings.
Definition at line 1269 of file qgstextrenderer.h.
|
inline |
Returns a reference to the text drop shadow settings.
Definition at line 1275 of file qgstextrenderer.h.
double QgsTextFormat::size | ( | ) | const |
Returns the size for rendered text.
Units are retrieved using sizeUnit().
Definition at line 1862 of file qgstextrenderer.cpp.
QgsMapUnitScale QgsTextFormat::sizeMapUnitScale | ( | ) | const |
Returns the map unit scale object for the size.
This is only used if the sizeUnit() is set to QgsUnitTypes::RenderMapUnit.
Definition at line 1852 of file qgstextrenderer.cpp.
QgsUnitTypes::RenderUnit QgsTextFormat::sizeUnit | ( | ) | const |
Returns the units for the size of rendered text.
Definition at line 1842 of file qgstextrenderer.cpp.
|
static |
Returns a pixmap preview for a text format.
format | text format |
size | target pixmap size |
previewText | text to render in preview, or empty for default text |
padding | space between icon edge and color ramp |
Definition at line 2499 of file qgstextrenderer.cpp.
QMimeData * QgsTextFormat::toMimeData | ( | ) | const |
Returns new mime data representing the text format settings.
Caller takes responsibility for deleting the returned object.
Definition at line 2193 of file qgstextrenderer.cpp.
QFont QgsTextFormat::toQFont | ( | ) | const |
Returns a QFont matching the relevant settings from this text format.
Unlike font(), this method also handles the size and size units from the text format.
Definition at line 2226 of file qgstextrenderer.cpp.
void QgsTextFormat::updateDataDefinedProperties | ( | QgsRenderContext & | context | ) |
Updates the format by evaluating current values of data defined properties.
Definition at line 2317 of file qgstextrenderer.cpp.
QDomElement QgsTextFormat::writeXml | ( | QDomDocument & | doc, |
const QgsReadWriteContext & | context | ||
) | const |
Write settings into a DOM element.
Definition at line 2157 of file qgstextrenderer.cpp.