1 /* Copyright (C) 1996, 1997, 1998, 1999, 2000 artofcode LLC.  All rights reserved.
2 
3   This program is free software; you can redistribute it and/or modify it
4   under the terms of the GNU General Public License as published by the
5   Free Software Foundation; either version 2 of the License, or (at your
6   option) any later version.
7 
8   This program is distributed in the hope that it will be useful, but
9   WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11   General Public License for more details.
12 
13   You should have received a copy of the GNU General Public License along
14   with this program; if not, write to the Free Software Foundation, Inc.,
15   59 Temple Place, Suite 330, Boston, MA, 02111-1307.
16 
17 */
18 
19 /*$Id: zfcid.c,v 1.11.4.1.2.1 2003/01/17 00:49:06 giles Exp $ */
20 /* CID-keyed font utilities */
21 #include "ghost.h"
22 #include "oper.h"
23 #include "gsmatrix.h"
24 #include "gxfcid.h"
25 #include "bfont.h"
26 #include "icid.h"
27 #include "idict.h"
28 #include "idparam.h"
29 #include "ifcid.h"
30 #include "store.h"
31 
32 /* Get the CIDSystemInfo of a CIDFont. */
33 int
cid_font_system_info_param(gs_cid_system_info_t * pcidsi,const ref * prfont)34 cid_font_system_info_param(gs_cid_system_info_t *pcidsi, const ref *prfont)
35 {
36     ref *prcidsi;
37 
38     if (dict_find_string(prfont, "CIDSystemInfo", &prcidsi) <= 0)
39 	return_error(e_rangecheck);
40     return cid_system_info_param(pcidsi, prcidsi);
41 }
42 
43 /* Get the additional information for a CIDFontType 0 or 2 CIDFont. */
44 int
cid_font_data_param(os_ptr op,gs_font_cid_data * pdata,ref * pGlyphDirectory)45 cid_font_data_param(os_ptr op, gs_font_cid_data *pdata, ref *pGlyphDirectory)
46 {
47     int code;
48     ref *pgdir;
49 
50     check_type(*op, t_dictionary);
51     if ((code = cid_font_system_info_param(&pdata->CIDSystemInfo, op)) < 0 ||
52 	(code = dict_int_param(op, "CIDCount", 0, max_int, -1,
53 			       &pdata->CIDCount)) < 0
54 	)
55 	return code;
56     /*
57      * If the font doesn't have a GlyphDirectory, GDBytes is required.
58      * If it does have a GlyphDirectory, GDBytes may still be needed for
59      * CIDMap: it's up to the client to check this.
60      */
61     if (dict_find_string(op, "GlyphDirectory", &pgdir) <= 0) {
62 	/* Standard CIDFont, require GDBytes. */
63 	make_null(pGlyphDirectory);
64 	return dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 0,
65 			      &pdata->GDBytes);
66     }
67     if (r_has_type(pgdir, t_dictionary) || r_is_array(pgdir)) {
68 	/* GlyphDirectory, GDBytes is optional. */
69 	*pGlyphDirectory = *pgdir;
70 	code = dict_int_param(op, "GDBytes", 1, MAX_GDBytes, 1,
71 			      &pdata->GDBytes);
72 	if (code == 1) {
73 	    pdata->GDBytes = 0;
74 	    code = 0;
75 	}
76 	return code;
77     } else {
78 	return_error(e_typecheck);
79     }
80 }
81