Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
improvements in the rendering of OpenType fonts on Windows
Browse files Browse the repository at this point in the history
This is essentially porting of the following commits from Qt 5:
qt/qtbase@51998eb
qt/qtbase@dde09c4
qt/qtbase@0a170be
  • Loading branch information
ashkulz committed Sep 8, 2014
1 parent b18df9f commit 5a8d870
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/gui/text/qfontengine_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,25 @@ static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc)
return otm;
}

bool QFontEngineWin::hasCFFTable() const
{
HDC hdc = shared_dc();
SelectObject(hdc, hfont);
return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR;
}

bool QFontEngineWin::hasCMapTable() const
{
HDC hdc = shared_dc();
SelectObject(hdc, hfont);
return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR;
}

void QFontEngineWin::getCMap()
{
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE);
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
cffTable = hasCFFTable();

HDC hdc = shared_dc();
SelectObject(hdc, hfont);
bool symb = false;
Expand Down Expand Up @@ -373,6 +389,7 @@ HGDIOBJ QFontEngineWin::selectDesignFont() const
{
LOGFONT f = logfont;
f.lfHeight = unitsPerEm;
f.lfWidth = 0;
HFONT designFont = CreateFontIndirect(&f);
return SelectObject(shared_dc(), designFont);
}
Expand Down Expand Up @@ -1072,7 +1089,7 @@ void QFontEngineWin::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m

bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) const
{
if (!ttf)
if (!ttf && !cffTable)
return false;
HDC hdc = shared_dc();
SelectObject(hdc, hfont);
Expand Down
3 changes: 3 additions & 0 deletions src/gui/text/qfontengine_win_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class QFontEngineWin : public QFontEngine
uint stockFont : 1;
uint ttf : 1;
uint hasOutline : 1;
uint cffTable : 1;
TEXTMETRIC tm;
int lw;
const unsigned char *cmap;
Expand All @@ -145,6 +146,8 @@ class QFontEngineWin : public QFontEngine
mutable int designAdvancesSize;

private:
bool hasCFFTable() const;
bool hasCMapTable() const;
QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
QImage::Format mask_format);

Expand Down

0 comments on commit 5a8d870

Please sign in to comment.