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: zfcid.c 9043 2008-08-28 22:48:19Z giles $ */
15 /* CID-keyed font utilities */
16 #include "ghost.h"
17 #include "oper.h"
18 #include "gsmatrix.h"
19 #include "gxfcid.h"
20 #include "bfont.h"
21 #include "icid.h"
22 #include "idict.h"
23 #include "idparam.h"
24 #include "ifcid.h"
25 #include "store.h"
26
27 /* Get the CIDSystemInfo of a CIDFont. */
28 int
cid_font_system_info_param(gs_cid_system_info_t * pcidsi,const ref * prfont)29 cid_font_system_info_param(gs_cid_system_info_t *pcidsi, const ref *prfont)
30 {
31 ref *prcidsi;
32
33 if (dict_find_string(prfont, "CIDSystemInfo", &prcidsi) <= 0)
34 return_error(e_rangecheck);
35 return cid_system_info_param(pcidsi, prcidsi);
36 }
37
38 /* Get the additional information for a CIDFontType 0 or 2 CIDFont. */
39 int
cid_font_data_param(os_ptr op,gs_font_cid_data * pdata,ref * pGlyphDirectory)40 cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory)
41 {
42 int code;
43 ref *pgdir;
44
45 check_type(*op, t_dictionary);
46 if ((code = cid_font_system_info_param(&pdata->CIDSystemInfo, op)) < 0 ||
47 (code = dict_int_param(op, "CIDCount", 0, max_int, -1,
48 &pdata->CIDCount)) < 0
49 )
50 return code;
51 /*
52 * If the font doesn't have a GlyphDirectory, GDBytes is required.
53 * If it does have a GlyphDirectory, GDBytes may still be needed for
54 * CIDMap: it's up to the client to check this.
55 */
56 if (dict_find_string(op, "GlyphDirectory", &pgdir) <= 0) {
57 /* Standard CIDFont, require GDBytes. */
58 make_null(pGlyphDirectory);
59 return dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 0,
60 &pdata->GDBytes);
61 }
62 if (r_has_type(pgdir, t_dictionary) || r_is_array(pgdir)) {
63 /* GlyphDirectory, GDBytes is optional. */
64 *pGlyphDirectory = *pgdir;
65 code = dict_int_param(op, "GDBytes", 0, MAX_GDBytes, 0,
66 &pdata->GDBytes);
67 return code;
68 } else {
69 return_error(e_typecheck);
70 }
71 }
72