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;
|
GlyphFormat glyphFormat;
|
||||||
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
|
int m_subPixelPositionCount; // Number of positions within a single pixel for this cache
|
||||||
|
|
||||||
inline QVariant userData() const { return m_userData; }
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit QFontEngine(Type type);
|
explicit QFontEngine(Type type);
|
||||||
|
|
||||||
QFixed lastRightBearing(const QGlyphLayout &glyphs);
|
QFixed lastRightBearing(const QGlyphLayout &glyphs);
|
||||||
|
|
||||||
inline void setUserData(const QVariant &userData) { m_userData = userData; }
|
|
||||||
QFixed calculatedCapHeight() const;
|
QFixed calculatedCapHeight() const;
|
||||||
|
|
||||||
mutable QFixed m_ascent;
|
mutable QFixed m_ascent;
|
||||||
@ -390,8 +387,6 @@ private:
|
|||||||
mutable QHash<const void *, GlyphCaches> m_glyphCaches;
|
mutable QHash<const void *, GlyphCaches> m_glyphCaches;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QVariant m_userData;
|
|
||||||
|
|
||||||
mutable qreal m_minLeftBearing;
|
mutable qreal m_minLeftBearing;
|
||||||
mutable qreal m_minRightBearing;
|
mutable qreal m_minRightBearing;
|
||||||
};
|
};
|
||||||
|
@ -255,13 +255,6 @@ QWindowsFontEngine::QWindowsFontEngine(const QString &name,
|
|||||||
if (!resolvedGetCharWidthI)
|
if (!resolvedGetCharWidthI)
|
||||||
resolveGetCharWidthI();
|
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;
|
hasUnreliableOutline = (tm.tmPitchAndFamily & (TMPF_TRUETYPE | TMPF_VECTOR)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,9 +64,6 @@
|
|||||||
#include <QtCore/qt_windows.h>
|
#include <QtCore/qt_windows.h>
|
||||||
#include <QtGui/qpagelayout.h>
|
#include <QtGui/qpagelayout.h>
|
||||||
|
|
||||||
Q_DECLARE_METATYPE(HFONT)
|
|
||||||
Q_DECLARE_METATYPE(LOGFONT)
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
Q_GUI_EXPORT HBITMAP qt_pixmapToWinHBITMAP(const QPixmap &p, int hbitmapFormat = 0);
|
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
|
bool fallBack = state->pen().brush().style() != Qt::SolidPattern
|
||||||
|| qAlpha(brushColor) != 0xff
|
|| qAlpha(brushColor) != 0xff
|
||||||
|| d->txop >= QTransform::TxProject
|
|| d->txop >= QTransform::TxProject
|
||||||
|| ti.fontEngine->type() != QFontEngine::Win
|
|
||||||
|| !d->embed_fonts;
|
|| !d->embed_fonts;
|
||||||
|
|
||||||
if (!fallBack) {
|
if (!fallBack && ti.fontEngine->type() == QFontEngine::Win) {
|
||||||
const QVariantMap userData = ti.fontEngine->userData().toMap();
|
if (HFONT hfont = static_cast<HFONT>(ti.fontEngine->handle())) {
|
||||||
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>();
|
|
||||||
// Try selecting the font to see if we get a substitution font
|
// Try selecting the font to see if we get a substitution font
|
||||||
SelectObject(d->hdc, hfont);
|
SelectObject(d->hdc, hfont);
|
||||||
if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
|
if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
|
||||||
|
LOGFONT logFont;
|
||||||
|
GetObject(hfont, sizeof(LOGFONT), &logFont);
|
||||||
|
|
||||||
wchar_t n[64];
|
wchar_t n[64];
|
||||||
GetTextFace(d->hdc, 64, n);
|
GetTextFace(d->hdc, 64, n);
|
||||||
fallBack = QString::fromWCharArray(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;
|
HFONT hfont = 0;
|
||||||
|
|
||||||
if (ti.fontEngine->type() == QFontEngine::Win) {
|
if (ti.fontEngine->type() == QFontEngine::Win) {
|
||||||
const QVariantMap userData = ti.fontEngine->userData().toMap();
|
if (ti.fontEngine->supportsTransformation(QTransform::fromScale(0.5, 0.5))) // is TrueType font?
|
||||||
const QVariant hfontV = userData.value(QStringLiteral("hFont"));
|
hfont = static_cast<HFONT>(ti.fontEngine->handle());
|
||||||
const QVariant ttfV = userData.value(QStringLiteral("trueType"));
|
|
||||||
if (ttfV.toBool() && hfontV.canConvert<HFONT>())
|
|
||||||
hfont = hfontV.value<HFONT>();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hfont)
|
if (!hfont)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user