CoreText: Share code by using delegate constructor

Change-Id: If3d5d533f98552335517ef61cb748d0117fe3053
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
This commit is contained in:
Tor Arne Vestbø 2018-11-24 23:42:32 +01:00
parent 9dd2048c1a
commit 61a94d2d04
2 changed files with 10 additions and 6 deletions

View File

@ -190,10 +190,8 @@ QCoreTextFontEngine *QCoreTextFontEngine::create(const QByteArray &fontData, qre
}
QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def)
: QFontEngine(Mac)
: QCoreTextFontEngine(def)
{
fontDef = def;
transform = qt_transform_from_fontdef(fontDef);
ctfont = font;
CFRetain(ctfont);
cgFont = CTFontCopyGraphicsFont(font, NULL);
@ -201,10 +199,8 @@ QCoreTextFontEngine::QCoreTextFontEngine(CTFontRef font, const QFontDef &def)
}
QCoreTextFontEngine::QCoreTextFontEngine(CGFontRef font, const QFontDef &def)
: QFontEngine(Mac)
: QCoreTextFontEngine(def)
{
fontDef = def;
transform = qt_transform_from_fontdef(fontDef);
cgFont = font;
// Keep reference count balanced
CFRetain(cgFont);
@ -212,6 +208,13 @@ QCoreTextFontEngine::QCoreTextFontEngine(CGFontRef font, const QFontDef &def)
init();
}
QCoreTextFontEngine::QCoreTextFontEngine(const QFontDef &def)
: QFontEngine(Mac)
{
fontDef = def;
transform = qt_transform_from_fontdef(fontDef);
}
QCoreTextFontEngine::~QCoreTextFontEngine()
{
CFRelease(cgFont);

View File

@ -126,6 +126,7 @@ public:
static QCoreTextFontEngine *create(const QByteArray &fontData, qreal pixelSize, QFont::HintingPreference hintingPreference);
protected:
QCoreTextFontEngine(const QFontDef &def);
void init();
QImage imageForGlyph(glyph_t glyph, QFixed subPixelPosition, bool colorful, const QTransform &m);
void loadAdvancesForGlyphs(QVarLengthArray<CGGlyph> &cgGlyphs, QGlyphLayout *glyphs) const;