summaryrefslogtreecommitdiff
path: root/gs/src/zcid.c
blob: e17e9f0ee25e801f329980e880b6f61215463ce4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/* Copyright (C) 1996, 1997 Aladdin Enterprises.  All rights reserved.
  
  This file is part of Aladdin Ghostscript.
  
  Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  or distributor accepts any responsibility for the consequences of using it,
  or for whether it serves any particular purpose or works at all, unless he
  or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  License (the "License") for full details.
  
  Every copy of Aladdin Ghostscript must include a copy of the License,
  normally in a plain ASCII text file named PUBLIC.  The License grants you
  the right to copy, modify and redistribute Aladdin Ghostscript, but only
  under certain conditions described in the License.  Among other things, the
  License requires that the copyright notice and this notice be preserved on
  all copies.
*/

/* zcid.c */
/* CID-keyed font operators */
#include "ghost.h"
#include "errors.h"
#include "oper.h"
#include "gsmatrix.h"
#include "gsccode.h"
#include "gxfont.h"
#include "bfont.h"
#include "iname.h"
#include "store.h"

/* Imported from zfont42.c */
int build_gs_TrueType_font(P5(os_ptr op, font_type ftype,
			      const char _ds *bcstr, const char _ds *bgstr,
			      build_font_options_t options));

/* <string|name> <font_dict> .buildfont9/10 <string|name> <font> */
/* Build a type 9 or 10 (CID-keyed) font. */
/* Right now, we treat these like type 3 (with a BuildGlyph procedure). */
private int
build_gs_cid_font(os_ptr op, font_type ftype, const build_proc_refs *pbuild)
{	int code;
	gs_font_base *pfont;

	check_type(*op, t_dictionary);
	code = build_gs_simple_font(op, &pfont, ftype, &st_gs_font_base,
				    pbuild,
				    bf_Encoding_optional |
				    bf_FontBBox_required |
				    bf_UniqueID_ignored);
	if ( code < 0 )
	  return code;
	return define_gs_font((gs_font *)pfont);
}
private int
zbuildfont9(os_ptr op)
{	build_proc_refs build;
	int code = build_proc_name_refs(&build, NULL, "%Type9BuildGlyph");

	if ( code < 0 )
	  return code;
	return build_gs_cid_font(op, ft_CID_encrypted, &build);
}
private int
zbuildfont10(os_ptr op)
{	build_proc_refs build;
	int code = build_gs_font_procs(op, &build);

	if ( code < 0 )
	  return code;
	make_null(&build.BuildChar); /* only BuildGlyph */
	return build_gs_cid_font(op, ft_CID_user_defined, &build);
}

/* <string|name> <font_dict> .buildfont11 <string|name> <font> */
private int
zbuildfont11(os_ptr op)
{	return build_gs_TrueType_font(op, ft_CID_TrueType, (const char _ds *)0,
				      "%Type11BuildGlyph",
				      bf_Encoding_optional |
				      bf_FontBBox_required |
				      bf_UniqueID_ignored |
				      bf_CharStrings_optional);
}

/* ------ Initialization procedure ------ */

BEGIN_OP_DEFS(zcid_op_defs) {
	{"2.buildfont9", zbuildfont9},
	{"2.buildfont10", zbuildfont10},
	{"2.buildfont11", zbuildfont11},
END_OP_DEFS(0) }