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

« back to all changes in this revision

Viewing changes to src/zchar32.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: zchar32.c 8250 2007-09-25 13:31:24Z giles $ */
15
 
/* Type 32 font glyph operators */
16
 
#include "ghost.h"
17
 
#include "oper.h"
18
 
#include "gsccode.h"            /* for gxfont.h */
19
 
#include "gsmatrix.h"
20
 
#include "gsutil.h"
21
 
#include "gxfixed.h"
22
 
#include "gxfont.h"
23
 
#include "gxfcache.h"
24
 
#include "ifont.h"
25
 
#include "igstate.h"
26
 
#include "store.h"
27
 
 
28
 
/* ([wx wy llx lly urx ury] | [w0x w0y llx lly urx ury w1x w1y vx vy]) */
29
 
/*   <bitmap> <cid> <type32font> <str22> .makeglyph32 <<same with substr>> */
30
 
static int
31
 
zmakeglyph32(i_ctx_t *i_ctx_p)
32
 
{
33
 
    os_ptr op = osp;
34
 
    bool long_form;
35
 
    uint msize;
36
 
    double metrics[10];
37
 
    int wx, llx, lly, urx, ury;
38
 
    int width, height, raster;
39
 
    gs_font *pfont;
40
 
    int code;
41
 
    byte *str;
42
 
 
43
 
    check_array(op[-4]);
44
 
    msize = r_size(op - 4);
45
 
    switch (msize) {
46
 
        case 10:
47
 
            long_form = true;
48
 
            break;
49
 
        case 6:
50
 
            long_form = false;
51
 
            break;
52
 
        default:
53
 
            return_error(e_rangecheck);
54
 
    }
55
 
    code = num_params(op[-4].value.refs + msize - 1, msize, metrics);
56
 
    if (code < 0)
57
 
        return code;
58
 
    if (~code & 0x3c)           /* check llx .. ury for integers */
59
 
        return_error(e_typecheck);
60
 
    check_read_type(op[-3], t_string);
61
 
    llx = (int)metrics[2];
62
 
    lly = (int)metrics[3];
63
 
    urx = (int)metrics[4];
64
 
    ury = (int)metrics[5];
65
 
    width = urx - llx;
66
 
    height = ury - lly;
67
 
    raster = (width + 7) >> 3;
68
 
    if (width < 0 || height < 0 || r_size(op - 3) != raster * height)
69
 
        return_error(e_rangecheck);
70
 
    check_int_leu(op[-2], 65535);
71
 
    code = font_param(op - 1, &pfont);
72
 
    if (code < 0)
73
 
        return code;
74
 
    if (pfont->FontType != ft_CID_bitmap)
75
 
        return_error(e_invalidfont);
76
 
    check_write_type(*op, t_string);
77
 
    if (r_size(op) < 22)
78
 
        return_error(e_rangecheck);
79
 
    str = op->value.bytes;
80
 
    if (long_form || metrics[0] != (wx = (int)metrics[0]) ||
81
 
        metrics[1] != 0 || height == 0 ||
82
 
        ((wx | width | height | (llx + 128) | (lly + 128)) & ~255) != 0
83
 
        ) {
84
 
        /* Use the long form. */
85
 
        int i, n = (long_form ? 10 : 6);
86
 
 
87
 
        str[0] = 0;
88
 
        str[1] = long_form;
89
 
        for (i = 0; i < n; ++i) {
90
 
            int v = (int)metrics[i];  /* no floating point widths yet */
91
 
 
92
 
            str[2 + 2 * i] = (byte)(v >> 8);
93
 
            str[2 + 2 * i + 1] = (byte)v;
94
 
        }
95
 
        r_set_size(op, 2 + n * 2);
96
 
    } else {
97
 
        /* Use the short form. */
98
 
        str[0] = (byte)width;
99
 
        str[1] = (byte)height;
100
 
        str[2] = (byte)wx;
101
 
        str[3] = (byte)(llx + 128);
102
 
        str[4] = (byte)(lly + 128);
103
 
        r_set_size(op, 5);
104
 
    }
105
 
    return code;
106
 
}
107
 
 
108
 
/* <cid_min> <cid_max> <type32font> .removeglyphs - */
109
 
