+ break;
+
+ case 6:
+ {
+ OTF_EncodingSubtable6 *sub6;
+ int j;
+
+ OTF_MALLOC (sub6, 1, " (EncodingSubtable6)");
+ cmap->EncodingRecord[i].subtable.f.f6 = sub6;
+ READ_USHORT (stream, sub6->firstCode);
+ READ_USHORT (stream, sub6->entryCount);
+ OTF_MALLOC (sub6->glyphIdArray, sub6->entryCount, " (GlyphCount)");
+ 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[j].startCharCode);
+ READ_ULONG (stream, sub12->Groups[j].endCharCode);
+ READ_ULONG (stream, sub12->Groups[j].startGlyphID);
+ }
+ }
+ break;
+
+ case 14:
+ {
+ cmap->EncodingRecord[i].subtable.f.f14
+ = read_cmap_uvs_table (otf, stream,
+ cmap->EncodingRecord[i].offset);
+ break;
+ }
+
+ default:
+ OTF_ERROR (OTF_ERROR_TABLE, " (invalid Subtable format)");
+ }
+ }
+
+ if (unicode_bmp_index >= 0)
+ {
+ OTF_EncodingRecord *rec = cmap->EncodingRecord + unicode_bmp_index;
+ OTF_GlyphID glyph_id, max_glyph_id = 0;
+
+ OTF_CALLOC (cmap->unicode_table, 0x10000, "");
+ switch (rec->subtable.format)
+ {
+ case 4:
+ {
+ OTF_EncodingSubtable4 *sub4 = rec->subtable.f.f4;
+ int segCount = sub4->segCountX2 / 2;
+
+ for (i = 0; i < segCount; i++)
+ {
+ OTF_cmapSegment *seg = sub4->segments + i;
+ int c;
+
+ if (seg->idRangeOffset == 0xFFFF)
+ for (c = seg->startCount; c <= seg->endCount; c++)
+ {
+ glyph_id = (c + seg->idDelta) % 0x10000;
+ cmap->unicode_table[c] = glyph_id;
+ if (glyph_id > max_glyph_id)
+ max_glyph_id = glyph_id;
+ }
+ else
+ for (c = seg->startCount; c <= seg->endCount && c != 0xFFFF;
+ c++)
+ {
+ glyph_id = sub4->glyphIdArray[seg->idRangeOffset
+ + (c - seg->startCount)];
+ cmap->unicode_table[c] = glyph_id;
+ if (glyph_id > max_glyph_id)
+ max_glyph_id = glyph_id;
+ }
+ }
+ }