QGIS API Documentation 3.41.0-Master (45a0abf3bec)
|
Contains utility functions for working with fonts. More...
#include <qgsfontutils.h>
Static Public Member Functions | |
static void | addRecentFontFamily (const QString &family) |
Adds a font family to the list of recently used font families. | |
static QString | asCSS (const QFont &font, double pointToPixelMultiplier=1.0) |
Returns a CSS string representing the specified font as closely as possible. | |
static QFont | createFont (const QString &family, int pointSize=-1, int weight=-1, bool italic=false) |
Creates a font with the specified family. | |
static bool | fontFamilyHasStyle (const QString &family, const QString &style) |
Check whether font family on system has specific style. | |
static bool | fontFamilyMatchOnSystem (const QString &family, QString *chosen=nullptr, bool *match=nullptr) |
Check whether font family is on system. | |
static bool | fontFamilyOnSystem (const QString &family) |
Check whether font family is on system in a quick manner, which does not compare [foundry]. | |
static bool | fontMatchOnSystem (const QFont &f) |
Check whether exact font is on system. | |
static QFont | fromMimeData (const QMimeData *data, bool *ok=nullptr) |
Attempts to parse the provided mime data as a QFont. | |
static QFont | getStandardTestFont (const QString &style="Roman", int pointsize=12) |
Gets standard test font with specific style. | |
static bool | loadStandardTestFonts (const QStringList &loadstyles) |
Loads standard test fonts from filesystem or qrc resource. | |
static QStringList | recentFontFamilies () |
Returns a list of recently used font families. | |
static QString | resolveFontStyleName (const QFont &font) |
Attempts to resolve the style name corresponding to the specified font object. | |
static void | setFontFamily (QFont &font, const QString &family) |
Sets the family for a font object. | |
static bool | setFromXmlChildNode (QFont &font, const QDomElement &element, const QString &childNode) |
Sets the properties of a font to match the properties stored in an XML child node. | |
static bool | setFromXmlElement (QFont &font, const QDomElement &element) |
Sets the properties of a font to match the properties stored in an XML element. | |
static QString | standardTestFontFamily () |
Gets standard test font family. | |
static QMimeData * | toMimeData (const QFont &font) |
Returns new mime data representing the specified font settings. | |
static QDomElement | toXmlElement (const QFont &font, QDomDocument &document, const QString &elementName) |
Returns a DOM element containing the properties of the font. | |
static QString | translateNamedStyle (const QString &namedStyle) |
Returns the localized named style of a font, if such a translation is available. | |
static QString | untranslateNamedStyle (const QString &namedStyle) |
Returns the english named style of a font, if possible. | |
static bool | updateFontViaStyle (QFont &f, const QString &fontstyle, bool fallback=false) |
Updates font with named style and retain all font properties. | |
Contains utility functions for working with fonts.
Definition at line 33 of file qgsfontutils.h.
|
static |
Adds a font family to the list of recently used font families.
Definition at line 578 of file qgsfontutils.cpp.
|
static |
Returns a CSS string representing the specified font as closely as possible.
font | QFont to convert |
pointToPixelMultiplier | scaling factor to apply to convert point sizes to pixel font sizes. The CSS returned by this function will always use pixels for font sizes, so this parameter should be set to a suitable value to convert point sizes to pixels (e.g., taking into account destination DPI) |
Definition at line 518 of file qgsfontutils.cpp.
|
static |
Creates a font with the specified family.
Applies some workarounds for specific font quirks.
Definition at line 618 of file qgsfontutils.cpp.
|
static |
Check whether font family on system has specific style.
family | The family to test |
style | The style to test for |
Definition at line 45 of file qgsfontutils.cpp.
|
static |
Check whether font family is on system.
family | The family to test |
chosen | The actual family (possibly from different foundry) returned by system |
match | Whether the family [foundry] returned by system is a match |
Definition at line 100 of file qgsfontutils.cpp.
|
static |
Check whether font family is on system in a quick manner, which does not compare [foundry].
family | The family to test |
Definition at line 38 of file qgsfontutils.cpp.
|
static |
Check whether exact font is on system.
f | The font to test for match |
Definition at line 32 of file qgsfontutils.cpp.
|
static |
Attempts to parse the provided mime data as a QFont.
If data can be parsed as a QFont, ok will be set to true
.
Definition at line 436 of file qgsfontutils.cpp.
|
static |
Gets standard test font with specific style.
style | Style to load, e.g. Roman, Oblique, Bold, Bold Oblique |
pointsize | Font point size to set |
Definition at line 319 of file qgsfontutils.cpp.
|
static |
Loads standard test fonts from filesystem or qrc resource.
loadstyles | List of styles to load, e.g. All, Roman, Oblique, Bold, Bold Oblique |
Definition at line 256 of file qgsfontutils.cpp.
|
static |
Returns a list of recently used font families.
Definition at line 600 of file qgsfontutils.cpp.
|
static |
Attempts to resolve the style name corresponding to the specified font object.
If a font has been modified by calling QFont::setBold or QFont::setItalic, then its QFont::styleName may return an empty string. This method attempts to determine the correct style name which corresponds to the font's bold and italic settings.
Returns an empty string if a matching style name could not be found.
Definition at line 69 of file qgsfontutils.cpp.
|
static |
Sets the family for a font object.
Applies some workarounds for specific font quirks.
Definition at line 606 of file qgsfontutils.cpp.
|
static |
Sets the properties of a font to match the properties stored in an XML child node.
Calling this will overwrite the current properties of the font.
font | font to update |
element | DOM element |
childNode | name of child node |
true
if child node exists and properties were successfully read from node Definition at line 405 of file qgsfontutils.cpp.
|
static |
Sets the properties of a font to match the properties stored in an XML element.
Calling this will overwrite the current properties of the font.
font | font to update |
element | DOM element |
true
if properties were successfully read from element Definition at line 371 of file qgsfontutils.cpp.
|
static |
Gets standard test font family.
Definition at line 251 of file qgsfontutils.cpp.
|
static |
Returns new mime data representing the specified font settings.
Caller takes responsibility for deleting the returned object.
Definition at line 424 of file qgsfontutils.cpp.
|
static |
Returns a DOM element containing the properties of the font.
font | font |
document | DOM document |
elementName | name for DOM element |
Definition at line 359 of file qgsfontutils.cpp.
|
static |
Returns the localized named style of a font, if such a translation is available.
namedStyle | a named style, i.e. "Bold", "Italic", etc |
Definition at line 489 of file qgsfontutils.cpp.
|
static |
Returns the english named style of a font, if possible.
namedStyle | a localized named style, i.e. "Fett", "Kursiv", etc |
Definition at line 499 of file qgsfontutils.cpp.
|
static |
Updates font with named style and retain all font properties.
f | The font to update |
fontstyle | The style to try and switch the font to |
fallback | If no matching fontstyle found for font, assign most similar or first style found to font |
true
if the requested style matches font's current style) Definition at line 153 of file qgsfontutils.cpp.