| OLD | NEW |
| 1 /* | 1 /* |
| 2 ******************************************************************************* | 2 ******************************************************************************* |
| 3 * | 3 * |
| 4 * Copyright (C) 1999-2013, International Business Machines | 4 * Copyright (C) 1999-2015, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ******************************************************************************* | 7 ******************************************************************************* |
| 8 * file name: PortableFontInstance.cpp | 8 * file name: PortableFontInstance.cpp |
| 9 * | 9 * |
| 10 * created on: 11/22/1999 | 10 * created on: 11/22/1999 |
| 11 * created by: Eric R. Mader | 11 * created by: Eric R. Mader |
| 12 */ | 12 */ |
| 13 | 13 |
| 14 #include <stdio.h> | 14 #include <stdio.h> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 | 90 |
| 91 if (fFile == NULL) { | 91 if (fFile == NULL) { |
| 92 printf("%s:%d: %s: FNF\n", __FILE__, __LINE__, fileName); | 92 printf("%s:%d: %s: FNF\n", __FILE__, __LINE__, fileName); |
| 93 status = LE_FONT_FILE_NOT_FOUND_ERROR; | 93 status = LE_FONT_FILE_NOT_FOUND_ERROR; |
| 94 return; | 94 return; |
| 95 } | 95 } |
| 96 | 96 |
| 97 // read in the directory | 97 // read in the directory |
| 98 SFNTDirectory tempDir; | 98 SFNTDirectory tempDir; |
| 99 | 99 |
| 100 fread(&tempDir, sizeof tempDir, 1, fFile); | 100 size_t numRead = fread(&tempDir, sizeof tempDir, 1, fFile); |
| 101 (void)numRead; |
| 101 | 102 |
| 102 le_int32 dirSize = sizeof tempDir + ((SWAPW(tempDir.numTables) - ANY_NUMBER)
* sizeof(DirectoryEntry)); | 103 le_int32 dirSize = sizeof tempDir + ((SWAPW(tempDir.numTables) - ANY_NUMBER)
* sizeof(DirectoryEntry)); |
| 103 const LETag headTag = LE_HEAD_TABLE_TAG; | 104 const LETag headTag = LE_HEAD_TABLE_TAG; |
| 104 const LETag hheaTag = LE_HHEA_TABLE_TAG; | 105 const LETag hheaTag = LE_HHEA_TABLE_TAG; |
| 105 const HEADTable *headTable = NULL; | 106 const HEADTable *headTable = NULL; |
| 106 const HHEATable *hheaTable = NULL; | 107 const HHEATable *hheaTable = NULL; |
| 107 // const NAMETable *nameTable = NULL; | 108 // const NAMETable *nameTable = NULL; |
| 108 le_uint16 numTables = 0; | 109 le_uint16 numTables = 0; |
| 109 | 110 |
| 110 fDirectory = (const SFNTDirectory *) LE_NEW_ARRAY(char, dirSize); | 111 fDirectory = (const SFNTDirectory *) LE_NEW_ARRAY(char, dirSize); |
| 111 | 112 |
| 112 if (fDirectory == NULL) { | 113 if (fDirectory == NULL) { |
| 113 printf("%s:%d: %s: malloc err\n", __FILE__, __LINE__, fileName); | 114 printf("%s:%d: %s: malloc err\n", __FILE__, __LINE__, fileName); |
| 114 status = LE_MEMORY_ALLOCATION_ERROR; | 115 status = LE_MEMORY_ALLOCATION_ERROR; |
| 115 goto error_exit; | 116 goto error_exit; |
| 116 } | 117 } |
| 117 | 118 |
| 118 fseek(fFile, 0L, SEEK_SET); | 119 fseek(fFile, 0L, SEEK_SET); |
| 119 fread((void *) fDirectory, sizeof(char), dirSize, fFile); | 120 numRead = fread((void *) fDirectory, sizeof(char), dirSize, fFile); |
| 120 | 121 |
| 121 // | 122 // |
| 122 // We calculate these numbers 'cause some fonts | 123 // We calculate these numbers 'cause some fonts |
| 123 // have bogus values for them in the directory header. | 124 // have bogus values for them in the directory header. |
| 124 // | 125 // |
| 125 numTables = SWAPW(fDirectory->numTables); | 126 numTables = SWAPW(fDirectory->numTables); |
| 126 fDirPower = 1 << highBit(numTables); | 127 fDirPower = 1 << highBit(numTables); |
| 127 fDirExtra = numTables - fDirPower; | 128 fDirExtra = numTables - fDirPower; |
| 128 | 129 |
| 129 // read unitsPerEm from 'head' table | 130 // read unitsPerEm from 'head' table |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 *length = 0; | 236 *length = 0; |
| 236 return NULL; | 237 return NULL; |
| 237 } | 238 } |
| 238 | 239 |
| 239 *length = SWAPL(entry->length); | 240 *length = SWAPL(entry->length); |
| 240 | 241 |
| 241 void *table = LE_NEW_ARRAY(char, *length); | 242 void *table = LE_NEW_ARRAY(char, *length); |
| 242 | 243 |
| 243 if (table != NULL) { | 244 if (table != NULL) { |
| 244 fseek(fFile, SWAPL(entry->offset), SEEK_SET); | 245 fseek(fFile, SWAPL(entry->offset), SEEK_SET); |
| 245 fread(table, sizeof(char), *length, fFile); | 246 size_t numRead = fread(table, sizeof(char), *length, fFile); |
| 247 (void)numRead; |
| 246 } | 248 } |
| 247 | 249 |
| 248 return table; | 250 return table; |
| 249 } | 251 } |
| 250 | 252 |
| 251 const void *PortableFontInstance::getFontTable(LETag tableTag) const | |
| 252 { | |
| 253 size_t ignored; | |
| 254 return getFontTable(tableTag, ignored); | |
| 255 } | |
| 256 | |
| 257 const void *PortableFontInstance::getFontTable(LETag tableTag, size_t &length) c
onst | 253 const void *PortableFontInstance::getFontTable(LETag tableTag, size_t &length) c
onst |
| 258 { | 254 { |
| 259 return FontTableCache::find(tableTag, length); | 255 return FontTableCache::find(tableTag, length); |
| 260 } | 256 } |
| 261 | 257 |
| 262 const void *PortableFontInstance::readFontTable(LETag tableTag, size_t &length)
const | 258 const void *PortableFontInstance::readFontTable(LETag tableTag, size_t &length)
const |
| 263 { | 259 { |
| 264 le_uint32 len; | 260 le_uint32 len; |
| 265 | 261 |
| 266 const void *data= readTable(tableTag, &len); | 262 const void *data= readTable(tableTag, &len); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 | 468 |
| 473 float PortableFontInstance::getScaleFactorX() const | 469 float PortableFontInstance::getScaleFactorX() const |
| 474 { | 470 { |
| 475 return 1.0; | 471 return 1.0; |
| 476 } | 472 } |
| 477 | 473 |
| 478 float PortableFontInstance::getScaleFactorY() const | 474 float PortableFontInstance::getScaleFactorY() const |
| 479 { | 475 { |
| 480 return 1.0; | 476 return 1.0; |
| 481 } | 477 } |
| OLD | NEW |