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

« back to all changes in this revision

Viewing changes to src/zcharx.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: zcharx.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Level 2 character operators */
16
 
#include "ghost.h"
17
 
#include "oper.h"
18
 
#include "gsmatrix.h"           /* for gxfont.h */
19
 
#include "gstext.h"
20
 
#include "gxfixed.h"            /* for gxfont.h */
21
 
#include "gxfont.h"
22
 
#include "gxtext.h"
23
 
#include "ialloc.h"
24
 
#include "ichar.h"
25
 
#include "igstate.h"
26
 
#include "iname.h"
27
 
#include "ibnum.h"
28
 
#include "memory_.h"
29
 
 
30
 
/* Common setup for glyphshow and .glyphwidth. */
31
 
static int
32
 
glyph_show_setup(i_ctx_t *i_ctx_p, gs_glyph *pglyph)
33
 
{
34
 
    os_ptr op = osp;
35
 
 
36
 
    switch (gs_currentfont(igs)->FontType) {
37
 
        case ft_CID_encrypted:
38
 
        case ft_CID_user_defined:
39
 
        case ft_CID_TrueType:
40
 
        case ft_CID_bitmap:
41
 
            check_int_leu(*op, gs_max_glyph - gs_min_cid_glyph);
42
 
            *pglyph = (gs_glyph) op->value.intval + gs_min_cid_glyph;
43
 
            break;
44
 
        default:
45
 
            check_type(*op, t_name);
46
 
            *pglyph = name_index(imemory, op);
47
 
    }
48
 
    return op_show_enum_setup(i_ctx_p);
49
 
}
50
 
 
51
 
/* <charname> glyphshow - */
52
 
static int
53
 
zglyphshow(i_ctx_t *i_ctx_p)
54
 
{
55
 
    gs_glyph glyph;
56
 
    gs_text_enum_t *penum;
57
 
    int code;
58
 
 
59
 
    if ((code = glyph_show_setup(i_ctx_p, &glyph)) != 0 ||
60
 
        (code = gs_glyphshow_begin(igs, glyph, imemory, &penum)) < 0)
61
 
        return code;
62
 
    *(op_proc_t *)&penum->enum_client_data = zglyphshow;
63
 
    if ((code = op_show_finish_setup(i_ctx_p, penum, 1, NULL)) < 0) {
64
 
        ifree_object(penum, "zglyphshow");
65
 
        return code;
66
 
    }
67
 
    return op_show_continue_pop(i_ctx_p, 1);
68
 
}
69
 
 
70
 
/* <charname> .glyphwidth <wx> <wy> */
71
 
static int
72
 
zglyphwidth(i_ctx_t *i_ctx_p)
73
 
{
74
 
    gs_glyph glyph;
75
 
    gs_text_enum_t *penum;
76
 
    int code;
77
 
 
78
 
    if ((code = glyph_show_setup(i_ctx_p, &glyph)) != 0 ||
79
 
        (code = gs_glyphwidth_begin(igs, glyph, imemory, &penum)) < 0)
80
 
        return code;
81
 
    if ((code = op_show_finish_setup(i_ctx_p, penum, 1, finish_stringwidth)) < 0) {
82
 
        ifree_object(penum, "zglyphwidth");
83
 
        return code;
84
 
    }
85
 
    return op_show_continue_pop(i_ctx_p, 1);
86
 
}
87
 
 
88
 
/* <string> <numarray|numstring> xshow - */
89
 
/* <string> <numarray|numstring> yshow - */
90
 
/* <string> <numarray|numstring> xyshow - */
91
 
static int
92
 
moveshow(i_ctx_t *i_ctx_p, bool have_x, bool have_y)
93
 
{
94
 
    os_ptr op = osp;
95
 
    gs_text_enum_t *penum;
96
 
    int code = op_show_setup(i_ctx_p, op - 1);
97
 
    int format;
98
 
    uint i, size, widths_needed;
99
 
    float *values;
100
 
    extern bool CPSI_mode;
101
 
 
102
 
    if (code != 0)
103
 
        return code;
104
 
    format = num_array_format(op);
105
 
    if (format < 0)
106
 
        return format;
107
 
    size = num_array_size(op, format);
108
 
    values = (float *)ialloc_byte_array(size, sizeof(float), "moveshow");
109
 
    if (values == 0)
110
 
        return_error(e_VMerror);
111
 
    if (CPSI_mode)
112
 
        memset(values, 0, size * sizeof(values[0])); /* Safety. */
113
 
    if ((code = gs_xyshow_begin(igs, op[-1].value.bytes, r_size(op - 1),
114
 
                                (have_x ? values : (float *)0),
115
 
                                (have_y ? values : (float *)0),
116
 
                                size, imemory, &penum)) < 0) {
117
 
        ifree_object(values, "moveshow");
118
 
        return code;
119
 
    }
120
 
    if (CPSI_mode) {
121
 
        /* CET 13-29.PS page 2 defines a longer width array
122
 
           then the text requires, and CPSI silently ignores extra elements.
123
 
           So we need to compute exact number of characters 
124
 
           to know how many elements to load and type check. */
125
 
        code = gs_text_count_chars(igs, gs_get_text_params(penum), imemory);
126
 
        if (code < 0)
127
 
            return code;
128
 
        widths_needed = code;
129
 
        if (have_x && have_y)
130
 
            widths_needed <<= 1;
131
 
    } else
132
 
        widths_needed = size;
133
 
    for (i = 0; i < widths_needed; ++i) {
134
 
        ref value;
135
 
 
136
 
        switch (code = num_array_get(imemory, op, format, i, &value)) {
137
 
        case t_integer:
138
 
            values[i] = (float)value.value.intval; break;
139
 
        case t_real:
140
 
            values[i] = value.value.realval; break;
141
 
        case t_null:
142
 
            code = gs_note_error(e_rangecheck);
143
 
            /* falls through */
144
 
        default:
145
 
            ifree_object(values, "moveshow");
146
 
            return code;
147
 
        }
148
 
    }
149
 
    if ((code = op_show_finish_setup(i_ctx_p, penum, 2, NULL)) < 0) {
150
 
        ifree_object(values, "moveshow");
151
 
        return code;
152
 
    }
153
 
    pop(2);
154
 
    return op_show_continue(i_ctx_p);
155
 
}
156
 
static int
157
 
zxshow(i_ctx_t *i_ctx_p)
158
 
{
159
 
    return moveshow(i_ctx_p, true, false);
160
 
}
161
 
static int
162
 
zyshow(i_ctx_t *i_ctx_p)
163
 
{
164
 
    return moveshow(i_ctx_p, false, true);
165
 
}
166
 
static int
167
 
zxyshow(i_ctx_t *i_ctx_p)
168
 
{
169
 
    return moveshow(i_ctx_p, true, true);
170
 
}
171
 
 
172
 
/* ------ Initialization procedure ------ */
173
 
 
174
 
const op_def zcharx_op_defs[] =
175
 
{
176
 
    op_def_begin_level2(),
177
 
    {"1glyphshow", zglyphshow},
178
 
    {"1.glyphwidth", zglyphwidth},
179
 
    {"2xshow", zxshow},
180
 
    {"2xyshow", zxyshow},
181
 
    {"2yshow", zyshow},
182
 
    op_def_end(0)
183
 
};