QFontEngine: Add handle() function
Both QFont::handle() and QFont::freetypeFace() used to
be available in Qt 4 but were removed in Qt 5. There's
currently no API to get access to the native font handle,
which the font engine holds in a way or another.
Similar to the way it was in Qt 4, the actual handle type
depends on the font engine currently in use. The types map
as follows:
Font Engine Native Handle
------------------------------------
DirectWrite IDWriteFontFace *
Freetype FT_Face
Mac CTFontRef
Win HFONT
All other font engines return a null handle.
Change-Id: I3bea8259ac1378fd24079723aa6603bf9e74834c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>
bb10
parent
72ff2a2f0d
commit
c35795b413
|
|
@ -1229,6 +1229,11 @@ int QFontEngine::glyphCount() const
|
|||
return count;
|
||||
}
|
||||
|
||||
Qt::HANDLE QFontEngine::handle() const
|
||||
{
|
||||
return Q_NULLPTR;
|
||||
}
|
||||
|
||||
const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSymbolFont, int *cmapSize)
|
||||
{
|
||||
const uchar *header = table;
|
||||
|
|
|
|||
|
|
@ -2005,6 +2005,11 @@ QFontEngine *QFontEngineFT::cloneWithSize(qreal pixelSize) const
|
|||
}
|
||||
}
|
||||
|
||||
Qt::HANDLE QFontEngineFT::handle() const
|
||||
{
|
||||
return non_locked_face();
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT_NO_FREETYPE
|
||||
|
|
|
|||
|
|
@ -283,6 +283,7 @@ private:
|
|||
void setDefaultHintStyle(HintStyle style) Q_DECL_OVERRIDE;
|
||||
|
||||
QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
|
||||
Qt::HANDLE handle() const Q_DECL_OVERRIDE;
|
||||
bool initFromFontEngine(const QFontEngineFT *fontEngine);
|
||||
|
||||
HintStyle defaultHintStyle() const { return default_hint_style; }
|
||||
|
|
|
|||
|
|
@ -229,6 +229,8 @@ public:
|
|||
|
||||
virtual QFontEngine *cloneWithSize(qreal /*pixelSize*/) const { return 0; }
|
||||
|
||||
virtual Qt::HANDLE handle() const;
|
||||
|
||||
void *harfbuzzFont() const;
|
||||
void *harfbuzzFace() const;
|
||||
bool supportsScript(QChar::Script script) const;
|
||||
|
|
|
|||
|
|
@ -738,6 +738,11 @@ QFontEngine *QCoreTextFontEngine::cloneWithSize(qreal pixelSize) const
|
|||
return new QCoreTextFontEngine(cgFont, newFontDef);
|
||||
}
|
||||
|
||||
Qt::HANDLE QCoreTextFontEngine::handle() const
|
||||
{
|
||||
return (Qt::HANDLE)ctfont;
|
||||
}
|
||||
|
||||
bool QCoreTextFontEngine::supportsTransformation(const QTransform &transform) const
|
||||
{
|
||||
if (transform.type() < QTransform::TxScale)
|
||||
|
|
|
|||
|
|
@ -101,6 +101,7 @@ public:
|
|||
bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE;
|
||||
|
||||
QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
|
||||
Qt::HANDLE handle() const Q_DECL_OVERRIDE;
|
||||
int glyphMargin(QFontEngine::GlyphFormat format) Q_DECL_OVERRIDE { Q_UNUSED(format); return 0; }
|
||||
|
||||
QFontEngine::Properties properties() const Q_DECL_OVERRIDE;
|
||||
|
|
|
|||
|
|
@ -1256,6 +1256,11 @@ QFontEngine *QWindowsFontEngine::cloneWithSize(qreal pixelSize) const
|
|||
return fontEngine;
|
||||
}
|
||||
|
||||
Qt::HANDLE QWindowsFontEngine::handle() const
|
||||
{
|
||||
return hfont;
|
||||
}
|
||||
|
||||
void QWindowsFontEngine::initFontInfo(const QFontDef &request,
|
||||
int dpi)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -108,6 +108,7 @@ public:
|
|||
glyph_metrics_t alphaMapBoundingBox(glyph_t glyph, QFixed, const QTransform &matrix, GlyphFormat) Q_DECL_OVERRIDE;
|
||||
|
||||
QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
|
||||
Qt::HANDLE handle() const Q_DECL_OVERRIDE;
|
||||
bool supportsTransformation(const QTransform &transform) const Q_DECL_OVERRIDE;
|
||||
|
||||
#ifndef Q_CC_MINGW
|
||||
|
|
|
|||
|
|
@ -639,6 +639,11 @@ QFontEngine *QWindowsFontEngineDirectWrite::cloneWithSize(qreal pixelSize) const
|
|||
return fontEngine;
|
||||
}
|
||||
|
||||
Qt::HANDLE QWindowsFontEngineDirectWrite::handle() const
|
||||
{
|
||||
return m_directWriteFontFace;
|
||||
}
|
||||
|
||||
void QWindowsFontEngineDirectWrite::initFontInfo(const QFontDef &request,
|
||||
int dpi)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -92,6 +92,7 @@ public:
|
|||
QImage alphaRGBMapForGlyph(glyph_t t, QFixed subPixelPosition, const QTransform &xform) Q_DECL_OVERRIDE;
|
||||
|
||||
QFontEngine *cloneWithSize(qreal pixelSize) const Q_DECL_OVERRIDE;
|
||||
Qt::HANDLE handle() const Q_DECL_OVERRIDE;
|
||||
|
||||
const QSharedPointer<QWindowsFontEngineData> &fontEngineData() const { return m_fontEngineData; }
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue