Doc: Revise Qt Quick Text reference page

* Fix typos.
* Show rich text Markdown example.
* Be consistent with relative clauses (that vs which).
* Where it makes sense, use active voice instead of passive voice.

Fixes: QTBUG-119485
Pick-to: 6.7 6.6 6.5 6.2 5.15
Change-Id: I7843a3276f277172e25f5891f08e2a830d713c4e
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Andreas Eliasson 2023-11-29 15:16:03 +01:00
parent d4ca70eaa4
commit ec3b799824
1 changed files with 49 additions and 25 deletions

View File

@ -206,7 +206,7 @@ void QQuickTextPrivate::setBottomPadding(qreal value, bool reset)
Used to decide if the Text should use antialiasing or not. Only Text
with renderType of Text.NativeRendering can disable antialiasing.
The default is true.
The default is \c true.
*/
void QQuickText::q_updateLayout()
@ -1382,8 +1382,8 @@ void QQuickTextPrivate::updateDocumentText()
\inherits Item
\brief Specifies how to add formatted text to a scene.
Text items can display both plain and rich text. For example, red text with
a specific font and size can be defined like this:
Text items can display both plain and rich text. For example, you can define
red text with a specific font and size like this:
\qml
Text {
@ -1394,25 +1394,47 @@ void QQuickTextPrivate::updateDocumentText()
}
\endqml
Rich text is defined using HTML-style markup:
Use HTML-style markup or Markdown to define rich text:
\if defined(onlinedocs)
\tab {build-qt-app}{tab-html}{HTML-style}{checked}
\tab {build-qt-app}{tab-md}{Markdown}{}
\tabcontent {tab-html}
\else
\section1 Using HTML-style
\endif
\qml
Text {
text: "<b>Hello</b> <i>World!</i>"
}
\endqml
\if defined(onlinedocs)
\endtabcontent
\tabcontent {tab-md}
\else
\section1 Using Markdown
\endif
\qml
Text {
text: "**Hello** *World!*"
}
\endqml
\if defined(onlinedocs)
\endtabcontent
\endif
\image declarative-text.png
If height and width are not explicitly set, Text will attempt to determine how
much room is needed and set it accordingly. Unless \l wrapMode is set, it will always
prefer width to height (all text will be placed on a single line).
If height and width are not explicitly set, Text will try to determine how
much room is needed and set it accordingly. Unless \l wrapMode is set, it
will always prefer width to height (all text will be placed on a single
line).
The \l elide property can alternatively be used to fit a single line of
plain text to a set width.
To fit a single line of plain text to a set width, you can use the \l elide
property.
Note that the \l{Supported HTML Subset} is limited. Also, if the text contains
HTML img tags that load remote images, the text is reloaded.
Note that the \l{Supported HTML Subset} is limited. Also, if the text
contains HTML img tags that load remote images, the text is reloaded.
Text provides read-only text. For editable text, see \l TextEdit.
@ -1445,7 +1467,7 @@ QQuickText::~QQuickText()
\qmlproperty bool QtQuick::Text::clip
This property holds whether the text is clipped.
Note that if the text does not fit in the bounding rectangle it will be abruptly chopped.
Note that if the text does not fit in the bounding rectangle, it will be abruptly chopped.
If you want to display potentially long text in a limited space, you probably want to use \c elide instead.
*/
@ -1534,7 +1556,8 @@ QQuickText::~QQuickText()
Sets the family name of the font.
The family name is case insensitive and may optionally include a foundry name, e.g. "Helvetica [Cronyx]".
The family name is case insensitive and may optionally include a foundry
name, for example "Helvetica [Cronyx]".
If the family is available from more than one foundry and the foundry isn't specified, an arbitrary foundry is chosen.
If the family isn't available a family will be set using the font matching algorithm.
*/
@ -1658,7 +1681,7 @@ QQuickText::~QQuickText()
\value Font.PreferDefaultHinting Use the default hinting level for the target platform.
\value Font.PreferNoHinting If possible, render text without hinting the outlines
of the glyphs. The text layout will be typographically accurate, using the same metrics
as are used e.g. when printing.
as are used, for example, when printing.
\value Font.PreferVerticalHinting If possible, render text with no horizontal hinting,
but align glyphs to the pixel grid in the vertical direction. The text will appear
crisper on displays where the density is too low to give an accurate rendering
@ -1695,7 +1718,7 @@ QQuickText::~QQuickText()
Sometimes, a font will apply complex rules to a set of characters in order to
display them correctly. In some writing systems, such as Brahmic scripts, this is
required in order for the text to be legible, but in e.g. Latin script, it is merely
required in order for the text to be legible, but in for example Latin script, it is merely
a cosmetic feature. Setting the \c preferShaping property to false will disable all
such features when they are not required, which will improve performance in most cases.
@ -1766,7 +1789,7 @@ QQuickText::~QQuickText()
The font features are represented by a map from four-letter tags to integer values. This integer
value passed along with the tag in most cases represents a boolean value: A zero value means the
feature is disabled, and a non-zero value means it is enabled. For certain font features,
however, it may have other intepretations. For example, when applied to the \c salt feature, the
however, it may have other interpretations. For example, when applied to the \c salt feature, the
value is an index that specifies the stylistic alternative to use.
For example, the \c frac font feature will convert diagonal fractions separated with a slash
@ -1784,8 +1807,9 @@ QQuickText::~QQuickText()
}
\endqml
Multiple features can be assigned values in the same mapping. For instance, if we would like
to also disable kerning for the font, we can explicitly disable this as follows:
Multiple features can be assigned values in the same mapping. For instance,
if you would like to also disable kerning for the font, you can explicitly
disable this as follows:
\qml
Text {
@ -1814,8 +1838,8 @@ QQuickText::~QQuickText()
systems where the use of ligature is cosmetic. For writing systems where ligatures are required,
the features will remain in their default state. The values set using \c font.features will
override the default behavior. If, for instance, \c{"kern"} is set to 1, then kerning will
always be enabled, egardless of whether the \l font.kerning property is set to false. Similarly,
if it is set to 0, then it will always be disabled.
always be enabled, regardless of whether the \l font.kerning property is set to false. Similarly,
if it is set to \c 0, it will always be disabled.
\sa QFont::setFeature()
//! [qml-font-features]
@ -2340,7 +2364,7 @@ void QQuickText::resetMaximumLineCount()
\l {https://guides.github.com/features/mastering-markdown/}{GitHub}
extensions for tables and task lists (since 5.14)
If the text format is \c Text.AutoText the Text item
If the text format is \c Text.AutoText, the Text item
will automatically determine whether the text should be treated as
styled text. This determination is made using Qt::mightBeRichText(),
which can detect the presence of an HTML tag on the first line of text,
@ -2469,7 +2493,7 @@ void QQuickText::setElideMode(QQuickText::TextElideMode mode)
/*!
\qmlproperty url QtQuick::Text::baseUrl
This property specifies a base URL which is used to resolve relative URLs
This property specifies a base URL that is used to resolve relative URLs
within the text.
Urls are resolved to be within the same directory as the target of the base
@ -2764,7 +2788,7 @@ void QQuickText::updatePolish()
\qmlproperty real QtQuick::Text::contentWidth
Returns the width of the text, including width past the width
which is covered due to insufficient wrapping if WrapMode is set.
that is covered due to insufficient wrapping if WrapMode is set.
*/
qreal QQuickText::contentWidth() const
{
@ -2776,7 +2800,7 @@ qreal QQuickText::contentWidth() const
\qmlproperty real QtQuick::Text::contentHeight
Returns the height of the text, including height past the height
which is covered due to there being more text than fits in the set height.
that is covered due to there being more text than fits in the set height.
*/
qreal QQuickText::contentHeight() const
{
@ -3559,7 +3583,7 @@ QJSValue QQuickText::fontInfo() const
in a text flow.
Note that the advance can be negative if the text flows from
the right to the left.
right to left.
*/
QSizeF QQuickText::advance() const
{