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

Commit 5a8d870

Browse files
committed
improvements in the rendering of OpenType fonts on Windows
This is essentially porting of the following commits from Qt 5: qt/qtbase@51998eb qt/qtbase@dde09c4 qt/qtbase@0a170be
1 parent b18df9f commit 5a8d870

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/gui/text/qfontengine_win.cpp

+19-2
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,25 @@ static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc)
190190
return otm;
191191
}
192192

193+
bool QFontEngineWin::hasCFFTable() const
194+
{
195+
HDC hdc = shared_dc();
196+
SelectObject(hdc, hfont);
197+
return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR;
198+
}
199+
200+
bool QFontEngineWin::hasCMapTable() const
201+
{
202+
HDC hdc = shared_dc();
203+
SelectObject(hdc, hfont);
204+
return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR;
205+
}
206+
193207
void QFontEngineWin::getCMap()
194208
{
195-
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE);
209+
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE) || hasCMapTable();
210+
cffTable = hasCFFTable();
211+
196212
HDC hdc = shared_dc();
197213
SelectObject(hdc, hfont);
198214
bool symb = false;
@@ -373,6 +389,7 @@ HGDIOBJ QFontEngineWin::selectDesignFont() const
373389
{
374390
LOGFONT f = logfont;
375391
f.lfHeight = unitsPerEm;
392+
f.lfWidth = 0;
376393
HFONT designFont = CreateFontIndirect(&f);
377394
return SelectObject(shared_dc(), designFont);
378395
}
@@ -1072,7 +1089,7 @@ void QFontEngineWin::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_m
10721089

10731090
bool QFontEngineWin::getSfntTableData(uint tag, uchar *buffer, uint *length) const
10741091
{
1075-
if (!ttf)
1092+
if (!ttf && !cffTable)
10761093
return false;
10771094
HDC hdc = shared_dc();
10781095
SelectObject(hdc, hfont);

src/gui/text/qfontengine_win_p.h

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ class QFontEngineWin : public QFontEngine
126126
uint stockFont : 1;
127127
uint ttf : 1;
128128
uint hasOutline : 1;
129+
uint cffTable : 1;
129130
TEXTMETRIC tm;
130131
int lw;
131132
const unsigned char *cmap;
@@ -145,6 +146,8 @@ class QFontEngineWin : public QFontEngine
145146
mutable int designAdvancesSize;
146147

147148
private:
149+
bool hasCFFTable() const;
150+
bool hasCMapTable() const;
148151
QNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
149152
QImage::Format mask_format);
150153

0 commit comments

Comments
 (0)