factor code constants to a tag and make it endianness dependent

This commit is contained in:
Riccardo Mottola 2017-12-12 16:30:14 +01:00
parent b89023984e
commit 9560b56f7f

View File

@ -218,6 +218,12 @@ struct writeBuf
int offset; int offset;
}; };
#ifdef __ppc__
#define TAG_CFF 0x43464620
#else
#define TAG_CFF 0x20464643
#endif
bool bool
ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton) ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
{ {
@ -233,7 +239,7 @@ ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
bool CFF = false; bool CFF = false;
for (CFIndex i = 0; i<count; i++) { for (CFIndex i = 0; i<count; i++) {
uint32_t tag = (uint32_t)(uintptr_t)CFArrayGetValueAtIndex(tags, i); uint32_t tag = (uint32_t)(uintptr_t)CFArrayGetValueAtIndex(tags, i);
if (tag == 0x43464620) // 'CFF ' if (tag == TAG_CFF) // 'CFF '
CFF = true; CFF = true;
CFDataRef data = CGFontCopyTableForTag(mFont, tag); CFDataRef data = CGFontCopyTableForTag(mFont, tag);
records[i].tag = tag; records[i].tag = tag;
@ -283,11 +289,8 @@ ScaledFontMac::GetFontFileData(FontFileDataOutput aDataCallback, void *aBaton)
uint32_t *wtable = (reinterpret_cast<uint32_t *>(table.Elements())); uint32_t *wtable = (reinterpret_cast<uint32_t *>(table.Elements()));
TableRecord *records = new TableRecord[count]; TableRecord *records = new TableRecord[count];
for (uint32_t i=3; i<(sizer/4); i+=4) { // Skip header for (uint32_t i=3; i<(sizer/4); i+=4) { // Skip header
#ifndef __ppc__
#error need little-endian version
#endif
uint32_t tag = wtable[i]; uint32_t tag = wtable[i];
if (tag == 0x43464620) // 'CFF ' if (tag == TAG_CFF)
CFF = true; CFF = true;
// We know the length from the directory, so we can simply import // We know the length from the directory, so we can simply import
// the data. We assume the table exists, and OMG if it doesn't. // the data. We assume the table exists, and OMG if it doesn't.