1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
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.
14
/* $Id: zchar32.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* Type 32 font glyph operators */
18
#include "gsccode.h" /* for gxfont.h */
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>> */
31
zmakeglyph32(i_ctx_t *i_ctx_p)
37
int wx, llx, lly, urx, ury;
38
int width, height, raster;
44
msize = r_size(op - 4);
53
return_error(e_rangecheck);
55
code = num_params(op[-4].value.refs + msize - 1, msize, metrics);
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];
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);
74
if (pfont->FontType != ft_CID_bitmap)
75
return_error(e_invalidfont);
76
check_write_type(*op, t_string);
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
84
/* Use the long form. */
85
int i, n = (long_form ? 10 : 6);
89
for (i = 0; i < n; ++i) {
90
int v = (int)metrics[i]; /* no floating point widths yet */
92
str[2 + 2 * i] = (byte)(v >> 8);
93
str[2 + 2 * i + 1] = (byte)v;
95
r_set_size(op, 2 + n * 2);
97
/* Use the short form. */
99
str[1] = (byte)height;
101
str[3] = (byte)(llx + 128);
102
str[4] = (byte)(lly + 128);
108
/* <cid_min> <cid_max> <type32font> .removeglyphs - */
110
gs_glyph cid_min, cid_max;
114
select_cid_range(const gs_memory_t *mem, cached_char * cc, void *range_ptr)
116
const font_cid_range_t *range = range_ptr;
118
return (cc->code >= range->cid_min &&
119
cc->code <= range->cid_max &&
120
cc->pair->font == range->font);
123
zremoveglyphs(i_ctx_t *i_ctx_p)
127
font_cid_range_t range;
129
check_int_leu(op[-2], 65535);
130
check_int_leu(op[-1], 65535);
131
code = font_param(op, &range.font);
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,
144
/* <str5/14/22> .getmetrics32 <width> <height> <wx> ... <ury> 5/14 */
145
/* <str5/14/22> .getmetrics32 <width> <height> <w0x> ... <vy> 22 */
147
zgetmetrics32(i_ctx_t *i_ctx_p)
155
check_read_type(*op, t_string);
156
data = op->value.const_bytes;
159
return_error(e_rangecheck);
162
int llx = (int)data[3] - 128, lly = (int)data[4] - 128;
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 */
175
/* Long form, both WModes. */
177
return_error(e_rangecheck);
181
/* Long form, WMode = 0 only. */
183
return_error(e_rangecheck);
188
for (i = 0; i < n; ++i)
190
((int)((data[2 * i + 2] << 8) + data[2 * i + 3]) ^ 0x8000)
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);
200
/* ------ Initialization procedure ------ */
202
const op_def zchar32_op_defs[] =
204
{"1.getmetrics32", zgetmetrics32},
205
{"4.makeglyph32", zmakeglyph32},
206
{"3.removeglyphs", zremoveglyphs},