/* Copyright (C) 1992 Aladdin Enterprises. All rights reserved.
Distributed by Free Software Foundation, Inc.
This file is part of Ghostscript.
Ghostscript is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
to anyone for the consequences of using it or for whether it serves any
particular purpose or works at all, unless he says so in writing. Refer
to the Ghostscript General Public License for full details.
Everyone is granted permission to copy, modify and redistribute
Ghostscript, but only under the conditions described in the Ghostscript
General Public License. A copy of this license is supposed to have been
given to you along with Ghostscript so you can know your rights and
responsibilities. It should be in a file named COPYING. Among other
things, the copyright notice and this notice must be preserved on all
/* Initialization support for compiled fonts */
#include "save.h" /* for alloc_refs */
extern int array_get(P3(const ref
*, long, ref
*));
extern ref name_StandardEncoding
;
/* Check for reaching the end of the keys. */
#define more_keys(kp) ((kp)->num_enc_keys | (kp)->num_str_keys)
/* Put the next entry into a dictionary. */
/* We know that more_keys(kp) is true. */
cfont_put_next(ref
*pdict
, cfont_dict_keys _ss
*kp
, const ref
*pvalue
,
{ /* Create the dictionary and look up the encodings. */
code
= dict_create(kp
->num_enc_keys
+ kp
->num_str_keys
+ kp
->extra_slots
, pdict
);
if ( code
< 0 ) return code
;
make_tasv(&kname
, t_string
, 0, 17, bytes
,
(byte
*)"ISOLatin1Encoding");
if ( dict_find(&systemdict
, &name_StandardEncoding
, &pencodings
[0]) <= 0 ||
dict_find(&systemdict
, &kname
, &pencodings
[1]) <= 0
{ charindex _ds
*skp
= kp
->enc_keys
++;
code
= array_get(pencodings
[skp
->encx
], (long)(skp
->charx
), &kname
);
else /* must have kp->num_str_keys != 0 */
{ const char *skp
= *(kp
->str_keys
++);
code
= name_ref((const byte
*)skp
, strlen(skp
), &kname
, 0);
return dict_put(pdict
, &kname
, pvalue
);
/* Create a dictionary with general ref values. */
cfont_ref_dict_create(ref
*pdict
, const cfont_dict_keys _ds
*kp
,
const ref _ds
* _ds
*values
)
const ref _ds
* _ds
*vp
= values
;
while ( more_keys(&keys
) )
{ const ref
*pvalue
= *vp
++;
if ( r_has_type(pvalue
, t_name
) )
{ /* The "name" is really a string. */
/* Convert it to a real name now. */
code
= name_ref(pvalue
->value
.bytes
, r_size(pvalue
),
if ( code
< 0 ) return code
;
code
= cfont_put_next(pdict
, &keys
, pvalue
, pencodings
);
if ( code
< 0 ) return code
;
/* Create a dictionary with string values. */
cfont_string_dict_create(ref
*pdict
, const cfont_dict_keys _ds
*kp
,
const charray _ds
*values
)
const charray _ds
*vp
= values
;
uint attrs
= kp
->value_attrs
;
while ( more_keys(&keys
) )
make_tasv(&vstring
, t_string
, attrs
,
vp
->len
, bytes
, (byte
*)vp
->str
);
code
= cfont_put_next(pdict
, &keys
, &vstring
, pencodings
);
if ( code
< 0 ) return code
;
/* Create a dictionary with number values. */
cfont_num_dict_create(ref
*pdict
, const cfont_dict_keys _ds
*kp
,
const float _ds
*vp
= values
;
while ( more_keys(&keys
) )
make_int(&vnum
, (int)val
);
code
= cfont_put_next(pdict
, &keys
, &vnum
, pencodings
);
if ( code
< 0 ) return code
;
/* Create an array with name values. */
cfont_name_array_create(ref
*parray
, const char _ds
* _ds
*str_list
,
{ ref
*aptr
= alloc_refs(size
, "cfont_name_array_create");
const char _ds
* _ds
*pstr
= str_list
;
if ( aptr
== 0 ) return e_VMerror
;
make_tasv(parray
, t_array
, a_read
+ a_execute
, size
, refs
, aptr
);
for ( i
= 0; i
< size
; i
++, aptr
++, pstr
++ )
int code
= name_ref((byte
*)*pstr
, strlen(*pstr
), &nref
, 0);
if ( code
< 0 ) return code
;
ref_assign_new(aptr
, &nref
);