Make distance fields rendering work with Opentype CFF fonts
If the font has a CFF table, GDI will not label it as TMPF_TRUETYPE, however, we can still use GetFontData to get the SFNT tables. This is required to get the maxp table which contains the glyph count, which is required to use the font with the distance-field renderer. Task-number: QTBUG-28746 Change-Id: I3ca1e3d96ea53c453e6fa422b33d1f1f5050a82c Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
b8623461d1
commit
dde09c429a
@ -155,9 +155,20 @@ static OUTLINETEXTMETRIC *getOutlineTextMetric(HDC hdc)
|
|||||||
return otm;
|
return otm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWindowsFontEngine::hasCFFTable() const
|
||||||
|
{
|
||||||
|
HDC hdc = m_fontEngineData->hdc;
|
||||||
|
SelectObject(hdc, hfont);
|
||||||
|
return GetFontData(hdc, MAKE_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
void QWindowsFontEngine::getCMap()
|
void QWindowsFontEngine::getCMap()
|
||||||
{
|
{
|
||||||
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE);
|
ttf = (bool)(tm.tmPitchAndFamily & TMPF_TRUETYPE);
|
||||||
|
|
||||||
|
// TMPF_TRUETYPE is not set for fonts with CFF tables
|
||||||
|
cffTable = !ttf && hasCFFTable();
|
||||||
|
|
||||||
HDC hdc = m_fontEngineData->hdc;
|
HDC hdc = m_fontEngineData->hdc;
|
||||||
SelectObject(hdc, hfont);
|
SelectObject(hdc, hfont);
|
||||||
bool symb = false;
|
bool symb = false;
|
||||||
@ -1041,7 +1052,7 @@ void QWindowsFontEngine::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, gly
|
|||||||
|
|
||||||
bool QWindowsFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const
|
bool QWindowsFontEngine::getSfntTableData(uint tag, uchar *buffer, uint *length) const
|
||||||
{
|
{
|
||||||
if (!ttf)
|
if (!ttf && !cffTable)
|
||||||
return false;
|
return false;
|
||||||
HDC hdc = m_fontEngineData->hdc;
|
HDC hdc = m_fontEngineData->hdc;
|
||||||
SelectObject(hdc, hfont);
|
SelectObject(hdc, hfont);
|
||||||
|
@ -145,6 +145,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
|
QWindowsNativeImage *drawGDIGlyph(HFONT font, glyph_t, int margin, const QTransform &xform,
|
||||||
QImage::Format mask_format);
|
QImage::Format mask_format);
|
||||||
|
bool hasCFFTable() const;
|
||||||
|
|
||||||
const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
|
const QSharedPointer<QWindowsFontEngineData> m_fontEngineData;
|
||||||
|
|
||||||
@ -155,6 +156,7 @@ private:
|
|||||||
uint stockFont : 1;
|
uint stockFont : 1;
|
||||||
uint ttf : 1;
|
uint ttf : 1;
|
||||||
uint hasOutline : 1;
|
uint hasOutline : 1;
|
||||||
|
uint cffTable : 1;
|
||||||
TEXTMETRIC tm;
|
TEXTMETRIC tm;
|
||||||
int lw;
|
int lw;
|
||||||
const unsigned char *cmap;
|
const unsigned char *cmap;
|
||||||
|
Loading…
Reference in New Issue
Block a user