Coverage Report

Created: 2026-07-24 07:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ghostpdl/psi/zfont32.c
Line
Count
Source
1
/* Copyright (C) 2001-2026 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
#include "iddict.h"
29
30
/* The encode_char procedure of a Type 32 font should never be called. */
31
static gs_glyph
32
zfont_no_encode_char(gs_font *pfont, gs_char chr, gs_glyph_space_t ignored)
33
0
{
34
0
    return GS_NO_GLYPH;
35
0
}
36
37
/* <string|name> <font_dict> .buildfont32 <string|name> <font> */
38
/* Build a type 32 (bitmap) font. */
39
static int
40
zbuildfont32(i_ctx_t *i_ctx_p)
41
9
{
42
9
    os_ptr op = osp;
43
9
    int code;
44
9
    build_proc_refs build;
45
9
    gs_font_base *pfont;
46
47
9
    check_op(2);
48
1
    check_type(*op, t_dictionary);
49
0
    code = build_proc_name_refs(imemory, &build, NULL, "%Type32BuildGlyph");
50
0
    if (code < 0)
51
0
        return code;
52
0
    code = build_gs_simple_font(i_ctx_p, op, &pfont, ft_CID_bitmap,
53
0
                                &st_gs_font_base, &build,
54
0
                                bf_Encoding_optional);
55
0
    if (code < 0)
56
0
        return code;
57
    /* Always transform cached bitmaps. */
58
0
    pfont->BitmapWidths = true;
59
0
    pfont->ExactSize = fbit_transform_bitmaps;
60
0
    pfont->InBetweenSize = fbit_transform_bitmaps;
61
0
    pfont->TransformedChar = fbit_transform_bitmaps;
62
    /* The encode_char procedure of a Type 32 font */
63
    /* should never be called. */
64
0
    pfont->procs.encode_char = zfont_no_encode_char;
65
0
    return define_gs_font(i_ctx_p, (gs_font *) pfont);
66
0
}
67
68
static int
69
zbuildcidfont4(i_ctx_t *i_ctx_p)
70
0
{
71
0
    os_ptr op = osp;
72
0
    int code = 0;
73
0
    ref csd, ftype;
74
75
0
    check_op(2);
76
0
    check_type(*op, t_dictionary);
77
0
    if ((code = dict_create((uint) 20, &csd)) < 0)
78
0
        return code;
79
0
    make_int(&ftype, 32);
80
0
    if ((code = idict_put_string_copy(op, "CharStrings", &csd)) < 0)
81
0
        return code;
82
0
    if ((code = idict_put_string_copy(op, "FontType", &ftype)) < 0)
83
0
        return code;
84
85
0
    return zbuildfont32(i_ctx_p);
86
0
}
87
88
/* - .getshowoperator <oper|null> */
89
/* Get the calling operator for error reporting in %Type32BuildGlyph */
90
static int
91
zgetshowoperator(i_ctx_t *i_ctx_p)
92
0
{
93
0
    os_ptr op = osp;
94
0
    gs_text_enum_t *osenum = op_show_find(i_ctx_p);
95
96
0
    push(1);
97
0
    if (osenum == NULL)
98
0
        make_null(op);
99
0
    else {
100
0
        op_proc_t proc;
101
0
        *(void **)&proc = osenum->enum_client_data;
102
0
        make_oper(op, 0, proc);
103
0
    }
104
0
    return 0;
105
0
}
106
107
/* ------ Initialization procedure ------ */
108
109
const op_def zfont32_op_defs[] =
110
{
111
    {"2.buildfont32", zbuildfont32},
112
    {"2.buildcidfont4", zbuildcidfont4},
113
    {"0.getshowoperator", zgetshowoperator},
114
    op_def_end(0)
115
};