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

giles at ghostscript.com giles at ghostscript.com
Mon Oct 2 16:26:12 PDT 2006


Author: giles
Date: 2006-10-02 16:26:12 -0700 (Mon, 02 Oct 2006)
New Revision: 7077

Modified:
   trunk/gs/src/gxfapiu.c
   trunk/gs/src/gxfapiu.h
   trunk/gs/src/gxftype.h
Log:
Port UFST-related changes from the ghostpcl tree, r2472 to r2532. This
introduces gx_UFST_init() and _fini() functions, and make both PCL and 
PS ufst initialization use these functions instead of calling ufst
directly, so that the same ufst config is shared between the two.

Also, update the copyright headers, and defined a needed enum entry for 
UFST MicroType fonts.


Modified: trunk/gs/src/gxfapiu.c
===================================================================
--- trunk/gs/src/gxfapiu.c	2006-10-02 23:21:05 UTC (rev 7076)
+++ trunk/gs/src/gxfapiu.c	2006-10-02 23:26:12 UTC (rev 7077)
@@ -1,38 +1,37 @@
-/* Copyright (C) 1991, 2000 Aladdin Enterprises.  All rights reserved.
-  
-  This software is provided AS-IS with no warranty, either express or
-  implied.
-  
-  This software is distributed under license and may not be copied,
-  modified or distributed except as expressly authorized under the terms
-  of the license contained in the file LICENSE in this distribution.
-  
-  For more information about licensing, please refer to
-  http://www.ghostscript.com/licensing/. For information on
-  commercial licensing, go to http://www.artifex.com/licensing/ or
-  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+/* Copyright (C) 2001-2006 artofcode LLC.
+   All Rights Reserved.
+
+   This software is provided AS-IS with no warranty, either express or
+   implied.
+
+   This software is distributed under license and may not be copied, modified
+   or distributed except as expressly authorized under the terms of that
+   license.  Refer to licensing information at http://www.artifex.com/
+   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
+   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 */
 
 /* $Id$ */
-/* Font API support : UFST callback dispatch. */
+/* Font API support : UFST common initialization */
 
 /* GS includes : */
 #include "gx.h"
+
 /* UFST includes : */
 #undef true
 #undef false
+#undef frac_bits
 #include "cgconfig.h"
 #include "ufstport.h"
 #include "shareinc.h"
 /* GS includes : */
 #include "gxfapiu.h"
 
-#define MAX_STATIC_FCO_COUNT 2
+#define MAX_STATIC_FCO_COUNT 4
 
 /* -------------------- UFST callback dispatcher ------------- */
 
-/*  This code provides dispatching UFST callbacks to GS or PCL. */
+/*  This code provides dispatching UFST callbacks to the PDL */
 
 struct IF_STATE;
 
@@ -48,23 +47,25 @@
 {   return NULL;
 }
 
+/* This global is defined here because the UFST needs it to link against. */
+/* set to 1 to display UFST debugging statements */
+GLOBAL const SW16 trace_sw = 0;
+
+
 /*
     The following 4 variables are defined statically 
-    because the language switching project doesn't define 
-    a general dynamic context for all interpreters.
- */
 
+They could be stored in the gs_lib_ctx but that would require casting the types
+to avoid including ufst's typedefs. 
+*/
+
 static LPUB8 (*m_PCLEO_charptr)(FSP LPUB8 pfont_hdr, UW16  sym_code) = stub_PCLEO_charptr;
 static LPUB8 (*m_PCLchId2ptr)(FSP UW16 chId) = stub_PCLchId2ptr;
 static LPUB8 (*m_PCLglyphID2Ptr)(FSP UW16 glyphID) = stub_PCLglyphID2Ptr;
-#if !UFST_REENTRANT
-static bool global_UFST_lock = false;
-static fco_list_elem static_fco_list[MAX_STATIC_FCO_COUNT];
+static fco_list_elem static_fco_list[MAX_STATIC_FCO_COUNT] = {0, 0, 0, 0};
 static char static_fco_paths[MAX_STATIC_FCO_COUNT][gp_file_name_sizeof];
 static int static_fco_count = 0;
-#endif
 
-
 LPUB8 PCLEO_charptr(FSP LPUB8 pfont_hdr, UW16  sym_code)
 {   return m_PCLEO_charptr(FSA pfont_hdr, sym_code);
 }
@@ -77,20 +78,10 @@
 {   return m_PCLglyphID2Ptr(FSA glyphID);
 }
 
