summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Faure <[email protected]>2025-07-01 12:22:07 +0200
committerDavid Faure <[email protected]>2025-07-01 14:00:16 +0200
commit1447c303b1b7b27bf0f9b20362a26c7b91749346 (patch)
treefdb3930238a7582ee53089d6e58d487665e716ac
parenta43b6dfd5eadbdcf46451a120bd2994a5f5bacc3 (diff)
QTextCharFormat: improve documentation for font()HEADdev
It can be quite confusing to find out that fontItalic() == false but font().italic() == true, or vice-versa. Or worse, the fact that fontPointSize() returns 0 if the size comes from the default font. Fixes: QTBUG-49564 Pick-to: 6.10 6.9 6.8 6.5 Change-Id: I05239ed80e82080ea942524f289b953f806c8196 Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
-rw-r--r--src/gui/text/qtextformat.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/gui/text/qtextformat.cpp b/src/gui/text/qtextformat.cpp
index 06ae00123f0..379fb70a81a 100644
--- a/src/gui/text/qtextformat.cpp
+++ b/src/gui/text/qtextformat.cpp
@@ -2245,6 +2245,17 @@ void QTextCharFormat::setFont(const QFont &font, FontPropertiesInheritanceBehavi
/*!
Returns the font for this character format.
+
+ This function takes into account the format's font attributes (such as fontWeight()
+ and fontPointSize()) and resolves them on top of the default font, defined as follows.
+ If the format is part of a document, that is the document's default font.
+ Otherwise the properties are resolved on top of a default constructed QFont.
+
+ For example, if this format's font size hasn't been changed from the default font,
+ fontPointSize() returns 0, while \c {font().pointSize()} returns the actual
+ size used for drawing.
+
+ \sa QTextDocument::defaultFont()
*/
QFont QTextCharFormat::font() const
{