QWindowsFontDatabase::QWindowsFontDatabase() :
m_fontEngineData(new QWindowsFontEngineData)
{
+ // Properties accessed by QWin32PrintEngine (QtPrintSupport)
+ static const int hfontMetaTypeId = qRegisterMetaType<HFONT>();
+ static const int logFontMetaTypeId = qRegisterMetaType<LOGFONT>();
+ Q_UNUSED(hfontMetaTypeId)
+ Q_UNUSED(logFontMetaTypeId)
+
if (QWindowsContext::verboseFonts)
qDebug() << __FUNCTION__ << "Clear type: "
<< m_fontEngineData->clearTypeEnabled << "gamma: "
QWindowsFontEngine::QWindowsFontEngine(const QString &name,
HFONT _hfont, bool stockFontIn, LOGFONT lf,
- QSharedPointer<QWindowsFontEngineData> fontEngineData) :
+ const QSharedPointer<QWindowsFontEngineData> &fontEngineData) :
m_fontEngineData(fontEngineData),
_name(name),
hfont(_hfont),
const QString fam = fallbacks.at(at-1);
QWindowsFontEngine *fe = static_cast<QWindowsFontEngine*>(engines.at(0));
- LOGFONT lf = fe->logfont();
+ LOGFONT lf = fe->logFont();
memcpy(lf.lfFaceName, fam.utf16(), sizeof(wchar_t) * qMin(fam.length() + 1, 32)); // 32 = Windows hard-coded
HFONT hfont = CreateFontIndirect(&lf);
#include <QtGui/QImage>
#include <QtCore/QSharedPointer>
+#include <QtCore/QMetaType>
#include "qtwindows_additional.h"
class QWindowsFontEngine : public QFontEngine
{
- Q_DISABLE_COPY(QWindowsFontEngine)
+ Q_OBJECT
+ Q_PROPERTY(HFONT hFont READ hFont STORED false)
+ Q_PROPERTY(LOGFONT logFont READ logFont STORED false)
+ Q_PROPERTY(bool trueType READ trueType STORED false)
+
public:
QWindowsFontEngine(const QString &name, HFONT, bool, LOGFONT,
- QSharedPointer<QWindowsFontEngineData> fontEngineData);
+ const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
~QWindowsFontEngine();
void initFontInfo(const QFontDef &request,
bool getOutlineMetrics(glyph_t glyph, const QTransform &t, glyph_metrics_t *metrics) const;
- QSharedPointer<QWindowsFontEngineData> fontEngineData() const { return m_fontEngineData; }
- LOGFONT logfont() const { return m_logfont; }
+ const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
+
+ // Properties accessed by QWin32PrintEngine (QtPrintSupport)
+ LOGFONT logFont() const { return m_logfont; }
+ HFONT hFont() const { return hfont; }
+ bool trueType() const { return ttf; }
+
void setUniqueFamilyName(const QString &newName) { uniqueFamilyName = newName; }
private:
QT_END_NAMESPACE
+Q_DECLARE_METATYPE(HFONT)
+Q_DECLARE_METATYPE(LOGFONT)
+
#endif // QWINDOWSFONTENGINE_H
#include <qpa/qplatformpixmap.h>
#include <private/qpicture_p.h>
#include <private/qpixmap_raster_p.h>
+#include <QtCore/QMetaType>
+#include <QtCore/qt_windows.h>
+
+Q_DECLARE_METATYPE(HFONT)
+Q_DECLARE_METATYPE(LOGFONT)
QT_BEGIN_NAMESPACE
|| d->txop >= QTransform::TxProject
|| ti.fontEngine->type() != QFontEngine::Win;
-
-#if 0
if (!fallBack) {
- QFontEngineWin *fe = static_cast<QFontEngineWin *>(ti.fontEngine);
-
- // Try selecting the font to see if we get a substitution font
- SelectObject(d->hdc, fe->hfont);
-
- if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
- wchar_t n[64];
- GetTextFace(d->hdc, 64, n);
- fallBack = QString::fromWCharArray(n)
- != QString::fromWCharArray(fe->logfont.lfFaceName);
+ const QVariant hFontV = ti.fontEngine->property("hFont");
+ const QVariant logFontV = ti.fontEngine->property("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
+ SelectObject(d->hdc, hfont);
+ if (GetDeviceCaps(d->hdc, TECHNOLOGY) != DT_CHARSTREAM) {
+ wchar_t n[64];
+ GetTextFace(d->hdc, 64, n);
+ fallBack = QString::fromWCharArray(n)
+ != QString::fromWCharArray(logFont.lfFaceName);
+ }
}
}
-#endif
if (fallBack) {
SetTextAlign(hdc, TA_BASELINE);
SetBkMode(hdc, TRANSPARENT);
- bool has_kerning = ti.f && ti.f->kerning();
-// ### TODO
-// QFontEngineWin *winfe = (fe->type() == QFontEngine::Win) ? static_cast<QFontEngineWin *>(fe) : 0;
+ const bool has_kerning = ti.f && ti.f->kerning();
- HFONT hfont;
+ HFONT hfont = 0;
bool ttf = false;
-// if (winfe) {
-// hfont = winfe->hfont;
-// ttf = winfe->ttf;
-// } else {
+ if (ti.fontEngine->type() == QFontEngine::Win) {
+ const QVariant hfontV = ti.fontEngine->property("hFont");
+ const QVariant ttfV = ti.fontEngine->property("trueType");
+ if (ttfV.type() == QVariant::Bool && hfontV.canConvert<HFONT>()) {
+ hfont = hfontV.value<HFONT>();
+ ttf = ttfV.toBool();
+ }
+ }
+
+ if (!hfont)
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
-// }
HGDIOBJ old_font = SelectObject(hdc, hfont);
unsigned int options = (ttf && !convertToText) ? ETO_GLYPH_INDEX : 0;