Use QFont::Tag in the Windows font database implementation
Replace the local MAKE_TAG macro definition with QFont::Tag's support conversions to and from big endian byte ordering. Also replace the incorrect usage of the big-endian-producing MAKE_TAG macro in the DirectWrite implementation. The IDWriteFontFace documentation suggests to use the DWRITE_MAKE_OPENTYPE_TAG macro for producting the tag, which is equivalent to the LittleEndian implementation of QFont::Tag::value. Task-number: QTBUG-117046 Change-Id: I1e522c1c6006b8bcf66110bd74a36a42ed28f7e4 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
bde443801f
commit
eb02561f58
@ -153,7 +153,7 @@ void QWindowsDirectWriteFontDatabase::populateFamily(const QString &familyName)
|
|||||||
UINT32 tableSize;
|
UINT32 tableSize;
|
||||||
void *tableContext = nullptr;
|
void *tableContext = nullptr;
|
||||||
BOOL exists;
|
BOOL exists;
|
||||||
HRESULT hr = face->TryGetFontTable(qbswap<quint32>(MAKE_TAG('O','S','/','2')),
|
HRESULT hr = face->TryGetFontTable(qFromBigEndian(QFont::Tag("OS/2").value()),
|
||||||
&tableData,
|
&tableData,
|
||||||
&tableSize,
|
&tableSize,
|
||||||
&tableContext,
|
&tableContext,
|
||||||
|
@ -192,17 +192,6 @@ static inline QFontDatabase::WritingSystem writingSystemFromCharSet(uchar charSe
|
|||||||
return QFontDatabase::Any;
|
return QFontDatabase::Any;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MAKE_TAG
|
|
||||||
#undef MAKE_TAG
|
|
||||||
#endif
|
|
||||||
// GetFontData expects the tags in little endian ;(
|
|
||||||
#define MAKE_TAG(ch1, ch2, ch3, ch4) (\
|
|
||||||
(((quint32)(ch4)) << 24) | \
|
|
||||||
(((quint32)(ch3)) << 16) | \
|
|
||||||
(((quint32)(ch2)) << 8) | \
|
|
||||||
((quint32)(ch1)) \
|
|
||||||
)
|
|
||||||
|
|
||||||
bool qt_localizedName(const QString &name)
|
bool qt_localizedName(const QString &name)
|
||||||
{
|
{
|
||||||
const QChar *c = name.unicode();
|
const QChar *c = name.unicode();
|
||||||
@ -380,7 +369,7 @@ QString qt_getEnglishName(const QString &familyName, bool includeStyle)
|
|||||||
|
|
||||||
HGDIOBJ oldobj = SelectObject( hdc, hfont );
|
HGDIOBJ oldobj = SelectObject( hdc, hfont );
|
||||||
|
|
||||||
const DWORD name_tag = MAKE_TAG( 'n', 'a', 'm', 'e' );
|
const DWORD name_tag = qFromBigEndian(QFont::Tag("name").value());
|
||||||
|
|
||||||
// get the name table
|
// get the name table
|
||||||
unsigned char *table = 0;
|
unsigned char *table = 0;
|
||||||
@ -429,7 +418,7 @@ QFontNames qt_getCanonicalFontNames(const LOGFONT &lf)
|
|||||||
|
|
||||||
// get the name table
|
// get the name table
|
||||||
QByteArray table;
|
QByteArray table;
|
||||||
const DWORD name_tag = MAKE_TAG('n', 'a', 'm', 'e');
|
const DWORD name_tag = qFromBigEndian(QFont::Tag("name").value());
|
||||||
DWORD bytes = GetFontData(hdc, name_tag, 0, 0, 0);
|
DWORD bytes = GetFontData(hdc, name_tag, 0, 0, 0);
|
||||||
if (bytes != GDI_ERROR) {
|
if (bytes != GDI_ERROR) {
|
||||||
table.resize(bytes);
|
table.resize(bytes);
|
||||||
@ -882,11 +871,11 @@ static QList<quint32> getTrueTypeFontOffsets(const uchar *fontData, const uchar
|
|||||||
}
|
}
|
||||||
|
|
||||||
const quint32 headerTag = qFromUnaligned<quint32>(fontData);
|
const quint32 headerTag = qFromUnaligned<quint32>(fontData);
|
||||||
if (headerTag != MAKE_TAG('t', 't', 'c', 'f')) {
|
if (headerTag != qFromBigEndian(QFont::Tag("ttcf").value())) {
|
||||||
if (headerTag != MAKE_TAG(0, 1, 0, 0)
|
if (headerTag != qFromBigEndian(QFont::Tag("\0\1\0\0").value())
|
||||||
&& headerTag != MAKE_TAG('O', 'T', 'T', 'O')
|
&& headerTag != qFromBigEndian(QFont::Tag("OTTO").value())
|
||||||
&& headerTag != MAKE_TAG('t', 'r', 'u', 'e')
|
&& headerTag != qFromBigEndian(QFont::Tag("true").value())
|
||||||
&& headerTag != MAKE_TAG('t', 'y', 'p', '1')) {
|
&& headerTag != qFromBigEndian(QFont::Tag("typ1").value())) {
|
||||||
return offsets;
|
return offsets;
|
||||||
}
|
}
|
||||||
offsets << 0;
|
offsets << 0;
|
||||||
@ -959,7 +948,9 @@ static void getFamiliesAndSignatures(const QByteArray &fontData,
|
|||||||
const uchar *font = data + offsets.at(i);
|
const uchar *font = data + offsets.at(i);
|
||||||
const uchar *table;
|
const uchar *table;
|
||||||
quint32 length;
|
quint32 length;
|
||||||
getFontTable(data, dataEndSentinel, font, MAKE_TAG('n', 'a', 'm', 'e'), &table, &length);
|
getFontTable(data, dataEndSentinel, font,
|
||||||
|
qFromBigEndian(QFont::Tag("name").value()),
|
||||||
|
&table, &length);
|
||||||
if (!table)
|
if (!table)
|
||||||
continue;
|
continue;
|
||||||
QFontNames names = qt_getCanonicalFontNames(table, length);
|
QFontNames names = qt_getCanonicalFontNames(table, length);
|
||||||
@ -968,8 +959,11 @@ static void getFamiliesAndSignatures(const QByteArray &fontData,
|
|||||||
|
|
||||||
families->append(std::move(names));
|
families->append(std::move(names));
|
||||||
|
|
||||||
if (values || signatures)
|
if (values || signatures) {
|
||||||
getFontTable(data, dataEndSentinel, font, MAKE_TAG('O', 'S', '/', '2'), &table, &length);
|
getFontTable(data, dataEndSentinel, font,
|
||||||
|
qFromBigEndian(QFont::Tag("OS/2").value()),
|
||||||
|
&table, &length);
|
||||||
|
}
|
||||||
|
|
||||||
if (values) {
|
if (values) {
|
||||||
QFontValues fontValues;
|
QFontValues fontValues;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user