|
Lines 444-450
int FoFiTrueType::mapNameToGID(char *nam
Link Here
|
| 444 |
return nameToGID->lookupInt(name); |
444 |
return nameToGID->lookupInt(name); |
| 445 |
} |
445 |
} |
| 446 |
|
446 |
|
| 447 |
Gushort *FoFiTrueType::getCIDToGIDMap(int *nCIDs) { |
447 |
Gushort *FoFiTrueType::getCIDToGIDMap(SafeInt *nCIDs) { |
| 448 |
FoFiType1C *ff; |
448 |
FoFiType1C *ff; |
| 449 |
Gushort *map; |
449 |
Gushort *map; |
| 450 |
int i; |
450 |
int i; |
|
Lines 552-558
void FoFiTrueType::convertToType1(char *
Link Here
|
| 552 |
} |
552 |
} |
| 553 |
|
553 |
|
| 554 |
void FoFiTrueType::convertToCIDType2(char *psName, |
554 |
void FoFiTrueType::convertToCIDType2(char *psName, |
| 555 |
Gushort *cidMap, int nCIDs, |
555 |
Gushort *cidMap, SafeInt nCIDs, |
| 556 |
GBool needVerticalMetrics, |
556 |
GBool needVerticalMetrics, |
| 557 |
FoFiOutputFunc outputFunc, |
557 |
FoFiOutputFunc outputFunc, |
| 558 |
void *outputStream) { |
558 |
void *outputStream) { |
|
Lines 586-592
void FoFiTrueType::convertToCIDType2(cha
Link Here
|
| 586 |
(*outputFunc)(outputStream, " end def\n", 10); |
586 |
(*outputFunc)(outputStream, " end def\n", 10); |
| 587 |
(*outputFunc)(outputStream, "/GDBytes 2 def\n", 15); |
587 |
(*outputFunc)(outputStream, "/GDBytes 2 def\n", 15); |
| 588 |
if (cidMap) { |
588 |
if (cidMap) { |
| 589 |
buf = GooString::format("/CIDCount {0:d} def\n", nCIDs); |
589 |
buf = GooString::format("/CIDCount {0:d} def\n", nCIDs.Int()); |
| 590 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
590 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
| 591 |
delete buf; |
591 |
delete buf; |
| 592 |
if (nCIDs > 32767) { |
592 |
if (nCIDs > 32767) { |
|
Lines 625-637
void FoFiTrueType::convertToCIDType2(cha
Link Here
|
| 625 |
} |
625 |
} |
| 626 |
} else { |
626 |
} else { |
| 627 |
// direct mapping - just fill the string(s) with s[i]=i |
627 |
// direct mapping - just fill the string(s) with s[i]=i |
| 628 |
buf = GooString::format("/CIDCount {0:d} def\n", nGlyphs); |
628 |
buf = GooString::format("/CIDCount {0:d} def\n", nGlyphs.Int()); |
| 629 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
629 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
| 630 |
delete buf; |
630 |
delete buf; |
| 631 |
if (nGlyphs > 32767) { |
631 |
if (nGlyphs > 32767) { |
| 632 |
(*outputFunc)(outputStream, "/CIDMap [\n", 10); |
632 |
(*outputFunc)(outputStream, "/CIDMap [\n", 10); |
| 633 |
for (i = 0; i < nGlyphs; i += 32767) { |
633 |
for (i = 0; i < nGlyphs; i += 32767) { |
| 634 |
j = nGlyphs - i < 32767 ? nGlyphs - i : 32767; |
634 |
j = nGlyphs.Int() - i < 32767 ? nGlyphs.Int() - i : 32767; |
| 635 |
buf = GooString::format(" {0:d} string 0 1 {1:d} {{\n", 2 * j, j - 1); |
635 |
buf = GooString::format(" {0:d} string 0 1 {1:d} {{\n", 2 * j, j - 1); |
| 636 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
636 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
| 637 |
delete buf; |
637 |
delete buf; |
|
Lines 647-656
void FoFiTrueType::convertToCIDType2(cha
Link Here
|
| 647 |
} |
647 |
} |
| 648 |
(*outputFunc)(outputStream, "] def\n", 6); |
648 |
(*outputFunc)(outputStream, "] def\n", 6); |
| 649 |
} else { |
649 |
} else { |
| 650 |
buf = GooString::format("/CIDMap {0:d} string\n", 2 * nGlyphs); |
650 |
buf = GooString::format("/CIDMap {0:d} string\n", 2 * nGlyphs.Int()); |
| 651 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
651 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
| 652 |
delete buf; |
652 |
delete buf; |
| 653 |
buf = GooString::format(" 0 1 {0:d} {{\n", nGlyphs - 1); |
653 |
buf = GooString::format(" 0 1 {0:d} {{\n", nGlyphs.Int() - 1); |
| 654 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
654 |
(*outputFunc)(outputStream, buf->getCString(), buf->getLength()); |
| 655 |
delete buf; |
655 |
delete buf; |
| 656 |
(*outputFunc)(outputStream, |
656 |
(*outputFunc)(outputStream, |
|
Lines 702-708
void FoFiTrueType::convertToCIDType0(cha
Link Here
|
| 702 |
delete ff; |
702 |
delete ff; |
| 703 |
} |
703 |
} |
| 704 |
|
704 |
|
| 705 |
void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, int nCIDs, |
705 |
void FoFiTrueType::convertToType0(char *psName, Gushort *cidMap, SafeInt nCIDs, |
| 706 |
GBool needVerticalMetrics, |
706 |
GBool needVerticalMetrics, |
| 707 |
FoFiOutputFunc outputFunc, |
707 |
FoFiOutputFunc outputFunc, |
| 708 |
void *outputStream) { |
708 |
void *outputStream) { |
|
Lines 720-726
void FoFiTrueType::convertToType0(char *
Link Here
|
| 720 |
delete sfntsName; |
720 |
delete sfntsName; |
| 721 |
|
721 |
|
| 722 |
// write the descendant Type 42 fonts |
722 |
// write the descendant Type 42 fonts |
| 723 |
n = cidMap ? nCIDs : nGlyphs; |
723 |
n = cidMap ? nCIDs.Int() : nGlyphs.Int(); |
| 724 |
for (i = 0; i < n; i += 256) { |
724 |
for (i = 0; i < n; i += 256) { |
| 725 |
(*outputFunc)(outputStream, "10 dict begin\n", 14); |
725 |
(*outputFunc)(outputStream, "10 dict begin\n", 14); |
| 726 |
(*outputFunc)(outputStream, "/FontName /", 11); |
726 |
(*outputFunc)(outputStream, "/FontName /", 11); |
|
Lines 884-895
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 884 |
}; |
884 |
}; |
| 885 |
GBool missingCmap, missingName, missingPost, missingOS2; |
885 |
GBool missingCmap, missingName, missingPost, missingOS2; |
| 886 |
GBool unsortedLoca, badCmapLen, abbrevHMTX; |
886 |
GBool unsortedLoca, badCmapLen, abbrevHMTX; |
| 887 |
int nZeroLengthTables; |
887 |
SafeInt nZeroLengthTables; |
| 888 |
int nHMetrics, advWidth, lsb; |
888 |
int nHMetrics, advWidth, lsb; |
| 889 |
TrueTypeLoca *locaTable; |
889 |
TrueTypeLoca *locaTable; |
| 890 |
TrueTypeTable *newTables; |
890 |
TrueTypeTable *newTables; |
| 891 |
char *newNameTab, *newCmapTab, *newHHEATab, *newHMTXTab; |
891 |
char *newNameTab, *newCmapTab, *newHHEATab, *newHMTXTab; |
| 892 |
int nNewTables, cmapIdx, cmapLen, glyfLen, newNameLen, newCmapLen, next; |
892 |
SafeInt nNewTables; |
|
|
893 |
int cmapIdx, cmapLen, glyfLen, newNameLen, newCmapLen, next; |
| 893 |
int newHHEALen, newHMTXLen; |
894 |
int newHHEALen, newHMTXLen; |
| 894 |
Guint locaChecksum, glyfChecksum, fileChecksum; |
895 |
Guint locaChecksum, glyfChecksum, fileChecksum; |
| 895 |
char *tableDir; |
896 |
char *tableDir; |
|
Lines 918-924
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 918 |
missingOS2 = seekTable("OS/2") < 0; |
919 |
missingOS2 = seekTable("OS/2") < 0; |
| 919 |
|
920 |
|
| 920 |
// read the loca table, check to see if it's sorted |
921 |
// read the loca table, check to see if it's sorted |
| 921 |
locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + 1, sizeof(TrueTypeLoca)); |
922 |
locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + SafeInt(1), sizeof(TrueTypeLoca)); |
| 922 |
unsortedLoca = gFalse; |
923 |
unsortedLoca = gFalse; |
| 923 |
i = seekTable("loca"); |
924 |
i = seekTable("loca"); |
| 924 |
pos = tables[i].offset; |
925 |
pos = tables[i].offset; |
|
Lines 997-1009
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 997 |
// the same pos value remain in the same order) |
998 |
// the same pos value remain in the same order) |
| 998 |
glyfLen = 0; // make gcc happy |
999 |
glyfLen = 0; // make gcc happy |
| 999 |
if (unsortedLoca) { |
1000 |
if (unsortedLoca) { |
| 1000 |
qsort(locaTable, nGlyphs + 1, sizeof(TrueTypeLoca), |
1001 |
qsort(locaTable, nGlyphs.Int() + 1, sizeof(TrueTypeLoca), |
| 1001 |
&cmpTrueTypeLocaOffset); |
1002 |
&cmpTrueTypeLocaOffset); |
| 1002 |
for (i = 0; i < nGlyphs; ++i) { |
1003 |
for (i = 0; i < nGlyphs; ++i) { |
| 1003 |
locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset; |
1004 |
locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset; |
| 1004 |
} |
1005 |
} |
| 1005 |
locaTable[nGlyphs].len = 0; |
1006 |
locaTable[nGlyphs.Int()].len = 0; |
| 1006 |
qsort(locaTable, nGlyphs + 1, sizeof(TrueTypeLoca), |
1007 |
qsort(locaTable, nGlyphs.Int() + 1, sizeof(TrueTypeLoca), |
| 1007 |
&cmpTrueTypeLocaIdx); |
1008 |
&cmpTrueTypeLocaIdx); |
| 1008 |
pos = 0; |
1009 |
pos = 0; |
| 1009 |
for (i = 0; i <= nGlyphs; ++i) { |
1010 |
for (i = 0; i <= nGlyphs; ++i) { |
|
Lines 1046-1052
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1046 |
// construct the new name table |
1047 |
// construct the new name table |
| 1047 |
if (name) { |
1048 |
if (name) { |
| 1048 |
n = strlen(name); |
1049 |
n = strlen(name); |
| 1049 |
newNameLen = (6 + 4*12 + 2 * (3*n + 7) + 3) & ~3; |
1050 |
newNameLen = (6 + 4*12 + 2 * (3*SafeInt(n) + 7) + 3).Int() & ~3; |
| 1050 |
newNameTab = (char *)gmalloc(newNameLen); |
1051 |
newNameTab = (char *)gmalloc(newNameLen); |
| 1051 |
memset(newNameTab, 0, newNameLen); |
1052 |
memset(newNameTab, 0, newNameLen); |
| 1052 |
newNameTab[0] = 0; // format selector |
1053 |
newNameTab[0] = 0; // format selector |
|
Lines 1151-1161
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1151 |
for (i = 0; i < newHHEALen; ++i) { |
1152 |
for (i = 0; i < newHHEALen; ++i) { |
| 1152 |
newHHEATab[i] = getU8(pos++, &ok); |
1153 |
newHHEATab[i] = getU8(pos++, &ok); |
| 1153 |
} |
1154 |
} |
| 1154 |
newHHEATab[34] = nGlyphs >> 8; |
1155 |
newHHEATab[34] = nGlyphs.Int() >> 8; |
| 1155 |
newHHEATab[35] = nGlyphs & 0xff; |
1156 |
newHHEATab[35] = nGlyphs.Int() & 0xff; |
| 1156 |
i = seekTable("hmtx"); |
1157 |
i = seekTable("hmtx"); |
| 1157 |
pos = tables[i].offset; |
1158 |
pos = tables[i].offset; |
| 1158 |
newHMTXLen = 4 * nGlyphs; |
1159 |
newHMTXLen = (4 * nGlyphs).Int(); |
| 1159 |
newHMTXTab = (char *)gmalloc(newHMTXLen); |
1160 |
newHMTXTab = (char *)gmalloc(newHMTXLen); |
| 1160 |
advWidth = 0; |
1161 |
advWidth = 0; |
| 1161 |
for (i = 0; i < nHMetrics; ++i) { |
1162 |
for (i = 0; i < nHMetrics; ++i) { |
|
Lines 1211-1217
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1211 |
} else if (newTables[j].tag == cmapTag && badCmapLen) { |
1212 |
} else if (newTables[j].tag == cmapTag && badCmapLen) { |
| 1212 |
newTables[j].len = cmapLen; |
1213 |
newTables[j].len = cmapLen; |
| 1213 |
} else if (newTables[j].tag == locaTag && unsortedLoca) { |
1214 |
} else if (newTables[j].tag == locaTag && unsortedLoca) { |
| 1214 |
newTables[j].len = (nGlyphs + 1) * (locaFmt ? 4 : 2); |
1215 |
newTables[j].len = (nGlyphs.Int() + 1) * (locaFmt ? 4 : 2); |
| 1215 |
newTables[j].checksum = locaChecksum; |
1216 |
newTables[j].checksum = locaChecksum; |
| 1216 |
} else if (newTables[j].tag == glyfTag && unsortedLoca) { |
1217 |
} else if (newTables[j].tag == glyfTag && unsortedLoca) { |
| 1217 |
newTables[j].len = glyfLen; |
1218 |
newTables[j].len = glyfLen; |
|
Lines 1272-1280
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1272 |
newTables[j].len = sizeof(os2Tab); |
1273 |
newTables[j].len = sizeof(os2Tab); |
| 1273 |
++j; |
1274 |
++j; |
| 1274 |
} |
1275 |
} |
| 1275 |
qsort(newTables, nNewTables, sizeof(TrueTypeTable), |
1276 |
qsort(newTables, nNewTables.Int(), sizeof(TrueTypeTable), |
| 1276 |
&cmpTrueTypeTableTag); |
1277 |
&cmpTrueTypeTableTag); |
| 1277 |
pos = 12 + nNewTables * 16; |
1278 |
pos = 12 + nNewTables.Int() * 16; |
| 1278 |
for (i = 0; i < nNewTables; ++i) { |
1279 |
for (i = 0; i < nNewTables; ++i) { |
| 1279 |
newTables[i].offset = pos; |
1280 |
newTables[i].offset = pos; |
| 1280 |
pos += newTables[i].len; |
1281 |
pos += newTables[i].len; |
|
Lines 1284-1303
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1284 |
} |
1285 |
} |
| 1285 |
|
1286 |
|
| 1286 |
// write the table directory |
1287 |
// write the table directory |
| 1287 |
tableDir = (char *)gmalloc(12 + nNewTables * 16); |
1288 |
tableDir = (char *)gmalloc((SafeInt(12) + nNewTables * SafeInt(16)).Int()); |
| 1288 |
tableDir[0] = 0x00; // sfnt version |
1289 |
tableDir[0] = 0x00; // sfnt version |
| 1289 |
tableDir[1] = 0x01; |
1290 |
tableDir[1] = 0x01; |
| 1290 |
tableDir[2] = 0x00; |
1291 |
tableDir[2] = 0x00; |
| 1291 |
tableDir[3] = 0x00; |
1292 |
tableDir[3] = 0x00; |
| 1292 |
tableDir[4] = (char)((nNewTables >> 8) & 0xff); // numTables |
1293 |
tableDir[4] = (char)((nNewTables.Int() >> 8) & 0xff); // numTables |
| 1293 |
tableDir[5] = (char)(nNewTables & 0xff); |
1294 |
tableDir[5] = (char)(nNewTables.Int() & 0xff); |
| 1294 |
for (i = -1, t = (Guint)nNewTables; t; ++i, t >>= 1) ; |
1295 |
for (i = -1, t = (Guint)nNewTables.Int(); t; ++i, t >>= 1) ; |
| 1295 |
t = 1 << (4 + i); |
1296 |
t = 1 << (4 + i); |
| 1296 |
tableDir[6] = (char)((t >> 8) & 0xff); // searchRange |
1297 |
tableDir[6] = (char)((t >> 8) & 0xff); // searchRange |
| 1297 |
tableDir[7] = (char)(t & 0xff); |
1298 |
tableDir[7] = (char)(t & 0xff); |
| 1298 |
tableDir[8] = (char)((i >> 8) & 0xff); // entrySelector |
1299 |
tableDir[8] = (char)((i >> 8) & 0xff); // entrySelector |
| 1299 |
tableDir[9] = (char)(i & 0xff); |
1300 |
tableDir[9] = (char)(i & 0xff); |
| 1300 |
t = nNewTables * 16 - t; |
1301 |
t = nNewTables.Int() * 16 - t; |
| 1301 |
tableDir[10] = (char)((t >> 8) & 0xff); // rangeShift |
1302 |
tableDir[10] = (char)((t >> 8) & 0xff); // rangeShift |
| 1302 |
tableDir[11] = (char)(t & 0xff); |
1303 |
tableDir[11] = (char)(t & 0xff); |
| 1303 |
pos = 12; |
1304 |
pos = 12; |
|
Lines 1320-1330
void FoFiTrueType::writeTTF(FoFiOutputFu
Link Here
|
| 1320 |
tableDir[pos+15] = (char) newTables[i].len; |
1321 |
tableDir[pos+15] = (char) newTables[i].len; |
| 1321 |
pos += 16; |
1322 |
pos += 16; |
| 1322 |
} |
1323 |
} |
| 1323 |
(*outputFunc)(outputStream, tableDir, 12 + nNewTables * 16); |
1324 |
(*outputFunc)(outputStream, tableDir, 12 + nNewTables.Int() * 16); |
| 1324 |
|
1325 |
|
| 1325 |
// compute the file checksum |
1326 |
// compute the file checksum |
| 1326 |
fileChecksum = computeTableChecksum((Guchar *)tableDir, |
1327 |
fileChecksum = computeTableChecksum((Guchar *)tableDir, |
| 1327 |
12 + nNewTables * 16); |
1328 |
12 + nNewTables.Int() * 16); |
| 1328 |
for (i = 0; i < nNewTables; ++i) { |
1329 |
for (i = 0; i < nNewTables; ++i) { |
| 1329 |
fileChecksum += newTables[i].checksum; |
1330 |
fileChecksum += newTables[i].checksum; |
| 1330 |
} |
1331 |
} |
|
Lines 1512-1518
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1512 |
Guchar tableDir[12 + nT42Tables*16]; |
1513 |
Guchar tableDir[12 + nT42Tables*16]; |
| 1513 |
GBool ok; |
1514 |
GBool ok; |
| 1514 |
Guint checksum; |
1515 |
Guint checksum; |
| 1515 |
int nNewTables; |
1516 |
SafeInt nNewTables; |
| 1516 |
int length, pos, glyfPos, i, j, k; |
1517 |
int length, pos, glyfPos, i, j, k; |
| 1517 |
Guchar vheaTab[36] = { |
1518 |
Guchar vheaTab[36] = { |
| 1518 |
0, 1, 0, 0, // table version number |
1519 |
0, 1, 0, 0, // table version number |
|
Lines 1556-1562
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1556 |
// table, cmpTrueTypeLocaPos uses offset as its primary sort key, |
1557 |
// table, cmpTrueTypeLocaPos uses offset as its primary sort key, |
| 1557 |
// and idx as its secondary key (ensuring that adjacent entries with |
1558 |
// and idx as its secondary key (ensuring that adjacent entries with |
| 1558 |
// the same pos value remain in the same order) |
1559 |
// the same pos value remain in the same order) |
| 1559 |
locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + 1, sizeof(TrueTypeLoca)); |
1560 |
locaTable = (TrueTypeLoca *)gmallocn(nGlyphs + SafeInt(1), sizeof(TrueTypeLoca)); |
| 1560 |
i = seekTable("loca"); |
1561 |
i = seekTable("loca"); |
| 1561 |
pos = tables[i].offset; |
1562 |
pos = tables[i].offset; |
| 1562 |
ok = gTrue; |
1563 |
ok = gTrue; |
|
Lines 1568-1580
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1568 |
locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok); |
1569 |
locaTable[i].origOffset = 2 * getU16BE(pos + i*2, &ok); |
| 1569 |
} |
1570 |
} |
| 1570 |
} |
1571 |
} |
| 1571 |
qsort(locaTable, nGlyphs + 1, sizeof(TrueTypeLoca), |
1572 |
qsort(locaTable, nGlyphs.Int() + 1, sizeof(TrueTypeLoca), |
| 1572 |
&cmpTrueTypeLocaOffset); |
1573 |
&cmpTrueTypeLocaOffset); |
| 1573 |
for (i = 0; i < nGlyphs; ++i) { |
1574 |
for (i = 0; i < nGlyphs; ++i) { |
| 1574 |
locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset; |
1575 |
locaTable[i].len = locaTable[i+1].origOffset - locaTable[i].origOffset; |
| 1575 |
} |
1576 |
} |
| 1576 |
locaTable[nGlyphs].len = 0; |
1577 |
locaTable[nGlyphs.Int()].len = 0; |
| 1577 |
qsort(locaTable, nGlyphs + 1, sizeof(TrueTypeLoca), |
1578 |
qsort(locaTable, nGlyphs.Int() + 1, sizeof(TrueTypeLoca), |
| 1578 |
&cmpTrueTypeLocaIdx); |
1579 |
&cmpTrueTypeLocaIdx); |
| 1579 |
pos = 0; |
1580 |
pos = 0; |
| 1580 |
for (i = 0; i <= nGlyphs; ++i) { |
1581 |
for (i = 0; i <= nGlyphs; ++i) { |
|
Lines 1586-1592
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1586 |
} |
1587 |
} |
| 1587 |
|
1588 |
|
| 1588 |
// construct the new 'loca' table |
1589 |
// construct the new 'loca' table |
| 1589 |
locaData = (Guchar *)gmallocn(nGlyphs + 1, (locaFmt ? 4 : 2)); |
1590 |
locaData = (Guchar *)gmallocn(nGlyphs + SafeInt(1), (locaFmt ? 4 : 2)); |
| 1590 |
for (i = 0; i <= nGlyphs; ++i) { |
1591 |
for (i = 0; i <= nGlyphs; ++i) { |
| 1591 |
pos = locaTable[i].newOffset; |
1592 |
pos = locaTable[i].newOffset; |
| 1592 |
if (locaFmt) { |
1593 |
if (locaFmt) { |
|
Lines 1627-1633
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1627 |
|
1628 |
|
| 1628 |
// construct the new table headers, including table checksums |
1629 |
// construct the new table headers, including table checksums |
| 1629 |
// (pad each table out to a multiple of 4 bytes) |
1630 |
// (pad each table out to a multiple of 4 bytes) |
| 1630 |
pos = 12 + nNewTables*16; |
1631 |
pos = 12 + nNewTables.Int()*16; |
| 1631 |
k = 0; |
1632 |
k = 0; |
| 1632 |
for (i = 0; i < nT42Tables; ++i) { |
1633 |
for (i = 0; i < nT42Tables; ++i) { |
| 1633 |
length = -1; |
1634 |
length = -1; |
|
Lines 1636-1642
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1636 |
length = 54; |
1637 |
length = 54; |
| 1637 |
checksum = computeTableChecksum(headData, 54); |
1638 |
checksum = computeTableChecksum(headData, 54); |
| 1638 |
} else if (i == t42LocaTable) { |
1639 |
} else if (i == t42LocaTable) { |
| 1639 |
length = (nGlyphs + 1) * (locaFmt ? 4 : 2); |
1640 |
length = (nGlyphs.Int() + 1) * (locaFmt ? 4 : 2); |
| 1640 |
checksum = computeTableChecksum(locaData, length); |
1641 |
checksum = computeTableChecksum(locaData, length); |
| 1641 |
} else if (i == t42GlyfTable) { |
1642 |
} else if (i == t42GlyfTable) { |
| 1642 |
length = 0; |
1643 |
length = 0; |
|
Lines 1665-1671
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1665 |
length = sizeof(vheaTab); |
1666 |
length = sizeof(vheaTab); |
| 1666 |
checksum = computeTableChecksum(vheaTab, length); |
1667 |
checksum = computeTableChecksum(vheaTab, length); |
| 1667 |
} else if (needVerticalMetrics && i == t42VmtxTable) { |
1668 |
} else if (needVerticalMetrics && i == t42VmtxTable) { |
| 1668 |
length = 4 + (nGlyphs - 1) * 4; |
1669 |
length = (4 + (nGlyphs - 1) * 4).Int(); |
| 1669 |
vmtxTab = (Guchar *)gmalloc(length); |
1670 |
vmtxTab = (Guchar *)gmalloc(length); |
| 1670 |
vmtxTab[0] = advance / 256; |
1671 |
vmtxTab[0] = advance / 256; |
| 1671 |
vmtxTab[1] = advance % 256; |
1672 |
vmtxTab[1] = advance % 256; |
|
Lines 1703-1715
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1703 |
tableDir[2] = 0x00; |
1704 |
tableDir[2] = 0x00; |
| 1704 |
tableDir[3] = 0x00; |
1705 |
tableDir[3] = 0x00; |
| 1705 |
tableDir[4] = 0; // numTables |
1706 |
tableDir[4] = 0; // numTables |
| 1706 |
tableDir[5] = nNewTables; |
1707 |
tableDir[5] = nNewTables.Int(); |
| 1707 |
tableDir[6] = 0; // searchRange |
1708 |
tableDir[6] = 0; // searchRange |
| 1708 |
tableDir[7] = (Guchar)128; |
1709 |
tableDir[7] = (Guchar)128; |
| 1709 |
tableDir[8] = 0; // entrySelector |
1710 |
tableDir[8] = 0; // entrySelector |
| 1710 |
tableDir[9] = 3; |
1711 |
tableDir[9] = 3; |
| 1711 |
tableDir[10] = 0; // rangeShift |
1712 |
tableDir[10] = 0; // rangeShift |
| 1712 |
tableDir[11] = (Guchar)(16 * nNewTables - 128); |
1713 |
tableDir[11] = (Guchar)(16 * nNewTables.Int() - 128); |
| 1713 |
pos = 12; |
1714 |
pos = 12; |
| 1714 |
for (i = 0; i < nNewTables; ++i) { |
1715 |
for (i = 0; i < nNewTables; ++i) { |
| 1715 |
tableDir[pos ] = (Guchar)(newTables[i].tag >> 24); |
1716 |
tableDir[pos ] = (Guchar)(newTables[i].tag >> 24); |
|
Lines 1732-1738
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1732 |
} |
1733 |
} |
| 1733 |
|
1734 |
|
| 1734 |
// compute the font checksum and store it in the head table |
1735 |
// compute the font checksum and store it in the head table |
| 1735 |
checksum = computeTableChecksum(tableDir, 12 + nNewTables*16); |
1736 |
checksum = computeTableChecksum(tableDir, 12 + nNewTables.Int()*16); |
| 1736 |
for (i = 0; i < nNewTables; ++i) { |
1737 |
for (i = 0; i < nNewTables; ++i) { |
| 1737 |
checksum += newTables[i].checksum; |
1738 |
checksum += newTables[i].checksum; |
| 1738 |
} |
1739 |
} |
|
Lines 1752-1765
void FoFiTrueType::cvtSfnts(FoFiOutputFu
Link Here
|
| 1752 |
} |
1753 |
} |
| 1753 |
|
1754 |
|
| 1754 |
// write the table directory |
1755 |
// write the table directory |
| 1755 |
dumpString(tableDir, 12 + nNewTables*16, outputFunc, outputStream); |
1756 |
dumpString(tableDir, 12 + nNewTables.Int()*16, outputFunc, outputStream); |
| 1756 |
|
1757 |
|
| 1757 |
// write the tables |
1758 |
// write the tables |
| 1758 |
for (i = 0; i < nNewTables; ++i) { |
1759 |
for (i = 0; i < nNewTables; ++i) { |
| 1759 |
if (i == t42HeadTable) { |
1760 |
if (i == t42HeadTable) { |
| 1760 |
dumpString(headData, 54, outputFunc, outputStream); |
1761 |
dumpString(headData, 54, outputFunc, outputStream); |
| 1761 |
} else if (i == t42LocaTable) { |
1762 |
} else if (i == t42LocaTable) { |
| 1762 |
length = (nGlyphs + 1) * (locaFmt ? 4 : 2); |
1763 |
length = (nGlyphs.Int() + 1) * (locaFmt ? 4 : 2); |
| 1763 |
dumpString(locaData, length, outputFunc, outputStream); |
1764 |
dumpString(locaData, length, outputFunc, outputStream); |
| 1764 |
} else if (i == t42GlyfTable) { |
1765 |
} else if (i == t42GlyfTable) { |
| 1765 |
glyfPos = tables[seekTable("glyf")].offset; |
1766 |
glyfPos = tables[seekTable("glyf")].offset; |
|
Lines 1983-1989
void FoFiTrueType::parse() {
Link Here
|
| 1983 |
parsedOk = gFalse; |
1984 |
parsedOk = gFalse; |
| 1984 |
return; |
1985 |
return; |
| 1985 |
} |
1986 |
} |
| 1986 |
if (tables[i].len < (nGlyphs + 1) * (locaFmt ? 4 : 2)) { |
1987 |
if (tables[i].len < (nGlyphs.Int() + 1) * (locaFmt ? 4 : 2)) { |
| 1987 |
nGlyphs = tables[i].len / (locaFmt ? 4 : 2) - 1; |
1988 |
nGlyphs = tables[i].len / (locaFmt ? 4 : 2) - 1; |
| 1988 |
} |
1989 |
} |
| 1989 |
for (j = 0; j <= nGlyphs; ++j) { |
1990 |
for (j = 0; j <= nGlyphs; ++j) { |
|
Lines 2032-2038
void FoFiTrueType::readPostTable() {
Link Here
|
| 2032 |
goto err; |
2033 |
goto err; |
| 2033 |
} |
2034 |
} |
| 2034 |
if (n > nGlyphs) { |
2035 |
if (n > nGlyphs) { |
| 2035 |
n = nGlyphs; |
2036 |
n = nGlyphs.Int(); |
| 2036 |
} |
2037 |
} |
| 2037 |
stringIdx = 0; |
2038 |
stringIdx = 0; |
| 2038 |
stringPos = tablePos + 34 + 2*n; |
2039 |
stringPos = tablePos + 34 + 2*n; |