2017-05-14 09:48:41 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsfontutils.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2017-07-06 19:34:42 +10:00
|
|
|
|
2013-06-19 23:08:13 +02:00
|
|
|
class QgsFontUtils
|
|
|
|
{
|
2017-05-14 09:48:41 +02:00
|
|
|
|
2013-06-19 23:08:13 +02:00
|
|
|
%TypeHeaderCode
|
2017-05-14 09:48:41 +02:00
|
|
|
#include "qgsfontutils.h"
|
2013-06-19 23:08:13 +02:00
|
|
|
%End
|
|
|
|
public:
|
2017-05-14 09:48:41 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool fontMatchOnSystem( const QFont &f );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Check whether exact font is on system
|
|
|
|
|
2017-12-15 21:36:08 -04:00
|
|
|
:param f: The font to test for match
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2013-06-19 23:08:13 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool fontFamilyOnSystem( const QString &family );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Check whether font family is on system in a quick manner, which does not compare [foundry]
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param family: The family to test
|
|
|
|
|
|
|
|
:return: Whether family was found on system
|
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
This is good for use in loops of large lists, e.g. registering many features for labeling
|
|
|
|
%End
|
2013-06-19 23:08:13 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool fontFamilyHasStyle( const QString &family, const QString &style );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Check whether font family on system has specific style
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param family: The family to test
|
|
|
|
:param style: The style to test for
|
|
|
|
|
|
|
|
:return: Whether family has style
|
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. versionadded:: 2.1
|
|
|
|
%End
|
2014-02-19 13:24:49 -07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool fontFamilyMatchOnSystem( const QString &family, QString *chosen = 0, bool *match = 0 );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Check whether font family is on system
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param family: The family to test
|
|
|
|
:param chosen: The actual family (possibly from different foundry) returned by system
|
|
|
|
:param match: Whether the family [foundry] returned by system is a match
|
|
|
|
|
|
|
|
:return: Whether family was found on system
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2013-06-19 23:08:13 +02:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool updateFontViaStyle( QFont &f, const QString &fontstyle, bool fallback = false );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Updates font with named style and retain all font properties
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param f: The font to update
|
|
|
|
:param fontstyle: The style to try and switch the font to
|
|
|
|
:param fallback: If no matching fontstyle found for font, assign most similar or first style found to font
|
|
|
|
|
2019-02-26 19:54:09 +10:00
|
|
|
:return: Whether the font was updated (also returns ``True`` if the requested style matches font's current style)
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
This is a more featured replacement for a Qt 4.8+ function: void QFont.setStyleName ( const QString & styleName )
|
|
|
|
%End
|
2013-06-19 23:08:13 +02:00
|
|
|
|
2014-02-19 13:24:49 -07:00
|
|
|
static QString standardTestFontFamily();
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets standard test font family
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. versionadded:: 2.1
|
|
|
|
%End
|
2014-02-19 13:24:49 -07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool loadStandardTestFonts( const QStringList &loadstyles );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Loads standard test fonts from filesystem or qrc resource
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param loadstyles: List of styles to load, e.g. All, Roman, Oblique, Bold, Bold Oblique
|
|
|
|
|
|
|
|
:return: Whether any font was loaded
|
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
Done by default on debug app/server startup to ensure fonts available for unit tests (Roman and Bold)
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. versionadded:: 2.1
|
|
|
|
%End
|
2014-02-19 10:11:26 -07:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QFont getStandardTestFont( const QString &style = "Roman", int pointsize = 12 );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2018-05-26 18:44:30 +10:00
|
|
|
Gets standard test font with specific style
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param style: Style to load, e.g. Roman, Oblique, Bold, Bold Oblique
|
|
|
|
:param pointsize: Font point size to set
|
|
|
|
|
|
|
|
:return: QFont
|
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. versionadded:: 2.1
|
|
|
|
%End
|
2015-06-15 19:35:28 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QDomElement toXmlElement( const QFont &font, QDomDocument &document, const QString &elementName );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns a DOM element containing the properties of the font.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param font: font
|
|
|
|
:param document: DOM document
|
|
|
|
:param elementName: name for DOM element
|
|
|
|
|
|
|
|
:return: DOM element containing font settings
|
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`setFromXmlElement`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 2.10
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-06-15 19:35:28 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool setFromXmlElement( QFont &font, const QDomElement &element );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param font: font to update
|
|
|
|
:param element: DOM element
|
|
|
|
|
2019-02-26 19:54:09 +10:00
|
|
|
:return: ``True`` if properties were successfully read from element
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`toXmlElement`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`setFromXmlChildNode`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 2.10
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-06-15 19:35:28 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static bool setFromXmlChildNode( QFont &font, const QDomElement &element, const QString &childNode );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
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.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param font: font to update
|
|
|
|
:param element: DOM element
|
|
|
|
:param childNode: name of child node
|
|
|
|
|
2019-02-26 19:54:09 +10:00
|
|
|
:return: ``True`` if child node exists and properties were successfully read from node
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`setFromXmlElement`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`toXmlElement`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 2.10
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-07-29 11:52:14 +02:00
|
|
|
|
2017-07-06 19:34:42 +10:00
|
|
|
static QMimeData *toMimeData( const QFont &font ) /Factory/;
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns new mime data representing the specified ``font`` settings.
|
|
|
|
Caller takes responsibility for deleting the returned object.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`fromMimeData`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-07-06 19:34:42 +10:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
|
|
|
static QFont fromMimeData( const QMimeData *data, bool *ok /Out/ = 0 );
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Attempts to parse the provided mime ``data`` as a QFont.
|
2019-02-26 19:54:09 +10:00
|
|
|
If data can be parsed as a QFont, ``ok`` will be set to ``True``.
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`toMimeData`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-07-06 19:34:42 +10:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QString translateNamedStyle( const QString &namedStyle );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns the localized named style of a font, if such a translation is available.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param namedStyle: a named style, i.e. "Bold", "Italic", etc
|
|
|
|
|
|
|
|
:return: The localized named style
|
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`untranslateNamedStyle`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 2.12
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2015-06-27 12:05:55 +10:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QString untranslateNamedStyle( const QString &namedStyle );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns the english named style of a font, if possible.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param namedStyle: a localized named style, i.e. "Fett", "Kursiv", etc
|
|
|
|
|
|
|
|
:return: The english named style
|
|
|
|
|
2017-12-05 20:04:14 -04:00
|
|
|
.. seealso:: :py:func:`translateNamedStyle`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 2.12
|
2017-05-14 09:48:41 +02:00
|
|
|
%End
|
2016-03-30 16:04:09 +11:00
|
|
|
|
2017-05-01 16:42:33 +02:00
|
|
|
static QString asCSS( const QFont &font, double pointToPixelMultiplier = 1.0 );
|
2017-05-14 09:48:41 +02:00
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns a CSS string representing the specified font as closely as possible.
|
2017-12-15 21:36:08 -04:00
|
|
|
|
2017-12-15 10:36:55 -04:00
|
|
|
:param font: QFont to convert
|
|
|
|
:param pointToPixelMultiplier: scaling factor to apply to convert point sizes to pixel font sizes.
|
2018-05-27 16:33:02 +10:00
|
|
|
The CSS returned by this function will always use pixels for font sizes, so this parameter
|
2018-05-24 21:21:14 +10:00
|
|
|
should be set to a suitable value to convert point sizes to pixels (e.g., taking into account
|
|
|
|
destination DPI)
|
2017-12-15 10:36:55 -04:00
|
|
|
|
|
|
|
:return: partial CSS string, e.g., "font-family: Comic Sans; font-size: 12px;"
|
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
.. versionadded:: 2.16
|
|
|
|
%End
|
2017-07-06 19:51:45 +10:00
|
|
|
|
|
|
|
static void addRecentFontFamily( const QString &family );
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Adds a font ``family`` to the list of recently used font families.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`recentFontFamilies`
|
2018-05-28 11:31:08 -04:00
|
|
|
|
|
|
|
.. versionadded:: 3.0
|
2017-07-06 19:51:45 +10:00
|
|
|
%End
|
|
|
|
|
|
|
|
static QStringList recentFontFamilies();
|
|
|
|
%Docstring
|
2017-12-15 10:36:55 -04:00
|
|
|
Returns a list of recently used font families.
|
|
|
|
|
2018-01-09 17:26:37 -04:00
|
|
|
.. seealso:: :py:func:`addRecentFontFamily`
|
2017-12-15 10:36:55 -04:00
|
|
|
|
2017-07-06 19:51:45 +10:00
|
|
|
.. versionadded:: 3.0
|
|
|
|
%End
|
2013-06-19 23:08:13 +02:00
|
|
|
};
|
2017-05-14 09:48:41 +02:00
|
|
|
|
2017-09-25 14:20:39 +10:00
|
|
|
|
2017-05-14 09:48:41 +02:00
|
|
|
/************************************************************************
|
|
|
|
* This file has been generated automatically from *
|
|
|
|
* *
|
|
|
|
* src/core/qgsfontutils.h *
|
|
|
|
* *
|
|
|
|
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
|
|
|
|
************************************************************************/
|