From 713282dfe41fbad1c1c940cec54227cd7c267831 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 10 Mar 2016 12:52:55 +0100 Subject: Deobfuscate SFNT tag creation on Windows The fact that we override the big endian MAKE_TAG macro (from qfontengine_p.h) with a little endian version on Windows caused some confusion and was a bug waiting to happen. This patch renames it instead to avoid future confusion. Change-Id: I6224a4bfbd80eafc849ecd82e7fe5f83ee1953af Reviewed-by: Simon Hausmann --- src/plugins/platforms/windows/qwindowsfontengine.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms/windows') diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp index c78412c8ec..143d39dc3d 100644 --- a/src/plugins/platforms/windows/qwindowsfontengine.cpp +++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp @@ -85,11 +85,8 @@ QT_BEGIN_NAMESPACE #define TT_PRIM_CSPLINE 3 #endif -#ifdef MAKE_TAG -#undef MAKE_TAG -#endif // GetFontData expects the tags in little endian ;( -#define MAKE_TAG(ch1, ch2, ch3, ch4) (\ +#define MAKE_LITTLE_ENDIAN_TAG(ch1, ch2, ch3, ch4) (\ (((quint32)(ch4)) << 24) | \ (((quint32)(ch3)) << 16) | \ (((quint32)(ch2)) << 8) | \ @@ -142,28 +139,28 @@ 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; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('C', 'F', 'F', ' '), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasCMapTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('c', 'm', 'a', 'p'), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasGlyfTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('g', 'l', 'y', 'f'), 0, 0, 0) != GDI_ERROR; } bool QWindowsFontEngine::hasEbdtTable() const { HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); - return GetFontData(hdc, MAKE_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; + return GetFontData(hdc, MAKE_LITTLE_ENDIAN_TAG('E', 'B', 'D', 'T'), 0, 0, 0) != GDI_ERROR; } static inline QString stringFromOutLineTextMetric(const OUTLINETEXTMETRIC *otm, PSTR offset) @@ -182,7 +179,7 @@ void QWindowsFontEngine::getCMap() SelectObject(hdc, hfont); bool symb = false; if (ttf) { - cmapTable = getSfntTable(qbswap(MAKE_TAG('c', 'm', 'a', 'p'))); + cmapTable = getSfntTable(MAKE_TAG('c', 'm', 'a', 'p')); cmap = QFontEngine::getCMap(reinterpret_cast(cmapTable.constData()), cmapTable.size(), &symb, &cmapSize); } @@ -956,7 +953,7 @@ int QWindowsFontEngine::synthesized() const if(synthesized_flags == -1) { synthesized_flags = 0; if(ttf) { - const DWORD HEAD = MAKE_TAG('h', 'e', 'a', 'd'); + const DWORD HEAD = MAKE_LITTLE_ENDIAN_TAG('h', 'e', 'a', 'd'); HDC hdc = m_fontEngineData->hdc; SelectObject(hdc, hfont); uchar data[4]; -- cgit v1.2.3