QFontEngine: get rid of userData() trickery
it is only used by QWin32PrintEngine and we know for sure QWindowsFontEngine::handle() returns HFONT Change-Id: I7656801e4642caf7df612d2f686061dca92707e0 Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
f9f2107cef
commit
bb8c24e467
@ -356,14 +356,11 @@ public:
|
||||
GlyphFormat glyphFormat;
|
||||
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
|
||||
|
||||
inline QVariant userData() const { return m_userData; }
|
||||
|
||||
protected:
|
||||
explicit QFontEngine(Type type);
|
||||
|
||||
QFixed lastRightBearing(const QGlyphLayout &glyphs);
|
||||
|
||||
inline void setUserData(const QVariant &userData) { m_userData = userData; }
|
||||
QFixed calculatedCapHeight() const;
|
||||
|
||||
mutable QFixed m_ascent;
|
||||
@ -390,8 +387,6 @@ private:
|
||||
mutable QHash<const void *, GlyphCaches> m_glyphCaches;
|
||||
|
||||
private:
|
||||
QVariant m_userData;
|
||||
|
||||
mutable qreal m_minLeftBearing;
|
||||
mutable qreal m_minRightBearing;
|
||||
};
|
||||
|
@ -255,13 +255,6 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
||||
if (!resolvedGetCharWidthI)
|
||||
resolveGetCharWidthI();
|
||||
|
||||
// ### Properties accessed by QWin32PrintEngine (QtPrintSupport)
|
||||
QVariantMap userData;
|
||||
userData.insert(QStringLiteral("logFont"), QVariant::fromValue(m_logfont));
|
||||
userData.insert(QStringLiteral("hFont"), QVariant::fromValue(hfont));
|
||||
userData.insert(QStringLiteral("trueType"), QVariant(bool(ttf)));
|
||||
setUserData(userData);
|
||||
|
||||
hasUnreliableOutline = (tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)) == 0;
|
||||
}
|
||||
|
||||
|
@ -64,9 +64,6 @@
|
||||
#include <QtCore/qt_windows.h>
|
||||
#include <QtGui/qpagelayout.h>
|
||||
|
||||
Q_DECLARE_METATYPE(HFONT)
|
||||
Q_DECLARE_METATYPE(LOGFONT)
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
|
||||
@ -291,19 +288,16 @@ void QWin32PrintEngine::drawTextItem(const QPointF &p, const QTextItem &textItem
|
||||
bool fallBack = state->pen().brush().style() != Qt::SolidPattern
|
||||
|| qAlpha(brushColor) != 0xff
|
||||
|| d->txop >= QTransform::TxProject
|
||||
|| ti.fontEngine->type() != QFontEngine::Win
|
||||
|| !d->embed_fonts;
|
||||
|
||||
if (!fallBack) {
|
||||
const QVariantMap userData = ti.fontEngine->userData().toMap();
|
||||
const QVariant hFontV = userData.value(QStringLiteral("hFont"));
|
||||
const QVariant logFontV = userData.value(QStringLiteral("logFont"));
|
||||
if (hFontV.canConvert<HFONT>() && logFontV.canConvert<LOGFONT>()) {
|
||||
const HFONT hfont = hFontV.value<HFONT>();
|
||||
const LOGFONT logFont = logFontV.value<LOGFONT>();
|
||||
if (!fallBack && ti.fontEngine->type() == QFontEngine::Win) {
|
||||
if (HFONT hfont = static_cast<HFONT>(ti.fontEngine->handle())) {
|
||||
// Try selecting the font to see if we get a substitution font
|
||||
SelectObject(d->hdc, hfont);
|
||||
if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
|
||||
LOGFONT logFont;
|
||||
GetObject(hfont, sizeof(LOGFONT), &logFont);
|
||||
|
||||
wchar_t n[64];
|
||||
GetTextFace(d->hdc, 64, n);
|
||||
fallBack = QString::fromWCharArray(n)
|
||||
@ -1730,11 +1724,8 @@ static void draw_text_item_win(const QPointF &pos, const QTextItemInt &ti, HDC h
|
||||
HFONT hfont = 0;
|
||||
|
||||
if (ti.fontEngine->type() == QFontEngine::Win) {
|
||||
const QVariantMap userData = ti.fontEngine->userData().toMap();
|
||||
const QVariant hfontV = userData.value(QStringLiteral("hFont"));
|
||||
const QVariant ttfV = userData.value(QStringLiteral("trueType"));
|
||||
if (ttfV.toBool() && hfontV.canConvert<HFONT>())
|
||||
hfont = hfontV.value<HFONT>();
|
||||
if (ti.fontEngine->supportsTransformation(QTransform::fromScale(0.5, 0.5))) // is TrueType font?
|
||||
hfont = static_cast<HFONT>(ti.fontEngine->handle());
|
||||
}
|
||||
|
||||
if (!hfont)
|
||||
|
Loading…
Reference in New Issue
Block a user