diff options
Diffstat (limited to 'src/gui/text/qrawfont.cpp')
-rw-r--r-- | src/gui/text/qrawfont.cpp | 69 |
1 files changed, 46 insertions, 23 deletions
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp index 4a715c2..10112d5 100644 --- a/src/gui/text/qrawfont.cpp +++ b/src/gui/text/qrawfont.cpp @@ -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::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 \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 @@ -370,11 +378,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::glyphs() 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(), QGlyphs, QTextLayout::glyphs(), QTextFragment::glyphs() */ @@ -579,8 +591,19 @@ QRawFont QRawFont::fromFont(const QFont &font, QFontDatabase::WritingSystem writ */ void QRawFont::setPixelSize(int pixelSize) { + if (d->fontEngine == 0) + return; + detach(); - d->platformSetPixelSize(pixelSize); + QFontEngine *oldFontEngine = d->fontEngine; + + d->fontEngine = d->fontEngine->cloneWithSize(pixelSize); + if (d->fontEngine != 0) + d->fontEngine->ref.ref(); + + oldFontEngine->ref.deref(); + if (oldFontEngine->cache_count == 0 && oldFontEngine->ref == 0) + delete oldFontEngine; } /*! |