From a5190a05bfe809339e9612c9013f0f8213791768 Mon Sep 17 00:00:00 2001 From: Volker Hilsheimer Date: Mon, 27 Jul 2009 11:26:22 +0200 Subject: Doc: QTextLayout is the class to use in interactive text controls. --- doc/src/i18n.qdoc | 12 ++++++------ src/gui/text/qfontmetrics.cpp | 10 ++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/doc/src/i18n.qdoc b/doc/src/i18n.qdoc index 5964926..d043f45 100644 --- a/doc/src/i18n.qdoc +++ b/doc/src/i18n.qdoc @@ -144,13 +144,13 @@ aligned, so for these languages use the version of drawText() that takes a QRect since this will align in accordance with the language. - \o When you write your own text input controls, use \l - QFontMetrics::charWidth() to determine the width of a character in a - string. In some languages (e.g. Arabic or languages from the Indian + \o When you write your own text input controls, use QTextLayout. + In some languages (e.g. Arabic or languages from the Indian subcontinent), the width and shape of a glyph changes depending on the - surrounding characters. Writing input controls usually requires a - certain knowledge of the scripts it is going to be used in. Usually - the easiest way is to subclass QLineEdit or QTextEdit. + surrounding characters, which QTextLayout takes into account. + Writing input controls usually requires a certain knowledge of the + scripts it is going to be used in. Usually the easiest way is to + subclass QLineEdit or QTextEdit. \endlist diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp index abab91c..f558011 100644 --- a/src/gui/text/qfontmetrics.cpp +++ b/src/gui/text/qfontmetrics.cpp @@ -557,9 +557,8 @@ int QFontMetrics::width(const QString &text, int len) const \warning This function will produce incorrect results for Arabic characters or non-spacing marks in the middle of a string, as the glyph shaping and positioning of marks that happens when - processing strings cannot be taken into account. Use charWidth() - instead if you aren't looking for the width of isolated - characters. + processing strings cannot be taken into account. When implementing + an interactive text control, use QTextLayout instead. \sa boundingRect(), charWidth() */ @@ -1386,9 +1385,8 @@ qreal QFontMetricsF::width(const QString &text) const \warning This function will produce incorrect results for Arabic characters or non-spacing marks in the middle of a string, as the glyph shaping and positioning of marks that happens when - processing strings cannot be taken into account. Use charWidth() - instead if you aren't looking for the width of isolated - characters. + processing strings cannot be taken into account. When implementing + an interactive text control, use QTextLayout instead. \sa boundingRect() */ -- cgit v0.12