-/* Set UFST callbacks. */
-/* Warning : the language switch progect doesn't guarantee
-   that this function is called when switching
-   to another interpreter. Therefore each interpreter must take
-   care for its own callback methods before they 
-   may be called by UFST.
+/* Set UFST callbacks. Each PDL will want it's own character build function and must set the callbacks
+ * upon language entry/initialization.
  */
- /* Warning : this function may cause a reentrancy problem
-    due to a modification of static variables.
-    Nevertheless this problem isn't important in a
-    sngle interpreter build because the values
-    really change on the first demand only.
-    See also a comment in gs_fapiufst_finit.
-  */
+
 void gx_set_UFST_Callbacks(LPUB8 (*p_PCLEO_charptr)(FSP LPUB8 pfont_hdr, UW16  sym_code),
                            LPUB8 (*p_PCLchId2ptr)(FSP UW16 chId),
                            LPUB8 (*p_PCLglyphID2Ptr)(FSP UW16 glyphID))
@@ -99,52 +90,93 @@
     m_PCLglyphID2Ptr = (p_PCLglyphID2Ptr != NULL ? p_PCLglyphID2Ptr : stub_PCLglyphID2Ptr);
 }
 
-#if !UFST_REENTRANT
-/* The following 2 functions provide a locking of a 
-   global static UFST instance, which must be a singleton 
-   when UFST works for embedded multilanguage system. 
-   When setting a lock, the language swithing code
-   must initialize and uninitialise UFST by immediate calls.
+#define MAX_OPEN_LIBRARIES  5   /* NB */
+#define BITMAP_WIDTH        1   /* must be 1, 2, 4 or 8 */
+
+
+/* returns negative on error, 
+ * 1 on I just initialized for the first time and you might want to as well.
+ * 0 I've already initialized but its ok to call me.
+ * NB: since this is using a static library UFST the initialization is static as well 
+ * ie no multi-threading through here, once per process please.  
  */
-void gs_set_UFST_lock(bool lock)
+int
+gx_UFST_init(UB8 ufst_root_dir[])
 {
-    global_UFST_lock = lock;
+    IFCONFIG            config_block;
+    int status;
+    static bool ufst_initialized = false;
+
+    if (!ufst_initialized) {
+	strcpy(config_block.ufstPath, ufst_root_dir);
+	strcpy(config_block.typePath, ufst_root_dir);
+	config_block.num_files = MAX_OPEN_LIBRARIES;  /* max open library files */
+	config_block.bit_map_width = BITMAP_WIDTH;    /* bitmap width 1, 2 or 4 */
+
+	/* These parameters were set in open_UFST() (fapiufst.c) but were left
+	   uninitialized in pl_load_built_in_fonts() (plulfont.c). */
+	config_block.typePath[0] = 0;
+
+	if ((status = CGIFinit(FSA0)) != 0) {
+	    dprintf1("CGIFinit() error: %d\n", status);
+	    return status;
+	}
+	if ((status = CGIFconfig(FSA &config_block)) != 0) {
+	    dprintf1("CGIFconfig() error: %d\n", status);
+	    return status;
+	}
+	if ((status = CGIFenter(FSA0)) != 0) {
+	    dprintf1("CGIFenter() error: %u\n",status);
+	    return status;
+	}
+	ufst_initialized = TRUE;
+	return 1; /* first time, caller may have more initialization to do */
+    }
+    return 0;  /* been here before, caller has no more initialization do do */
 }
-bool gs_get_UFST_lock(void)
+
+int
+gx_UFST_fini(void)
 {
-    return global_UFST_lock;
+    CGIFexit(FSA0);
+    return 0;
 }
-#endif /*!UFST_REENTRANT*/
 
 /* Access to the static FCO list for the language switching project. */
 
 fco_list_elem *gx_UFST_find_static_fco(const char *font_file_path)
 {   
-#if !UFST_REENTRANT
     int i;
 
     for (i = 0; i < static_fco_count; i++)
 	if (!strcmp(static_fco_list[i].file_path, font_file_path))
 	    return &static_fco_list[i];
-#endif
+
     return NULL;
 }
 
 fco_list_elem *gx_UFST_find_static_fco_handle(SW16 fcHandle)
 {   
-#if !UFST_REENTRANT
     int i;
 
     for (i = 0; i < static_fco_count; i++)
 	if (static_fco_list[i].fcHandle == fcHandle)
 	    return &static_fco_list[i];
-#endif
+
     return NULL;
 }
 
