[gs-cvs] rev 7074 - trunk/gs/src
stefan at ghostscript.com
stefan at ghostscript.com
Mon Oct 2 07:10:54 PDT 2006
Author: stefan
Date: 2006-10-02 07:10:53 -0700 (Mon, 02 Oct 2006)
New Revision: 7074
Modified:
trunk/gs/src/gstype42.c
trunk/gs/src/gxccman.c
trunk/gs/src/gxfcopy.c
trunk/gs/src/gxfont42.h
trunk/gs/src/zfont42.c
Log:
Add boolean USE_ttfReader to gs_type42_font_init()
In general this is always set true. If this is set false the caller
will disable the attachment of ttfReader for dynalab ttf font hinting
and the caller is expected to do all the gs_type42 font initialization
that was required prior to the addition of ttfReader to the code.
Add an early out from gs_type42_font_init() that bypasses some table
generation that isn't needed when USE_ttfReader is false. Pulling the
return statement here will reenable this code and is harmless except for
some small memory leaks.
Currently only the PXL downloaded ttf fonts use the false case init,
to render fonts with UFST not with FAPI ufst.
NO expected pdf or ps or pcl differences since the code path is identical.
Modified: trunk/gs/src/gstype42.c
===================================================================
--- trunk/gs/src/gstype42.c 2006-09-28 05:56:04 UTC (rev 7073)
+++ trunk/gs/src/gstype42.c 2006-10-02 14:10:53 UTC (rev 7074)
@@ -94,7 +94,7 @@
* string_proc, and the font procedures as well.
*/
int
-gs_type42_font_init(gs_font_type42 * pfont)
+gs_type42_font_init(gs_font_type42 * pfont, bool USE_ttfReader)
{
int (*string_proc)(gs_font_type42 *, ulong, uint, const byte **) =
pfont->data.string_proc;
@@ -193,9 +193,41 @@
pfont->data.numGlyphs = pfont->data.trueNumGlyphs;
loca_size = pfont->data.numGlyphs + 1;
}
+
+ pfont->data.warning_patented = false;
+ pfont->data.warning_bad_instruction = false;
+ pfont->procs.glyph_outline = gs_type42_glyph_outline;
+ pfont->procs.glyph_info = gs_type42_glyph_info;
+ pfont->procs.enumerate_glyph = gs_type42_enumerate_glyph;
+ pfont->procs.font_info = gs_type42_font_info;
+ pfont->data.USE_ttfReader = USE_ttfReader;
+
+ if( USE_ttfReader == false ) {
+ /* Allows specialization via different pfont->data.* functions.
+ *
+ * No extra allocations len_glyphs,
+ * the "default" data.get_* procs must be overridden.
+ * bbox must be provided.
+ *
+ * And the ttfReader in gx_add_fm_pair won't be constructed/used.
+ */
+ pfont->data.get_glyph_index = 0;
+ pfont->data.get_outline = 0;
+ pfont->data.get_metrics = 0;
+ pfont->data.len_glyphs = 0; /* used below along with a special notify destructor */
+ /* early exit cures the leak of gs_len_glyphs_release not being called.
+ * the return could be removed relying on alloc of size 0 to work.
+ */
+ return 0;
+ }
+ /* default data.get routines require a ram version of a ttf file */
+ pfont->data.get_glyph_index = default_get_glyph_index;
+ pfont->data.get_outline = default_get_outline;
+ pfont->data.get_metrics = gs_type42_default_get_metrics;
+
/* Now build the len_glyphs array since 'loca' may not be properly sorted */
pfont->data.len_glyphs = (uint *)gs_alloc_bytes(pfont->memory, pfont->data.numGlyphs * sizeof(uint),
- "gs_type42_font");
+ "gs_type42_font");
if (pfont->data.len_glyphs == 0)
return_error(gs_error_VMerror);
gs_font_notify_register((gs_font *)pfont, gs_len_glyphs_release, (void *)pfont);
Modified: trunk/gs/src/gxccman.c
===================================================================
--- trunk/gs/src/gxccman.c 2006-09-28 05:56:04 UTC (rev 7073)
+++ trunk/gs/src/gxccman.c 2006-10-02 14:10:53 UTC (rev 7074)
@@ -274,7 +274,7 @@
pair->ttr = 0;
pair->design_grid = false;
if (font->FontType == ft_TrueType || font->FontType == ft_CID_TrueType)
- if (((gs_font_type42 *)font)->FAPI==NULL) {
+ if (((gs_font_type42 *)font)->FAPI==NULL && ((gs_font_type42 *)font)->data.USE_ttfReader ) {
float cxx, cxy, cyx, cyy;
gs_matrix m;
gx_compute_char_matrix(char_tm, log2_scale, &cxx, &cxy, &cyx, &cyy);
Modified: trunk/gs/src/gxfcopy.c
===================================================================
--- trunk/gs/src/gxfcopy.c 2006-09-28 05:56:04 UTC (rev 7073)
+++ trunk/gs/src/gxfcopy.c 2006-10-02 14:10:53 UTC (rev 7074)
@@ -1290,7 +1290,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);
+ code = gs_type42_font_init(copied42, 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-09-28 05:56:04 UTC (rev 7073)
+++ trunk/gs/src/gxfont42.h 2006-10-02 14:10:53 UTC (rev 7074)
@@ -54,6 +54,16 @@
gs_glyph_data_t *pgd);
int (*get_metrics)(gs_font_type42 *pfont, uint glyph_index, int wmode,
float sbw[4]);
+
+
+ /* Essentially subclasses gs_type42 into with ttfReader and without ttReader
+ * Set by gs_type42_font_init,
+ * used by gx_add_fm_pair() to do a ISA inspection and attach a ttfReader to the font
+ * if false no ttfReader is attached and normal font calls are dispatched.
+ * Used to process ttf fonts with UFST without FAPI
+ */
+ bool USE_ttfReader;
+
/* The following are cached values. */
ulong cmap; /* offset to cmap table (not used by */
/* renderer, only here for clients) */
@@ -101,8 +111,10 @@
* we provide a procedure to initialize them from the font data.
* Note that this initializes the type42_data procedures other than
* string_proc, and the font procedures as well.
+ * USE_ttfReader subclasses gs_font_type42 with ttfReader or without.
+ * FAPI will disable ttfReader as well.
*/
-int gs_type42_font_init(gs_font_type42 *);
+int gs_type42_font_init(gs_font_type42 *pfont, 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-09-28 05:56:04 UTC (rev 7073)
+++ trunk/gs/src/zfont42.c 2006-10-02 14:10:53 UTC (rev 7074)
@@ -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);
+ code = gs_type42_font_init(pfont, true /*Use ttfReader */);
if (code < 0)
return code;
pfont->procs.font_info = z42_font_info;
More information about the gs-cvs
mailing list