summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qrawfont.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qrawfont.cpp')
-rw-r--r--src/gui/text/qrawfont.cpp104
1 files changed, 65 insertions, 39 deletions
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 44ddfd2d75..481180ec78 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -7,29 +7,29 @@
** This file is part of the QtGui module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the Technology Preview License Agreement accompanying
-** this package.
-**
** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Nokia gives you certain additional
-** rights. These rights are described in the Nokia Qt LGPL Exception
+** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
-** If you have questions regarding the use of this file, please contact
-** Nokia at qt-info@nokia.com.
-**
-**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
**
**
**
@@ -87,16 +87,16 @@ QT_BEGIN_NAMESPACE
QRawFont can be constructed in a number of ways:
\list
- \o \l It can be constructed by calling QTextLayout::glyphRuns() or QTextFragment::glyphRuns().
- The returned QGlyphRun objects will contain QRawFont objects which represent the actual
- fonts used to render each portion of the text.
- \o \l It can be constructed by passing a QFont object to QRawFont::fromFont(). The function
- will return a QRawFont object representing the font that will be selected as response to
- the QFont query and the selected writing system.
- \o \l It can be constructed by passing a file name or QByteArray directly to the QRawFont
- constructor, or by calling loadFromFile() or loadFromData(). In this case, the
- font will not be registered in QFontDatabase, and it will not be available as part of
- regular font selection.
+ \o It can be constructed by calling QTextLayout::glyphs() or QTextFragment::glyphs(). The
+ returned QGlyphs objects will contain QRawFont objects which represent the actual fonts
+ used to render each portion of the text.
+ \o It can be constructed by passing a QFont object to QRawFont::fromFont(). The function
+ will return a QRawFont object representing the font that will be selected as response to
+ the QFont query and the selected writing system.
+ \o It can be constructed by passing a file name or QByteArray directly to the QRawFont
+ constructor, or by calling loadFromFile() or loadFromData(). In this case, the
+ font will not be registered in QFontDatabase, and it will not be available as part of
+ regular font selection.
\endlist
QRawFont is considered local to the thread in which it is constructed (either using a
@@ -132,8 +132,9 @@ QRawFont::QRawFont()
}
/*!
- Constructs a QRawFont representing the font contained in the file referenced by \a fileName,
- with \a pixelSize size in pixels, and the selected \a hintingPreference.
+ Constructs a QRawFont representing the font contained in the file referenced
+ by \a fileName for the size (in pixels) given by \a pixelSize, and using the
+ hinting preference specified by \a hintingPreference.
\note The referenced file must contain a TrueType or OpenType font.
*/
@@ -146,7 +147,9 @@ QRawFont::QRawFont(const QString &fileName,
}
/*!
- Constructs a QRawFont representing the font contained in \a fontData.
+ Constructs a QRawFont representing the font contained in the supplied
+ \a fontData for the size (in pixels) given by \a pixelSize, and using the
+ hinting preference specified by \a hintingPreference.
\note The data must contain a TrueType or OpenType font.
*/
@@ -192,7 +195,9 @@ bool QRawFont::isValid() const
}
/*!
- Replaces the current QRawFont with the contents of the file references by \a fileName.
+ Replaces the current QRawFont with the contents of the file referenced
+ by \a fileName for the size (in pixels) given by \a pixelSize, and using the
+ hinting preference specified by \a hintingPreference.
The file must reference a TrueType or OpenType font.
@@ -208,7 +213,9 @@ void QRawFont::loadFromFile(const QString &fileName,
}
/*!
- Replaces the current QRawFont with the contents of \a fontData.
+ Replaces the current QRawFont with the font contained in the supplied
+ \a fontData for the size (in pixels) given by \a pixelSize, and using the
+ hinting preference specified by \a hintingPreference.
The \a fontData must contain a TrueType or OpenType font.
@@ -226,8 +233,9 @@ void QRawFont::loadFromData(const QByteArray &fontData,
}
/*!
- This function returns a rasterized image of the glyph at a given \a glyphIndex in the underlying
- font, if the QRawFont is valid, otherwise it will return an invalid QImage.
+ This function returns a rasterized image of the glyph at the given
+ \a glyphIndex in the underlying font, using the \a transform specified.
+ If the QRawFont is not valid, this function will return an invalid QImage.
If \a antialiasingType is set to QRawFont::SubPixelAntialiasing, then the resulting image will be
in QImage::Format_RGB32 and the RGB values of each pixel will represent the subpixel opacities of
@@ -422,11 +430,15 @@ int QRawFont::weight() const
}
/*!
- Converts a string of unicode points to glyph indexes using the CMAP table in the
- underlying font. Note that in cases where there are other tables in the font that affect the
- shaping of the text, the returned glyph indexes will not correctly represent the rendering
- of the text. To get the correctly shaped text, you can use QTextLayout to lay out and shape the
- text, and then call QTextLayout::glyphRuns() to get the set of glyph index list and QRawFont pairs.
+ Converts the string of unicode points given by \a text to glyph indexes
+ using the CMAP table in the underlying font, and returns a vector containing
+ the result.
+
+ Note that, in cases where there are other tables in the font that affect the
+ shaping of the text, the returned glyph indexes will not correctly represent
+ the rendering of the text. To get the correctly shaped text, you can use
+ QTextLayout to lay out and shape the text, then call QTextLayout::glyphs()
+ to get the set of glyph index list and QRawFont pairs.
\sa advancesForGlyphIndexes(), glyphIndexesForChars(), QGlyphRun, QTextLayout::glyphRuns(), QTextFragment::glyphRuns()
*/
@@ -718,6 +730,20 @@ void QRawFontPrivate::cleanUp()
hintingPreference = QFont::PreferDefaultHinting;
}
+/*!
+ Returns the smallest rectangle containing the glyph with the given \a glyphIndex.
+
+ \since 5.0
+*/
+QRectF QRawFont::boundingRect(quint32 glyphIndex) const
+{
+ if (!isValid())
+ return QRectF();
+
+ glyph_metrics_t gm = d->fontEngine->boundingBox(glyphIndex);
+ return QRectF(gm.x.toReal(), gm.y.toReal(), gm.width.toReal(), gm.height.toReal());
+}
+
#endif // QT_NO_RAWFONT
QT_END_NAMESPACE