char *errfmt = "cmap%s";
void *errret = NULL;
OTF_cmap *cmap;
- int unicode_index = -1;
+ int unicode_bmp_index = -1, unicode_full_index = -1;
int i;
OTF_CALLOC (cmap, 1, "");
OTF_MALLOC (cmap->EncodingRecord, cmap->numTables, "");
for (i = 0; i < cmap->numTables; i++)
{
- READ_USHORT (stream, cmap->EncodingRecord[i].platformID);
- READ_USHORT (stream, cmap->EncodingRecord[i].encodingID);
+ unsigned platformID, encodingID;
+
+ READ_USHORT (stream, platformID);
+ cmap->EncodingRecord[i].platformID = platformID;
+ READ_USHORT (stream, encodingID);
+ cmap->EncodingRecord[i].encodingID = encodingID;
READ_ULONG (stream, cmap->EncodingRecord[i].offset);
- if (cmap->EncodingRecord[i].platformID == 3
- && cmap->EncodingRecord[i].encodingID == 1)
- unicode_index = i;
+ if (platformID == 0)
+ {
+ if (encodingID <= 3)
+ unicode_bmp_index = i;
+ else
+ unicode_full_index = i;
+ }
+ else if (platformID == 3)
+ {
+ if (encodingID == 1)
+ unicode_bmp_index = i;
+ else if (encodingID == 10)
+ unicode_full_index = i;
+ }
}
for (i = 0; i < cmap->numTables; i++)
{
break;
case 2:
+ OTF_ERROR (OTF_ERROR_TABLE, " (not yet supported)");
break;
case 4:
for (j = 0; j < sub6->entryCount; j++)
READ_USHORT (stream, sub6->glyphIdArray[j]);
}
+ break;
+
+ case 8:
+ {
+ OTF_EncodingSubtable8 *sub8;
+ int j;
+
+ OTF_MALLOC (sub8, 1, " (EncodingSubtable8)");
+ cmap->EncodingRecord[i].subtable.f.f8 = sub8;
+ for (j = 0; j < 8192; j++)
+ READ_BYTES (stream, sub8->is32, 8192);
+ READ_ULONG (stream, sub8->nGroups);
+ OTF_MALLOC (sub8->Groups, sub8->nGroups, " (Groups)");
+ for (j = 0; j < sub8->nGroups; j++)
+ {
+ READ_ULONG (stream, sub8->Groups[i].startCharCode);
+ READ_ULONG (stream, sub8->Groups[i].endCharCode);
+ READ_ULONG (stream, sub8->Groups[i].startGlyphID);
+ }
+ }
+ break;
+
+ case 10:
+ {
+ OTF_EncodingSubtable10 *sub10;
+ int j;
+
+ OTF_MALLOC (sub10, 1, " (EncodingSubtable10)");
+ cmap->EncodingRecord[i].subtable.f.f10 = sub10;
+ READ_ULONG (stream, sub10->startCharCode);
+ READ_ULONG (stream, sub10->numChars);
+ OTF_MALLOC (sub10->glyphs, sub10->numChars, " (GlyphCount)");
+ for (j = 0; j < sub10->numChars; j++)
+ READ_USHORT (stream, sub10->glyphs[j]);
+ }
+ break;
+
+ case 12:
+ {
+ OTF_EncodingSubtable12 *sub12;
+ int j;
+
+ OTF_MALLOC (sub12, 1, " (EncodingSubtable12)");
+ cmap->EncodingRecord[i].subtable.f.f12 = sub12;
+ READ_ULONG (stream, sub12->nGroups);
+ OTF_MALLOC (sub12->Groups, sub12->nGroups, " (Groups)");
+ for (j = 0; j < sub12->nGroups; j++)
+ {
+ READ_ULONG (stream, sub12->Groups[i].startCharCode);
+ READ_ULONG (stream, sub12->Groups[i].endCharCode);
+ READ_ULONG (stream, sub12->Groups[i].startGlyphID);
+ }
+ }
+ break;
+
+ default:
+ OTF_ERROR (OTF_ERROR_TABLE, " (invalid Subtable format)");
}
}
- if (unicode_index >= 0)
+ if (unicode_bmp_index >= 0)
{
- OTF_EncodingRecord *rec = cmap->EncodingRecord + unicode_index;
+ OTF_EncodingRecord *rec = cmap->EncodingRecord + unicode_bmp_index;
OTF_GlyphID glyph_id, max_glyph_id = 0;
OTF_CALLOC (cmap->unicode_table, 0x10000, "");