summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJiang Jiang <jiang.jiang@nokia.com>2012-01-23 15:06:41 +0100
committerQt by Nokia <qt-info@nokia.com>2012-01-24 17:42:04 +0100
commitaf48e0ba36aed330e8b262687e3192d7e09796f7 (patch)
treef6d67b0c2d871ef169f61d7e0afcc578efefe5f2 /src/gui/text
parent601d68584921a47d83d833228f5ec698e13b624c (diff)
Move glyphMargin() to QFontEngine
glyphMargin() support for QTextureGlyphCache is implemented in respective font engines, thus this function is platform dependent. Before Qt 5 the code is guarded in macros like #ifdef Q_WS_MAC, now we should move them into QFontEngine and its subclasses. So far only Windows font engines support it. FreeType and Core Text based font engines all ignore it. Change-Id: Ia14016533d8fbfaacf848a7d3bc928f8197318f5 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontengine.cpp8
-rw-r--r--src/gui/text/qfontengine_ft.cpp6
-rw-r--r--src/gui/text/qfontengine_ft_p.h3
-rw-r--r--src/gui/text/qfontengine_p.h5
-rw-r--r--src/gui/text/qfontenginedirectwrite.cpp5
-rw-r--r--src/gui/text/qfontenginedirectwrite_p.h3
-rw-r--r--src/gui/text/qrawfont.cpp2
7 files changed, 17 insertions, 15 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 3894644f41..9303c65bac 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -618,7 +618,7 @@ QImage QFontEngine::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, con
return i;
}
-QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, int /* margin */, const QTransform &t)
+QImage QFontEngine::alphaRGBMapForGlyph(glyph_t glyph, QFixed /*subPixelPosition*/, const QTransform &t)
{
QImage alphaMask = alphaMapForGlyph(glyph, t);
QImage rgbMask(alphaMask.width(), alphaMask.height(), QImage::Format_RGB32);
@@ -664,7 +664,7 @@ QImage *QFontEngine::lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPositi
if (neededFormat != Format_A32)
currentlyLockedAlphaMap = alphaMapForGlyph(glyph, subPixelPosition, t);
else
- currentlyLockedAlphaMap = alphaRGBMapForGlyph(glyph, subPixelPosition, 0, t);
+ currentlyLockedAlphaMap = alphaRGBMapForGlyph(glyph, subPixelPosition, t);
if (offset != 0)
*offset = QPoint(0, 0);
@@ -1747,11 +1747,11 @@ QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition
return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
}
-QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, const QTransform &t)
+QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
{
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
- return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, margin, t);
+ return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, t);
}
QT_END_NAMESPACE
diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp
index 6fdb04ef61..31882af8bd 100644
--- a/src/gui/text/qfontengine_ft.cpp
+++ b/src/gui/text/qfontengine_ft.cpp
@@ -1896,17 +1896,17 @@ QImage QFontEngineFT::alphaMapForGlyph(glyph_t g, QFixed subPixelPosition)
return img;
}
-QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, int margin, const QTransform &t)
+QImage QFontEngineFT::alphaRGBMapForGlyph(glyph_t g, QFixed subPixelPosition, const QTransform &t)
{
if (t.type() > QTransform::TxTranslate)
- return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, margin, t);
+ return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
lockFace();
Glyph *glyph = loadGlyphFor(g, subPixelPosition, Format_A32);
if (!glyph) {
unlockFace();
- return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, margin, t);
+ return QFontEngine::alphaRGBMapForGlyph(g, subPixelPosition, t);
}
QImage img(glyph->width, glyph->height, QImage::Format_RGB32);
diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h
index 577b46c776..aaea1ea5fb 100644
--- a/src/gui/text/qfontengine_ft_p.h
+++ b/src/gui/text/qfontengine_ft_p.h
@@ -255,7 +255,7 @@ private:
virtual void recalcAdvances(QGlyphLayout *glyphs, QTextEngine::ShaperFlags flags) const;
virtual QImage alphaMapForGlyph(glyph_t g) { return alphaMapForGlyph(g, 0); }
virtual QImage alphaMapForGlyph(glyph_t, QFixed);
- virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual glyph_metrics_t alphaMapBoundingBox(glyph_t glyph,
QFixed subPixelPosition,
const QTransform &matrix,
@@ -267,6 +267,7 @@ private:
virtual void unlockAlphaMapForGlyph();
virtual void removeGlyphFromCache(glyph_t glyph);
+ virtual int glyphMargin(QFontEngineGlyphCache::Type type) { return 0; }
virtual int glyphCount() const;
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index cb3a0e111d..6fd83b06a6 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -189,7 +189,7 @@ public:
virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t);
virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QImage *lockedAlphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition,
GlyphFormat neededFormat,
const QTransform &t = QTransform(),
@@ -231,6 +231,7 @@ public:
virtual Type type() const = 0;
virtual int glyphCount() const;
+ virtual int glyphMargin(QFontEngineGlyphCache::Type type) { return type == QFontEngineGlyphCache::Raster_RGBMask ? 2 : 0; }
virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
@@ -370,7 +371,7 @@ public:
virtual QImage alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition);
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &t);
virtual QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
- virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, int margin, const QTransform &t);
+ virtual QImage alphaRGBMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
virtual QFixed lineThickness() const;
virtual QFixed underlinePosition() const;
diff --git a/src/gui/text/qfontenginedirectwrite.cpp b/src/gui/text/qfontenginedirectwrite.cpp
index 84dfe606e7..411642f231 100644
--- a/src/gui/text/qfontenginedirectwrite.cpp
+++ b/src/gui/text/qfontenginedirectwrite.cpp
@@ -641,10 +641,11 @@ QImage QFontEngineDirectWrite::imageForGlyph(glyph_t t,
QImage QFontEngineDirectWrite::alphaRGBMapForGlyph(glyph_t t,
QFixed subPixelPosition,
- int margin,
const QTransform &xform)
{
- QImage mask = imageForGlyph(t, subPixelPosition, margin, xform);
+ QImage mask = imageForGlyph(t, subPixelPosition,
+ glyphMargin(QFontEngineGlyphCache::Raster_RGBMask),
+ xform);
return mask.depth() == 32
? mask
: mask.convertToFormat(QImage::Format_RGB32);
diff --git a/src/gui/text/qfontenginedirectwrite_p.h b/src/gui/text/qfontenginedirectwrite_p.h
index de263c6214..f614b0497f 100644
--- a/src/gui/text/qfontenginedirectwrite_p.h
+++ b/src/gui/text/qfontenginedirectwrite_p.h
@@ -102,8 +102,7 @@ public:
bool supportsSubPixelPositions() const;
QImage alphaMapForGlyph(glyph_t, QFixed subPixelPosition, const QTransform &t);
- QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, int margin,
- const QTransform &xform);
+ QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform);
QFontEngine *cloneWithSize(qreal pixelSize) const;
diff --git a/src/gui/text/qrawfont.cpp b/src/gui/text/qrawfont.cpp
index 15d0d0ce20..7bd515366d 100644
--- a/src/gui/text/qrawfont.cpp
+++ b/src/gui/text/qrawfont.cpp
@@ -250,7 +250,7 @@ QImage QRawFont::alphaMapForGlyph(quint32 glyphIndex, AntialiasingType antialias
return QImage();
if (antialiasingType == SubPixelAntialiasing)
- return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), 0, transform);
+ return d->fontEngine->alphaRGBMapForGlyph(glyphIndex, QFixed(), transform);
return d->fontEngine->alphaMapForGlyph(glyphIndex, QFixed(), transform);
}