typedef struct {
110
 
    gs_glyph cid_min, cid_max;
111
 
    gs_font *font;
112
 
} font_cid_range_t;
113
 
static bool
114
 
select_cid_range(const gs_memory_t *mem, cached_char * cc, void *range_ptr)
115
 
{
116
 
    const font_cid_range_t *range = range_ptr;
117
 
 
118
 
    return (cc->code >= range->cid_min &&
119
 
            cc->code <= range->cid_max &&
120
 
            cc->pair->font == range->font);
121
 
}
122
 
static int
123
 
zremoveglyphs(i_ctx_t *i_ctx_p)
124
 
{
125
 
    os_ptr op = osp;
126
 
    int code;
127
 
    font_cid_range_t range;
128
 
 
129
 
    check_int_leu(op[-2], 65535);
130
 
    check_int_leu(op[-1], 65535);
131
 
    code = font_param(op, &range.font);
132
 
    if (code < 0)
133
 
        return code;
134
 
    if (range.font->FontType != ft_CID_bitmap)
135
 
        return_error(e_invalidfont);
136
 
    range.cid_min = gs_min_cid_glyph + op[-2].value.intval;
137
 
    range.cid_max = gs_min_cid_glyph + op[-1].value.intval;
138
 
    gx_purge_selected_cached_chars(range.font->dir, select_cid_range,
139
 
                                   &range);
140
 
    pop(3);
141
 
    return 0;
142
 
}
143
 
 
144
 
/* <str5/14/22> .getmetrics32 <width> <height> <wx> ... <ury> 5/14 */
145
 
/* <str5/14/22> .getmetrics32 <width> <height> <w0x> ... <vy> 22 */
146
 
static int
147
 
zgetmetrics32(i_ctx_t *i_ctx_p)
148
 
{
149
 
    os_ptr op = osp;
150
 
    const byte *data;
151
 
    uint size;
152
 
    int i, n = 6;
153
 
    os_ptr wop;
154
 
 
155
 
    check_read_type(*op, t_string);
156
 
    data = op->value.const_bytes;
157
 
    size = r_size(op);
158
 
    if (size < 5)
159
 
        return_error(e_rangecheck);
160
 
    if (data[0]) {
161
 
        /* Short form. */
162
 
        int llx = (int)data[3] - 128, lly = (int)data[4] - 128;
163
 
 
164
 
        n = 6;
165
 
        size = 5;
166
 
        push(8);
167
 
        make_int(op - 6, data[2]); /* wx */
168
 
        make_int(op - 5, 0);    /* wy */
169
 
        make_int(op - 4, llx);
170
 
        make_int(op - 3, lly);
171
 
        make_int(op - 2, llx + data[0]); /* urx */
172
 
        make_int(op - 1, lly + data[1]); /* ury */
173
 
    } else {
174
 
        if (data[1]) {
175
 
            /* Long form, both WModes. */
176
 
            if (size < 22)
177
 
                return_error(e_rangecheck);
178
 
            n = 10;
179
 
            size = 22;
180
 
        } else {
181
 
            /* Long form, WMode = 0 only. */
182
 
            if (size < 14)
183
 
                return_error(e_rangecheck);
184
 
            n = 6;
185
 
            size = 14;
186
 
        }
187
 
        push(2 + n);
188
 
        for (i = 0; i < n; ++i)
189
 
            make_int(op - n + i,
190
 
                     ((int)((data[2 * i + 2] << 8) + data[2 * i + 3]) ^ 0x8000)
191
 
                       - 0x8000);
192
 
    }
193
 
    wop = op - n;
194
 
    make_int(wop - 2, wop[4].value.intval - wop[2].value.intval);
195
 
    make_int(wop - 1, wop[5].value.intval - wop[3].value.intval);
196
 
    make_int(op, size);
197
 
    return 0;
198
 
}
199
 
 
200
 
/* ------ Initialization procedure ------ */
201
 
 
202
 
const op_def zchar32_op_defs[] =
203
 
{
204
 
    {"1.getmetrics32", zgetmetrics32},
205
 
    {"4.makeglyph32", zmakeglyph32},
206
 
    {"3.removeglyphs", zremoveglyphs},
207
 
    op_def_end(0)
208
 
};