Windows: Streamline rawfont-lookup code.
Fix ugly warnings by MinGW: qwindowsfontdatabase.cpp: In member function '{anonymous}::TableDirectory* {anonymous}::EmbeddedFont::tableDirectoryEntry(const QByteArray&)':qwindowsfontdatabase.cpp:167:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (Q_UNLIKELY(m_fontData.size() < sizeof(OffsetSubTable))) ^ ..\..\..\..\include/QtCore/../../src/corelib/global/qcompilerdetection.h:202:49: note: in definition of macro 'Q_UNLIKELY' Change-Id: I47fac598ed1b6623146fb437c00da64d8e8b6984 Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
This commit is contained in:
parent
6ad66140b1
commit
5c24c14a0e
@ -164,25 +164,24 @@ namespace {
|
||||
{
|
||||
Q_ASSERT(tagName.size() == 4);
|
||||
quint32 tagId = *(reinterpret_cast<const quint32 *>(tagName.constData()));
|
||||
if (Q_UNLIKELY(m_fontData.size() < sizeof(OffsetSubTable)))
|
||||
const size_t fontDataSize = m_fontData.size();
|
||||
if (Q_UNLIKELY(fontDataSize < sizeof(OffsetSubTable)))
|
||||
return 0;
|
||||
|
||||
OffsetSubTable *offsetSubTable = reinterpret_cast<OffsetSubTable *>(m_fontData.data());
|
||||
TableDirectory *tableDirectory = reinterpret_cast<TableDirectory *>(offsetSubTable + 1);
|
||||
|
||||
quint16 tableCount = qFromBigEndian<quint16>(offsetSubTable->numTables);
|
||||
if (Q_UNLIKELY(quint32(m_fontData.size()) < sizeof(OffsetSubTable) + sizeof(TableDirectory) * tableCount))
|
||||
const size_t tableCount = qFromBigEndian<quint16>(offsetSubTable->numTables);
|
||||
if (Q_UNLIKELY(fontDataSize < sizeof(OffsetSubTable) + sizeof(TableDirectory) * tableCount))
|
||||
return 0;
|
||||
|
||||
TableDirectory *nameTableDirectoryEntry = 0;
|
||||
for (int i = 0; i < tableCount; ++i, ++tableDirectory) {
|
||||
if (tableDirectory->identifier == tagId) {
|
||||
nameTableDirectoryEntry = tableDirectory;
|
||||
break;
|
||||
}
|
||||
TableDirectory *tableDirectoryEnd = tableDirectory + tableCount;
|
||||
for (TableDirectory *entry = tableDirectory; entry < tableDirectoryEnd; ++entry) {
|
||||
if (entry->identifier == tagId)
|
||||
return entry;
|
||||
}
|
||||
|
||||
return nameTableDirectoryEntry;
|
||||
return 0;
|
||||
}
|
||||
|
||||
QString EmbeddedFont::familyName(TableDirectory *nameTableDirectoryEntry)
|
||||
|
Loading…
Reference in New Issue
Block a user