summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qfontengine_ft.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/text/qfontengine_ft.cpp')
-rw-r--r--src/gui/text/qfontengine_ft.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 8ae178c6ad..8176ede994 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1756,7 +1756,6 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
};
QFontEngineFT::Glyph *glyph;
- QScopedPointer<QFontEngineFT::Glyph> glyphGuard;
if (cacheEnabled) {
QGlyphSet *gset = loadGlyphSet(t);
QFontEngine::HintStyle hintStyle = default_hint_style;
@@ -1772,15 +1771,13 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
freetype->matrix = m;
}
- if (!gset || gset->outline_drawing || !loadGlyph(gset, glyphIndex, subPixelPosition,
- neededFormat)) {
+ if (!gset || gset->outline_drawing || !(glyph = loadGlyph(gset, glyphIndex, subPixelPosition,
+ neededFormat))) {
default_hint_style = hintStyle;
return QFontEngine::lockedAlphaMapForGlyph(glyphIndex, subPixelPosition, neededFormat, t,
offset);
}
default_hint_style = hintStyle;
-
- glyph = gset->getGlyph(glyphIndex, subPixelPosition);
} else {
FT_Matrix m = matrix;
FT_Matrix extra = QTransformToFTMatrix(t);
@@ -1788,10 +1785,11 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
FT_Set_Transform(freetype->face, &m, 0);
freetype->matrix = m;
glyph = loadGlyph(0, glyphIndex, subPixelPosition, neededFormat);
- glyphGuard.reset(glyph);
}
if (glyph == 0 || glyph->data == 0 || glyph->width == 0 || glyph->height == 0) {
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
unlockFace();
return 0;
}
@@ -1816,8 +1814,10 @@ QImage *QFontEngineFT::lockedAlphaMapForGlyph(glyph_t glyphIndex, QFixed subPixe
*offset = QPoint(glyph->x, -glyph->y);
currentlyLockedAlphaMap = QImage(glyph->data, glyph->width, glyph->height, pitch, format);
- if (!glyphGuard.isNull())
+ if (!cacheEnabled && glyph != &emptyGlyph) {
currentlyLockedAlphaMap = currentlyLockedAlphaMap.copy();
+ delete glyph;
+ }
Q_ASSERT(!currentlyLockedAlphaMap.isNull());
QImageData *data = currentlyLockedAlphaMap.data_ptr();
@@ -1864,11 +1864,10 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition)
QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const QTransform &t)
{
- lockFace();
-
- QScopedPointer<Glyph> glyph(loadGlyphFor(g, subPixelPosition, antialias ? Format_A8 : Format_Mono, t));
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, antialias ? Format_A8 : Format_Mono, t);
if (!glyph || !glyph->data) {
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return QFontEngine::alphaMapForGlyph(g);
}
@@ -1886,9 +1885,9 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition, const
for (int y = 0; y < glyph->height; ++y)
memcpy(img.scanLine(y), &glyph->data[y * pitch], pitch);
}
- if (cacheEnabled)
- glyph.take();
- unlockFace();
+
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return img;
}
@@ -1898,20 +1897,18 @@ QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, co
if (t.type() > QTransform::TxRotate)
return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
- lockFace();
-
- QScopedPointer<Glyph> glyph(loadGlyphFor(g, subPixelPosition, Format_A32, t));
+ Glyph *glyph = loadGlyphFor(g, subPixelPosition, Format_A32, t);
if (!glyph || !glyph->data) {
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
}
QImage img(glyph->width, glyph->height, QImage::Format_RGB32);
memcpy(img.bits(), glyph->data, 4 * glyph->width * glyph->height);
- if (cacheEnabled)
- glyph.take();
- unlockFace();
+ if (!cacheEnabled && glyph != &emptyGlyph)
+ delete glyph;
return img;
}