/src/ghostpdl/psi/zfont32.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2001-2023 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, |
8 | | modified or distributed except as expressly authorized under the terms |
9 | | of the license contained in the file LICENSE in this distribution. |
10 | | |
11 | | Refer to licensing information at http://www.artifex.com or contact |
12 | | Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
13 | | CA 94129, USA, for further information. |
14 | | */ |
15 | | |
16 | | |
17 | | /* Type 32 font operators */ |
18 | | #include "ghost.h" |
19 | | #include "oper.h" |
20 | | #include "gsccode.h" /* for gxfont.h */ |
21 | | #include "gsmatrix.h" |
22 | | #include "gsutil.h" |
23 | | #include "gxfont.h" |
24 | | #include "gxtext.h" |
25 | | #include "bfont.h" |
26 | | #include "store.h" |
27 | | #include "ichar.h" |
28 | | |
29 | | /* The encode_char procedure of a Type 32 font should never be called. */ |
30 | | static gs_glyph |
31 | | zfont_no_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t ignored) |
32 | 0 | { |
33 | 0 | return GS_NO_GLYPH; |
34 | 0 | } |
35 | | |
36 | | /* <string|name> <font_dict> .buildfont32 <string|name> <font> */ |
37 | | /* Build a type 32 (bitmap) font. */ |
38 | | static int |
39 | | zbuildfont32(i_ctx_t *i_ctx_p) |
40 | 3 | { |
41 | 3 | os_ptr op = osp; |
42 | 3 | int code; |
43 | 3 | build_proc_refs build; |
44 | 3 | gs_font_base *pfont; |
45 | | |
46 | 3 | check_op(2); |
47 | 0 | check_type(*op, t_dictionary); |
48 | 0 | code = build_proc_name_refs(imemory, &build, NULL, "%Type32BuildGlyph"); |
49 | 0 | if (code < 0) |
50 | 0 | return code; |
51 | 0 | code = build_gs_simple_font(i_ctx_p, op, &pfont, ft_CID_bitmap, |
52 | 0 | &st_gs_font_base, &build, |
53 | 0 | bf_Encoding_optional); |
54 | 0 | if (code < 0) |
55 | 0 | return code; |
56 | | /* Always transform cached bitmaps. */ |
57 | 0 | pfont->BitmapWidths = true; |
58 | 0 | pfont->ExactSize = fbit_transform_bitmaps; |
59 | 0 | pfont->InBetweenSize = fbit_transform_bitmaps; |
60 | 0 | pfont->TransformedChar = fbit_transform_bitmaps; |
61 | | /* The encode_char procedure of a Type 32 font */ |
62 | | /* should never be called. */ |
63 | 0 | pfont->procs.encode_char = zfont_no_encode_char; |
64 | 0 | return define_gs_font(i_ctx_p, (gs_font *) pfont); |
65 | 0 | } |
66 | | |
67 | | /* - .getshowoperator <oper|null> */ |
68 | | /* Get the calling operator for error reporting in %Type32BuildGlyph */ |
69 | | static int |
70 | | zgetshowoperator(i_ctx_t *i_ctx_p) |
71 | 0 | { |
72 | 0 | os_ptr op = osp; |
73 | 0 | gs_text_enum_t *osenum = op_show_find(i_ctx_p); |
74 | |
|
75 | 0 | push(1); |
76 | 0 | if (osenum == NULL) |
77 | 0 | make_null(op); |
78 | 0 | else { |
79 | 0 | op_proc_t proc; |
80 | 0 | *(void **)&proc = osenum->enum_client_data; |
81 | 0 | make_oper(op, 0, proc); |
82 | 0 | } |
83 | 0 | return 0; |
84 | 0 | } |
85 | | |
86 | | /* ------ Initialization procedure ------ */ |
87 | | |
88 | | const op_def zfont32_op_defs[] = |
89 | | { |
90 | | {"2.buildfont32", zbuildfont32}, |
91 | | {"0.getshowoperator", zgetshowoperator}, |
92 | | op_def_end(0) |
93 | | }; |