(read_cmap_uvs_table): New function.
authorhanda <handa>
Mon, 22 Dec 2008 05:52:33 +0000 (05:52 +0000)
committerhanda <handa>
Mon, 22 Dec 2008 05:52:33 +0000 (05:52 +0000)
(read_cmap_table): Handle format 14 (Unicode Variation Sequences).
Not yet completed.

src/otfopen.c

index 2a7f989..443b822 100644 (file)
@@ -495,6 +495,21 @@ read_name_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 \f
 /*** (1-4) "cmap" table */
 
+static OTF_EncodingSubtable14 *
+read_cmap_uvs_table (OTF *otf, OTF_Stream *stream, int nbytes)
+{
+  OTF_EncodingSubtable14 *sub14;
+  char *errfmt = "cmap-uvs%s";
+  void *errret = NULL;
+  int i;
+
+  OTF_MALLOC (sub14, 1, " (EncodingSubtable14)");
+  sub14->nbytes = nbytes;
+  OTF_MALLOC (sub14->data, nbytes, " (EncodingSubtable14-Data)");
+  READ_BYTES (stream, sub14->data, nbytes);
+  return sub14;
+}
+
 static void *
 read_cmap_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
 {
@@ -540,15 +555,23 @@ read_cmap_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
       SEEK_STREAM (stream, cmap->EncodingRecord[i].offset);
       READ_USHORT (stream, format);
       cmap->EncodingRecord[i].subtable.format = format;
-      READ_USHORT (stream, cmap->EncodingRecord[i].subtable.length);
-      if (format == 8 || format == 10 || format == 12)
+      if (format == 14)
        {
-         READ_ULONG (stream, cmap->EncodingRecord[i].subtable.length);
-         READ_ULONG (stream, cmap->EncodingRecord[i].subtable.language);
+         READ_ULONG (stream, cmap->EncodingRecord[i].subtable.length);     
+         cmap->EncodingRecord[i].subtable.language = 0;
        }
       else
        {
-         READ_USHORT (stream, cmap->EncodingRecord[i].subtable.language);
+         READ_USHORT (stream, cmap->EncodingRecord[i].subtable.length);
+         if (format == 8 || format == 10 || format == 12)
+           {
+             READ_ULONG (stream, cmap->EncodingRecord[i].subtable.length);
+             READ_ULONG (stream, cmap->EncodingRecord[i].subtable.language);
+           }
+         else
+           {
+             READ_USHORT (stream, cmap->EncodingRecord[i].subtable.language);
+           }
        }
       switch (format)
        {
@@ -705,6 +728,15 @@ read_cmap_table (OTF *otf, OTF_TableInfo *table, enum OTF_ReaderFlag flag)
          }
          break;
 
+       case 14:
+         {
+           cmap->EncodingRecord[i].subtable.f.f14
+             = read_cmap_uvs_table (otf, stream,
+                                    cmap->EncodingRecord[i].subtable.length
+                                    - 6);
+           break;
+         }
+
        default:
          OTF_ERROR (OTF_ERROR_TABLE, " (invalid Subtable format)");
        }