Adapt font engines for Windows/QPA.

Export QFontEngineMulti and glyph_metrics_t.
Implement alphaMapForGlyph() for the multifont-engines
which is called in the QPA code paths (similar to
boundingBox()).

Acked-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
This commit is contained in:
Friedemann Kleint 2011-06-29 11:19:17 +02:00
parent 57e0c157df
commit 3ffe4283b6
4 changed files with 41 additions and 6 deletions

View File

@ -3045,7 +3045,7 @@ void QRasterPaintEngine::drawTextItem(const QPointF &p, const QTextItem &textIte
ensurePen();
ensureState();
#if defined (Q_OS_WIN) || defined(Q_WS_MAC)
#if defined (Q_WS_WIN) || defined(Q_WS_MAC)
if (!supportsTransformations(ti.fontEngine)) {
QVarLengthArray<QFixedPoint> positions;

View File

@ -1674,11 +1674,42 @@ bool QFontEngineMulti::canRender(const QChar *string, int len)
return allExist;
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t)
/* Implement alphaMapForGlyph() which is called by Lighthouse/Windows code.
* Ideally, that code should be fixed to correctly handle QFontEngineMulti. */
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph)
{
Q_ASSERT(false);
return QImage();
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph));
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition)
{
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition);
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, const QTransform &t)
{
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), t);
}
QImage QFontEngineMulti::alphaMapForGlyph(glyph_t glyph, QFixed subPixelPosition, const QTransform &t)
{
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
return engine(which)->alphaMapForGlyph(stripped(glyph), subPixelPosition, t);
}
QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosition, int margin, const QTransform &t)
{
const int which = highByte(glyph);
Q_ASSERT(which < engines.size());
return engine(which)->alphaRGBMapForGlyph(stripped(glyph), subPixelPosition, margin, t);
}
QT_END_NAMESPACE

View File

@ -393,7 +393,7 @@ private:
int _size;
};
class QFontEngineMulti : public QFontEngine
class Q_GUI_EXPORT QFontEngineMulti : public QFontEngine
{
public:
explicit QFontEngineMulti(int engineCount);
@ -416,6 +416,10 @@ public:
virtual QFixed xHeight() const;
virtual QFixed averageCharWidth() const;
virtual QImage alphaMapForGlyph(glyph_t);
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 QFixed lineThickness() const;
virtual QFixed underlinePosition() const;

View File

@ -93,7 +93,7 @@ class QAbstractTextDocumentLayout;
// * negative yoff means the following stuff is drawn higher up.
// the characters bounding rect is given by QRect(x,y,width,height), its advance by
// xoo and yoff
struct glyph_metrics_t
struct Q_GUI_EXPORT glyph_metrics_t
{
inline glyph_metrics_t()
: x(100000), y(100000) {}