[gs-cvs] rev 7437 - trunk/gs/src

tor at ghostscript.com tor at ghostscript.com
Fri Dec 1 15:17:00 PST 2006


Author: tor
Date: 2006-12-01 15:17:00 -0800 (Fri, 01 Dec 2006)
New Revision: 7437

Modified:
   trunk/gs/src/gstype42.c
   trunk/gs/src/gxfcopy.c
   trunk/gs/src/gxfont42.h
   trunk/gs/src/zfont42.c
Log:
Add an argument to select a specified subfont to gs_type42_font_init. This argument is only used for truetype collection (TTC) font files.

Modified: trunk/gs/src/gstype42.c
===================================================================
--- trunk/gs/src/gstype42.c	2006-12-01 01:34:22 UTC (rev 7436)
+++ trunk/gs/src/gstype42.c	2006-12-01 23:17:00 UTC (rev 7437)
@@ -94,7 +94,7 @@
  * string_proc, and the font procedures as well.
  */
 int
-gs_type42_font_init(gs_font_type42 * pfont, bool USE_ttfReader)
+gs_type42_font_init(gs_font_type42 * pfont, int subfontID, bool USE_ttfReader)
 {
     int (*string_proc)(gs_font_type42 *, ulong, uint, const byte **) =
 	pfont->data.string_proc;
@@ -106,16 +106,28 @@
     byte head_box[8];
     ulong loca_size = 0;
     ulong glyph_start, glyph_offset, glyph_length;
+    uint numFonts;
+    uint OffsetTableOffset;
 
+    static const byte version1_0[4] = {0, 1, 0, 0};
+    static const byte version_true[4] = {'t', 'r', 'u', 'e'};
+    static const byte version_ttcf[4] = {'t', 't', 'c', 'f'};
+
     ACCESS(0, 12, OffsetTable);
+    if (!memcmp(OffsetTable, version_ttcf, 4))
     {
-	static const byte version1_0[4] = {0, 1, 0, 0};
-	static const byte version_true[4] = {'t', 'r', 'u', 'e'};
+	numFonts = U16(OffsetTable + 8);
+	if (subfontID < 0 || subfontID >= numFonts)
+	    return_error(gs_error_rangecheck);
+	ACCESS(8, numFonts * 4, OffsetTable);
+	OffsetTableOffset = u32(OffsetTable + subfontID * 4);
+	ACCESS(OffsetTableOffset, 12, OffsetTable);
+    }
 
-	if (memcmp(OffsetTable, version1_0, 4) &&
+    if (memcmp(OffsetTable, version1_0, 4) &&
 	    memcmp(OffsetTable, version_true, 4))
-	    return_error(gs_error_invalidfont);
-    }
+	return_error(gs_error_invalidfont);
+
     numTables = U16(OffsetTable + 4);
     ACCESS(12, numTables * 16, TableDirectory);
     /* Clear all non-client-supplied data. */

Modified: trunk/gs/src/gxfcopy.c
===================================================================
--- trunk/gs/src/gxfcopy.c	2006-12-01 01:34:22 UTC (rev 7436)
+++ trunk/gs/src/gxfcopy.c	2006-12-01 23:17:00 UTC (rev 7437)
@@ -1292,7 +1292,7 @@
 	psf_write_cid2_stripped(&fs, (gs_font_cid2 *)font42);
     copied42->data.string_proc = copied_type42_string_proc;
     copied42->data.proc_data = cfdata;
-    code = gs_type42_font_init(copied42, font42->data.USE_ttfReader);
+    code = gs_type42_font_init(copied42, 0, font42->data.USE_ttfReader);
     if (code < 0)
 	goto fail2;
     /* gs_type42_font_init overwrites font_info. */

Modified: trunk/gs/src/gxfont42.h
===================================================================
--- trunk/gs/src/gxfont42.h	2006-12-01 01:34:22 UTC (rev 7436)
+++ trunk/gs/src/gxfont42.h	2006-12-01 23:17:00 UTC (rev 7437)
@@ -114,7 +114,7 @@
  * USE_ttfReader subclasses gs_font_type42 with ttfReader or without.
  * FAPI will disable ttfReader as well. 
  */
-int gs_type42_font_init(gs_font_type42 *pfont, bool USE_ttfReader);
+int gs_type42_font_init(gs_font_type42 *pfont, int subfontid, bool USE_ttfReader);
 
 /* Append the outline of a TrueType character to a path. */
 int gs_type42_append(uint glyph_index, gs_state * pgs,

Modified: trunk/gs/src/zfont42.c
===================================================================
--- trunk/gs/src/zfont42.c	2006-12-01 01:34:22 UTC (rev 7436)
+++ trunk/gs/src/zfont42.c	2006-12-01 23:17:00 UTC (rev 7437)
@@ -77,7 +77,7 @@
     ref_assign(&pdata->u.type42.GlyphDirectory, &GlyphDirectory);
     pfont->data.string_proc = z42_string_proc;
     pfont->data.proc_data = (char *)pdata;
-    code = gs_type42_font_init(pfont, true /*Use ttfReader */);
+    code = gs_type42_font_init(pfont, 0, true /*Use ttfReader */);
     if (code < 0)
 	return code;
     pfont->procs.font_info = z42_font_info;



More information about the gs-cvs mailing list