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: zcidtest.c 8250 2007-09-25 13:31:24Z giles $ */
15
/* Operators for testing CIDFont and CMap facilities */
33
zwrapfont(i_ctx_t *i_ctx_p)
35
gs_font *font = gs_currentfont(igs);
40
switch (font->FontType) {
42
code = gs_font_type0_from_type42(&font0, (gs_font_type42 *)font, wmode,
47
* Patch up BuildChar and CIDMap. This isn't necessary for
48
* TrueType fonts in general, only for Type 42 fonts whose
49
* BuildChar is implemented in PostScript code.
52
font_data *pdata = pfont_data(font);
53
const char *bgstr = "%Type11BuildGlyph";
57
ref_assign(&pdata->u.type42.CIDMap, &temp);
58
code = name_ref((const byte *)bgstr, strlen(bgstr), &temp, 1);
61
r_set_attrs(&temp, a_executable);
62
ref_assign(&pdata->BuildGlyph, &temp);
65
case ft_CID_encrypted:
66
case ft_CID_user_defined:
68
code = gs_font_type0_from_cidfont(&font0, font, wmode, NULL,
72
return_error(e_rangecheck);
76
gs_setfont(igs, (gs_font *)font0);
80
/* <file> <cmap> .writecmap - */
82
zfcmap_put_name_default(stream *s, const byte *str, uint size)
85
stream_write(s, str, size);
89
zwritecmap(i_ctx_t *i_ctx_p)
97
check_type(*op, t_dictionary);
98
if (dict_find_string(op, "CodeMap", &pcodemap) <= 0 ||
99
!r_is_struct(pcodemap)
101
return_error(e_typecheck);
102
check_write_file(s, op - 1);
103
pcmap = r_ptr(pcodemap, gs_cmap_t);
104
code = psf_write_cmap(s, pcmap, zfcmap_put_name_default, NULL, -1);
110
/* <file> <cid9font> .writefont9 - */
112
zwritefont9(i_ctx_t *i_ctx_p)
117
int code = font_param(op, &pfont);
122
if (pfont->FontType != ft_CID_encrypted)
123
return_error(e_invalidfont);
124
check_write_file(s, op - 1);
125
pfcid = (gs_font_cid0 *)pfont;
126
code = psf_write_cid0_font(s, pfcid,
127
WRITE_TYPE2_NO_LENIV | WRITE_TYPE2_CHARSTRINGS,
134
/* ------ Initialization procedure ------ */
136
const op_def zcidtest_op_defs[] =
138
{"1.wrapfont", zwrapfont},
139
{"2.writecmap", zwritecmap},
140
{"2.writefont9", zwritefont9},