(read_cmap_table): Support Format 2 of cmap.
authorhanda <handa>
Tue, 2 Nov 2004 06:10:24 +0000 (06:10 +0000)
committerhanda <handa>
Tue, 2 Nov 2004 06:10:24 +0000 (06:10 +0000)
src/otfopen.c

index 60adefe..54091d0 100644 (file)
@@ -518,7 +518,36 @@ read_cmap_table (OTF *otf, OTF_Stream *stream)
          break;
 
        case 2:
-         OTF_ERROR (OTF_ERROR_TABLE, " (not yet supported)");
+         {
+           OTF_EncodingSubtable2 *sub2;
+           int j, max_key, remaining_bytes;
+
+           OTF_MALLOC (sub2, 1, " (EncodingSubtable2)");
+           cmap->EncodingRecord[i].subtable.f.f2 = sub2;
+           for (j = 0, max_key = 0; j < 256; j++)
+             {
+               READ_USHORT (stream, sub2->subHeaderKeys[j]);
+               if (max_key < sub2->subHeaderKeys[j])
+                 max_key = sub2->subHeaderKeys[j];
+             }
+           max_key += 8;
+           sub2->subHeaderCount = max_key / 8;
+           OTF_MALLOC (sub2->subHeaders, max_key / 8, " (subHeaders)");
+           for (j = 0; j < sub2->subHeaderCount; j++)
+             {
+               READ_USHORT (stream, sub2->subHeaders[j].firstCode);
+               READ_USHORT (stream, sub2->subHeaders[j].entryCount);
+               READ_SHORT (stream, sub2->subHeaders[j].idDelta);
+               READ_USHORT (stream, sub2->subHeaders[j].idRangeOffset);
+               /* Make it offset from sub2->glyphIndexArray.  */
+               sub2->subHeaders[j].idRangeOffset -= max_key - (j * 8 + 6);
+             }
+           sub2->glyphIndexCount = (cmap->EncodingRecord[i].subtable.length
+                                    - 262 - max_key);
+           OTF_MALLOC (sub2->glyphIndexArray, sub2->glyphIndexCount,
+                       " (glyphIndexArray)");
+           READ_BYTES (stream, sub2->glyphIndexArray, sub2->glyphIndexCount);
+         }
          break;
 
        case 4: