~ubuntu-branches/ubuntu/jaunty/ghostscript/jaunty-updates

« back to all changes in this revision

Viewing changes to src/gxfapiu.c

  • Committer: Bazaar Package Importer
  • Author(s): Till Kamppeter
  • Date: 2009-01-20 16:40:45 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090120164045-lnfhi0n30o5lwhwa
Tags: 8.64.dfsg.1~svn9377-0ubuntu1
* New upstream release (SVN rev 9377)
   o Fixes many bugs concerning PDF rendering, to make the PDF printing
     workflow correctly working.
   o Fixes long-standing bugs in many drivers, like input paper tray and
     duplex options not working for the built-in PCL 4, 5, 5c, 5e, and
     6/XL drivers, PDF input not working for bjc600, bjc800, and cups
     output devices, several options not working and uninitialized
     memory with cups output device.
   o Merged nearly all patches of the Ubuntu and Debian packages upstream.
   o Fixes LP: #317810, LP: #314439, LP: #314018.
* debian/patches/03_libpaper_support.dpatch,
  debian/patches/11_gs-cjk_font_glyph_handling_fix.dpatch,
  debian/patches/12_gs-cjk_vertical_writing_metrics_fix.dpatch,
  debian/patches/13_gs-cjk_cjkps_examples.dpatch,
  debian/patches/20_bbox_segv_fix.dpatch,
  debian/patches/21_brother_7x0_gdi_fix.dpatch,
  debian/patches/22_epsn_margin_workaround.dpatch,
  debian/patches/24_gs_man_fix.dpatch,
  debian/patches/25_toolbin_insecure_tmp_usage_fix.dpatch,
  debian/patches/26_assorted_script_fixes.dpatch,
  debian/patches/29_gs_css_fix.dpatch,
  debian/patches/30_ps2pdf_man_improvement.dpatch,
  debian/patches/31_fix-gc-sigbus.dpatch,
  debian/patches/34_ftbfs-on-hurd-fix.dpatch,
  debian/patches/35_disable_libcairo.dpatch,
  debian/patches/38_pxl-duplex.dpatch,
  debian/patches/39_pxl-resolution.dpatch,
  debian/patches/42_gs-init-ps-delaybind-fix.dpatch,
  debian/patches/45_bjc600-bjc800-pdf-input.dpatch,
  debian/patches/48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch,
  debian/patches/50_lips4-floating-point-exception.dpatch,
  debian/patches/52_cups-device-logging.dpatch,
  debian/patches/55_pcl-input-slot-fix.dpatch,
  debian/patches/57_pxl-input-slot-fix.dpatch,
  debian/patches/60_pxl-cups-driver-pdf.dpatch,
  debian/patches/62_onebitcmyk-pdf.dpatch,
  debian/patches/65_too-big-temp-files-1.dpatch,
  debian/patches/67_too-big-temp-files-2.dpatch,
  debian/patches/70_take-into-account-data-in-stream-buffer-before-refill.dpatch:
  Removed, applied upstream.
* debian/patches/01_docdir_fix_for_debian.dpatch,
  debian/patches/02_gs_man_fix_debian.dpatch,
  debian/patches/01_docdir-fix-for-debian.dpatch,
  debian/patches/02_docdir-fix-for-debian.dpatch: Renamed patches to
  make merging with Debian easier.
* debian/patches/32_improve-handling-of-media-size-changes-from-gv.dpatch, 
  debian/patches/33_bad-params-to-xinitimage-on-large-bitmaps.dpatch:
  regenerated for new source directory structure.
* debian/rules: Corrected paths to remove cidfmap (it is in Resource/Init/
  in GS 8.64) and to install headers (source paths are psi/ and base/ now).
* debian/rules: Remove all fontmaps, as DeFoMa replaces them.
* debian/local/pdftoraster/pdftoraster.c,
  debian/local/pdftoraster/pdftoraster.convs, debian/rules: Removed
  added pdftoraster filter and use the one which comes with Ghostscript.
* debian/ghostscript.links: s/8.63/8.64/

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright (C) 2001-2006 Artifex Software, Inc.
2
 
   All Rights Reserved.
3
 
 
4
 
   This software is provided AS-IS with no warranty, either express or
5
 
   implied.
6
 
 
7
 
   This software is distributed under license and may not be copied, modified
8
 
   or distributed except as expressly authorized under the terms of that
9
 
   license.  Refer to licensing information at http://www.artifex.com/
10
 
   or contact Artifex Software, Inc.,  7 Mt. Lassen Drive - Suite A-134,
11
 
   San Rafael, CA  94903, U.S.A., +1(415)492-9861, for further information.
12
 
*/
13
 
 
14
 
/* $Id: gxfapiu.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Font API support : UFST common initialization */
16
 
 
17
 
/* GS includes : */
18
 
#include "gx.h"
19
 
 
20
 
/* UFST includes : */
21
 
#undef true
22
 
#undef false
23
 
#undef frac_bits
24
 
#include "cgconfig.h"
25
 
#include "ufstport.h"
26
 
#include "shareinc.h"
27
 
/* GS includes : */
28
 
#include "gxfapiu.h"
29
 
 
30
 
#define MAX_STATIC_FCO_COUNT 4
31
 
 
32
 
/* -------------------- UFST callback dispatcher ------------- */
33
 
 
34
 
/*  This code provides dispatching UFST callbacks to the PDL */
35
 
 
36
 
struct IF_STATE;
37
 
 
38
 
static LPUB8 stub_PCLEO_charptr(FSP LPUB8 pfont_hdr, UW16  sym_code)
39
 
{   return NULL;
40
 
}
41
 
 
42
 
static LPUB8 stub_PCLchId2ptr(FSP UW16 chId)
43
 
{   return NULL;
44
 
}
45
 
 
46
 
static LPUB8 stub_PCLglyphID2Ptr(FSP UW16 glyphID)
47
 
{   return NULL;
48
 
}
49
 
 
50
 
/* This global is defined here because the UFST needs it to link against. */
51
 
/* set to 1 to display UFST debugging statements */
52
 
GLOBAL const SW16 trace_sw = 0;
53
 
 
54
 
 
55
 
/*
56
 
    The following 4 variables are defined statically 
57
 
 
58
 
They could be stored in the gs_lib_ctx but that would require casting the types
59
 
to avoid including ufst's typedefs. 
60
 
*/
61
 
 
62
 
static LPUB8 (*m_PCLEO_charptr)(FSP LPUB8 pfont_hdr, UW16  sym_code) = stub_PCLEO_charptr;
63
 
static LPUB8 (*m_PCLchId2ptr)(FSP UW16 chId) = stub_PCLchId2ptr;
64
 
static LPUB8 (*m_PCLglyphID2Ptr)(FSP UW16 glyphID) = stub_PCLglyphID2Ptr;
65
 
#if !UFST_REENTRANT
66
 
static fco_list_elem static_fco_list[MAX_STATIC_FCO_COUNT] = {0, 0, 0, 0};
67
 
static char static_fco_paths[MAX_STATIC_FCO_COUNT][gp_file_name_sizeof];
68
 
static int static_fco_count = 0;
69
 
static bool ufst_initialized = false;
70
 
#endif
71
 
 
72
 
LPUB8 PCLEO_charptr(FSP LPUB8 pfont_hdr, UW16  sym_code)
73
 
{   return m_PCLEO_charptr(FSA pfont_hdr, sym_code);
74
 
}
75
 
 
76
 
LPUB8 PCLchId2ptr(FSP UW16 chId)
77
 
{   return m_PCLchId2ptr(FSA chId);
78
 
}
79
 
 
80
 
LPUB8 PCLglyphID2Ptr(FSP UW16 glyphID)
81
 
{   return m_PCLglyphID2Ptr(FSA glyphID);
82
 
}
83
 
 
84
 
/* Set UFST callbacks. Each PDL will want it's own character build function and must set the callbacks
85
 
 * upon language entry/initialization.
86
 
 */
87
 
/* Warning : this function may cause a reentrancy problem   
88
 
     due to a modification of static variables.   
89
 
     Nevertheless this problem isn't important in a   
90
 
     single interpreter build, because the values   
91
 
     really change on the first demand only.   
92
 
     See also a comment in gs_fapiufst_finit.   
93
 
   */ 
94
 
void gx_set_UFST_Callbacks(LPUB8 (*p_PCLEO_charptr)(FSP LPUB8 pfont_hdr, UW16  sym_code),
95
 
                           LPUB8 (*p_PCLchId2ptr)(FSP UW16 chId),
96
 
                           LPUB8 (*p_PCLglyphID2Ptr)(FSP UW16 glyphID))
97
 
{   m_PCLEO_charptr = (p_PCLEO_charptr != NULL ? p_PCLEO_charptr : stub_PCLEO_charptr);
98
 
    m_PCLchId2ptr = (p_PCLchId2ptr != NULL ? p_PCLchId2ptr : stub_PCLchId2ptr);
99
 
    m_PCLglyphID2Ptr = (p_PCLglyphID2Ptr != NULL ? p_PCLglyphID2Ptr : stub_PCLglyphID2Ptr);
100
 
}
101
 
 
102
 
#define MAX_OPEN_LIBRARIES  5   /* NB */
103
 
#define BITMAP_WIDTH        1   /* must be 1, 2, 4 or 8 */
104
 
 
105
 
 
106
 
/* returns negative on error, 
107
 
 * 1 = "I just initialized for the first time and you might want to as well."
108
 
 * 0 = "I've already initialized but its ok to call me."
109
 
 * <0 = error.
110
 
 */
111
 
int
112
 
gx_UFST_init(const UB8 *ufst_root_dir)
113
 
{
114
 
    IFCONFIG            config_block;
115
 
    int status;
116
 
 
117
 
#if !UFST_REENTRANT
118
 
    if (ufst_initialized)
119
 
        return 0;
120
 
#endif
121
 
    strcpy(config_block.ufstPath, ufst_root_dir);
122
 
    strcpy(config_block.typePath, ufst_root_dir);
123
 
    config_block.num_files = MAX_OPEN_LIBRARIES;  /* max open library files */
124
 
    config_block.bit_map_width = BITMAP_WIDTH;    /* bitmap width 1, 2 or 4 */
125
 
 
126
 
    /* These parameters were set in open_UFST() (fapiufst.c) but were left
127
 
       uninitialized in pl_load_built_in_fonts() (plulfont.c). */
128
 
    config_block.typePath[0] = 0;
129
 
 
130
 
    if ((status = CGIFinit(FSA0)) != 0) {
131
 
        dprintf1("CGIFinit() error: %d\n", status);
132
 
        return status;
133
 
    }
134
 
    if ((status = CGIFconfig(FSA &config_block)) != 0) {
135
 
        dprintf1("CGIFconfig() error: %d\n", status);
136
 
        return status;
137
 
    }
138
 
    if ((status = CGIFenter(FSA0)) != 0) {
139
 
        dprintf1("CGIFenter() error: %u\n",status);
140
 
        return status;
141
 
    }
142
 
#if !UFST_REENTRANT
143
 
    ufst_initialized = TRUE;
144
 
#endif
145
 
    return 1; /* first time, caller may have more initialization to do */
146
 
}
147
 
 
148
 
int
149
 
gx_UFST_fini(void)
150
 
{
151
 
    CGIFexit(FSA0);
152
 
#if !UFST_REENTRANT
153
 
    ufst_initialized = false;
154
 
#endif
155
 
    return 0;
156
 
}
157
 
 
158
 
/* Access to the static FCO list for the language switching project. */
159
 
 
160
 
fco_list_elem *gx_UFST_find_static_fco(const char *font_file_path)
161
 
{   
162
 
#if !UFST_REENTRANT
163
 
    int i;
164
 
 
165
 
    for (i = 0; i < static_fco_count; i++)
166
 
        if (!strcmp(static_fco_list[i].file_path, font_file_path))
167
 
            return &static_fco_list[i];
168
 
#endif
169
 
    return NULL;
170
 
}
171
 
 
172
 
fco_list_elem *gx_UFST_find_static_fco_handle(SW16 fcHandle)
173
 
{   
174
 
#if !UFST_REENTRANT
175
 
    int i;
176
 
 
177
 
    for (i = 0; i < static_fco_count; i++)
178
 
        if (static_fco_list[i].fcHandle == fcHandle)
179
 
            return &static_fco_list[i];
180
 
#endif
181
 
    return NULL;
182
 
}
183
 
 
184
 
SW16 gx_UFST_find_fco_handle_by_name(const char *font_file_path)
185
 
{   
186
 
#if !UFST_REENTRANT
187
 
    fco_list_elem *fco = gx_UFST_find_static_fco(font_file_path);
188
 
 
189
 
    if (fco)
190
 
        return fco->fcHandle;
191
 
    return 0;
192
 
#endif
193
 
}
194
 
 
195
 
UW16 gx_UFST_open_static_fco(const char *font_file_path, SW16 *result_fcHandle)
196
 
{   
197
 
#if !UFST_REENTRANT
198
 
    SW16 fcHandle;
199
 
    UW16 code;
200
 
    fco_list_elem *e;
201
 
 
202
 
    if (static_fco_count >= MAX_STATIC_FCO_COUNT)
203
 
        return ERR_fco_NoMem;
204
 
    code = CGIFfco_Open(FSA (UB8 *)font_file_path, &fcHandle);
205
 
    if (code != 0)
206
 
        return code;
207
 
    e = &static_fco_list[static_fco_count];
208
 
    strncpy(static_fco_paths[static_fco_count], font_file_path, 
209
 
            sizeof(static_fco_paths[static_fco_count]));
210
 
    e->file_path = static_fco_paths[static_fco_count];
211
 
    e->fcHandle = fcHandle;
212
 
    e->open_count = -1; /* Unused for static FCOs. */
213
 
    static_fco_count++;
214
 
    *result_fcHandle = fcHandle;
215
 
    return 0;
216
 
#else
217
 
    **result_fcHandle = -1;
218
 
    return ERR_fco_NoMem;
219
 
#endif
220
 
}
221
 
 
222
 
UW16 gx_UFST_close_static_fco(SW16 fcHandle)
223
 
{   
224
 
#if !UFST_REENTRANT
225
 
    int i;
226
 
 
227
 
    for (i = 0; i < static_fco_count; i++)
228
 
        if (static_fco_list[i].fcHandle == fcHandle)
229
 
            break;
230
 
    if (i >= static_fco_count)
231
 
        return ERR_fco_NoMem;
232
 
    CGIFfco_Close(FSA fcHandle);
233
 
    for (i++; i < static_fco_count; i++) {
234
 
        static_fco_list[i - 1] = static_fco_list[i];
235
 
        strcpy(static_fco_paths[i - 1], static_fco_paths[i]);
236
 
    }
237
 
    static_fco_count--;
238
 
#endif
239
 
    return 0;
240
 
}
241
 
 
242
 
void gx_UFST_close_static_fcos()
243
 
{
244
 
#if !UFST_REENTRANT
245
 
    for(; static_fco_count; )
246
 
        gx_UFST_close_static_fco(static_fco_list[0].fcHandle);
247
 
#endif
248
 
}