+SW16 gx_UFST_find_fco_handle_by_name(const char *font_file_path)
+{   
+    fco_list_elem *fco = gx_UFST_find_static_fco(font_file_path);
+
+    if (fco)
+	return fco->fcHandle;
+    return 0; /* or is it -1? */ 
+}
+
 UW16 gx_UFST_open_static_fco(const char *font_file_path, SW16 *result_fcHandle)
 {   
-#if !UFST_REENTRANT
     SW16 fcHandle;
     UW16 code;
     fco_list_elem *e;
@@ -163,15 +195,10 @@
     static_fco_count++;
     *result_fcHandle = fcHandle;
     return 0;
-#else
-    **result_fcHandle = -1;
-    return ERR_fco_NoMem;
-#endif
 }
 
 UW16 gx_UFST_close_static_fco(SW16 fcHandle)
 {   
-#if !UFST_REENTRANT
     int i;
 
     for (i = 0; i < static_fco_count; i++)
@@ -185,7 +212,12 @@
 	strcpy(static_fco_paths[i - 1], static_fco_paths[i]);
     }
     static_fco_count--;
-#endif
+
     return 0;
 }
 
+void gx_UFST_close_static_fcos()
+{
+    for(; static_fco_count; )
+	gx_UFST_close_static_fco(static_fco_list[0].fcHandle);
+}

Modified: trunk/gs/src/gxfapiu.h
===================================================================
--- trunk/gs/src/gxfapiu.h	2006-10-02 23:21:05 UTC (rev 7076)
+++ trunk/gs/src/gxfapiu.h	2006-10-02 23:26:12 UTC (rev 7077)
@@ -1,17 +1,14 @@
-/* Copyright (C) 1991, 2000 Aladdin Enterprises.  All rights reserved.
-  
-  This software is provided AS-IS with no warranty, either express or
-  implied.
-  
-  This software is distributed under license and may not be copied,
-  modified or distributed except as expressly authorized under the terms
-  of the license contained in the file LICENSE in this distribution.
-  
-  For more information about licensing, please refer to
-  http://www.ghostscript.com/licensing/. For information on
-  commercial licensing, go to http://www.artifex.com/licensing/ or
-  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
-  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
+/* Copyright (C) 2001-2006 artofcode LLC.
+   All Rights Reserved.
+
+   This software is provided AS-IS with no warranty, either express or
+   implied.
+
+   This software is distributed under license and may not be copied, modified
+   or distributed except as expressly authorized under the terms of that
+   license.  Refer to licensing information at http://www.artifex.com/
+   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
+   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
 */
 
 /* $Id$ */
@@ -42,17 +39,6 @@
 
 void gx_reset_UFST_Callbacks(void);
 
-#if !UFST_REENTRANT
-/* The following 2 functions provide a locking of a 
-   global static UFST instance, which must be a singleton 
-   when UFST works for embedded multilanguage system. 
-   When setting a lock, the language swithing code
-   must initialize and uninitialize UFST by immediate calls.
- */
-void gs_set_UFST_lock(bool lock);
-bool gs_get_UFST_lock(void);
-#endif /*!UFST_REENTRANT*/
-
 typedef struct fco_list_elem_s fco_list_elem;
 struct fco_list_elem_s {
     int open_count;
@@ -65,8 +51,16 @@
 /* For the language switch : */
 UW16 gx_UFST_open_static_fco(const char *font_file_path, SW16 *result_fcHandle);
 UW16 gx_UFST_close_static_fco(SW16 fcHandle);
+/* close all open FCO's */
+void gx_UFST_close_static_fcos(void);
+SW16 gx_UFST_find_fco_handle_by_name(const char *font_file_path);
+
 /* For fapiufst.c : */
 fco_list_elem *gx_UFST_find_static_fco(const char *font_file_path);
 fco_list_elem *gx_UFST_find_static_fco_handle(SW16 fcHandle);
 
+int gx_UFST_init(UB8 ufst_root_dir[]);
+
+int gx_UFST_fini(void);
+
 #endif /* gxfapiu_INCLUDED */

Modified: trunk/gs/src/gxftype.h
===================================================================
--- trunk/gs/src/gxftype.h	2006-10-02 23:21:05 UTC (rev 7076)
+++ trunk/gs/src/gxftype.h	2006-10-02 23:26:12 UTC (rev 7077)
@@ -31,7 +31,8 @@
     ft_CID_TrueType = 11,	/* CIDFontType 2 */
     ft_Chameleon = 14,
     ft_CID_bitmap = 32,		/* CIDFontType 4 */
-    ft_TrueType = 42
+    ft_TrueType = 42,
+    ft_MicroType = 51		/* MicroType 51 is arbitrary */
 } font_type;
 
 /* Define the bitmap font behaviors. */



More information about the gs-cvs mailing list