summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2010-03-19 10:24:56 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2010-03-19 10:25:34 (GMT)
commit725c2c29c192349016b1332824a7716bbb992f31 (patch)
tree076272d7de25bf03387defd3a1d41b1f21571529 /src/gui
parent3b45cff46eefcbe341f2e1adc3e864229c217226 (diff)
downloadQt-725c2c29c192349016b1332824a7716bbb992f31.zip
Qt-725c2c29c192349016b1332824a7716bbb992f31.tar.gz
Qt-725c2c29c192349016b1332824a7716bbb992f31.tar.bz2
Revert "Optimize getting bearings of a glyph on Windows for true type fonts"
This reverts commit 1ebeb971d3382aec0fff927ce2d6ea7b0452584f. This broke tst_qlistview::wordWrap in QWS
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/text/qfontengine.cpp14
-rw-r--r--src/gui/text/qfontengine_p.h3
-rw-r--r--src/gui/text/qfontengine_win.cpp24
-rw-r--r--src/gui/text/qfontengine_win_p.h2
-rw-r--r--src/gui/text/qfontmetrics.cpp21
-rw-r--r--src/gui/text/qtextlayout.cpp6
6 files changed, 11 insertions, 59 deletions
diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp
index 3ec389f..c000457 100644
--- a/src/gui/text/qfontengine.cpp
+++ b/src/gui/text/qfontengine.cpp
@@ -379,14 +379,6 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform
Q_ASSERT(positions.size() == glyphs_out.size());
}
-void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
-{
- glyph_metrics_t gi = boundingBox(glyph);
- if (leftBearing != 0)
- *leftBearing = gi.x.toReal();
- if (rightBearing != 0)
- *rightBearing = (gi.xoff - gi.x - gi.width).toReal();
-}
glyph_metrics_t QFontEngine::tightBoundingBox(const QGlyphLayout &glyphs)
{
@@ -1393,12 +1385,6 @@ glyph_metrics_t QFontEngineMulti::boundingBox(const QGlyphLayout &glyphs)
return overall;
}
-void QFontEngineMulti::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
-{
- int which = highByte(glyph);
- engine(which)->getGlyphBearings(stripped(glyph), leftBearing, rightBearing);
-}
-
void QFontEngineMulti::addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs,
QPainterPath *path, QTextItem::RenderFlags flags)
{
diff --git a/src/gui/text/qfontengine_p.h b/src/gui/text/qfontengine_p.h
index e645caf..71ab5a5 100644
--- a/src/gui/text/qfontengine_p.h
+++ b/src/gui/text/qfontengine_p.h
@@ -206,8 +206,6 @@ public:
virtual qreal minLeftBearing() const { return qreal(); }
virtual qreal minRightBearing() const { return qreal(); }
- virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
-
virtual const char *name() const = 0;
virtual bool canRender(const QChar *string, int len) = 0;
@@ -376,7 +374,6 @@ public:
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
virtual void doKerning(QGlyphLayout *, QTextEngine::ShaperFlags) const;
virtual void addOutlineToPath(qreal, qreal, const QGlyphLayout &, QPainterPath *, QTextItem::RenderFlags flags);
- virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
virtual QFixed ascent() const;
virtual QFixed descent() const;
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index a133b48..1a815d3 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -649,30 +649,6 @@ static const ushort char_table[] = {
static const int char_table_entries = sizeof(char_table)/sizeof(ushort);
-void QFontEngineWin::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing)
-{
- HDC hdc = shared_dc();
- SelectObject(hdc, hfont);
-
-#ifndef Q_WS_WINCE
- if (ttf)
-#endif
-
- {
- ABC abcWidths;
- GetCharABCWidthsI(hdc, glyph, 1, 0, &abcWidths);
- if (leftBearing)
- *leftBearing = abcWidths.abcA;
- if (rightBearing)
- *rightBearing = abcWidths.abcC;
- }
-
-#ifndef Q_WS_WINCE
- else {
- QFontEngine::getGlyphBearings(glyph, leftBearing, rightBearing);
- }
-#endif
-}
qreal QFontEngineWin::minLeftBearing() const
{
diff --git a/src/gui/text/qfontengine_win_p.h b/src/gui/text/qfontengine_win_p.h
index f19e48e..f9d8f8b 100644
--- a/src/gui/text/qfontengine_win_p.h
+++ b/src/gui/text/qfontengine_win_p.h
@@ -106,8 +106,6 @@ public:
virtual QImage alphaMapForGlyph(glyph_t, const QTransform &xform);
virtual QImage alphaRGBMapForGlyph(glyph_t t, int margin, const QTransform &xform);
- virtual void getGlyphBearings(glyph_t glyph, qreal *leftBearing = 0, qreal *rightBearing = 0);
-
int getGlyphIndexes(const QChar *ch, int numChars, QGlyphLayout *glyphs, bool mirrored) const;
void getCMap();
diff --git a/src/gui/text/qfontmetrics.cpp b/src/gui/text/qfontmetrics.cpp
index 44a18de..41d0af1 100644
--- a/src/gui/text/qfontmetrics.cpp
+++ b/src/gui/text/qfontmetrics.cpp
@@ -472,9 +472,8 @@ int QFontMetrics::leftBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- qreal lb;
- engine->getGlyphBearings(glyphs.glyphs[0], &lb);
- return qRound(lb);
+ glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
+ return qRound(gi.x);
}
/*!
@@ -507,9 +506,8 @@ int QFontMetrics::rightBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- qreal rb;
- engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
- return qRound(rb);
+ glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
+ return qRound(gi.xoff - gi.x - gi.width);
}
/*!
@@ -1319,9 +1317,8 @@ qreal QFontMetricsF::leftBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- qreal lb;
- engine->getGlyphBearings(glyphs.glyphs[0], &lb);
- return lb;
+ glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
+ return gi.x.toReal();
}
/*!
@@ -1354,10 +1351,8 @@ qreal QFontMetricsF::rightBearing(QChar ch) const
int nglyphs = 9;
engine->stringToCMap(&ch, 1, &glyphs, &nglyphs, 0);
// ### can nglyphs != 1 happen at all? Not currently I think
- qreal rb;
- engine->getGlyphBearings(glyphs.glyphs[0], 0, &rb);
- return rb;
-
+ glyph_metrics_t gi = engine->boundingBox(glyphs.glyphs[0]);
+ return (gi.xoff - gi.x - gi.width).toReal();
}
/*!
diff --git a/src/gui/text/qtextlayout.cpp b/src/gui/text/qtextlayout.cpp
index 3c0e85e..204effa 100644
--- a/src/gui/text/qtextlayout.cpp
+++ b/src/gui/text/qtextlayout.cpp
@@ -1688,9 +1688,9 @@ namespace {
if (currentPosition <= 0)
return;
- qreal rb;
- fontEngine->getGlyphBearings(currentGlyph(), 0, &rb);
- rightBearing = qMin(QFixed(), QFixed::fromReal(rb));
+ glyph_metrics_t gi = fontEngine->boundingBox(currentGlyph());
+ if (gi.isValid())
+ rightBearing = qMin(QFixed(), gi.xoff - gi.x - gi.width);
}
inline void resetRightBearing()