/src/ghostpdl/pdf/pdf_font.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* Copyright (C) 2018-2025 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 | | /* Font operations for the PDF interpreter */ |
17 | | |
18 | | #include "pdf_font_types.h" |
19 | | #include "pdf_stack.h" |
20 | | |
21 | | #ifndef PDF_FONT_OPERATORS |
22 | | #define PDF_FONT_OPERATORS |
23 | | |
24 | | int pdfi_d0(pdf_context *ctx); |
25 | | int pdfi_d1(pdf_context *ctx); |
26 | | int pdfi_Tf(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict); |
27 | | int pdfi_free_font(pdf_obj *font); |
28 | | |
29 | | static inline void pdfi_countup_current_font(pdf_context *ctx) |
30 | 0 | { |
31 | 0 | pdf_font *font; |
32 | 0 |
|
33 | 0 | if (ctx->pgs->font != NULL) { |
34 | 0 | font = (pdf_font *)ctx->pgs->font->client_data; |
35 | 0 | pdfi_countup(font); |
36 | 0 | } |
37 | 0 | } Unexecuted instantiation: ghostpdf.c:pdfi_countup_current_font Unexecuted instantiation: pdf_int.c:pdfi_countup_current_font Unexecuted instantiation: pdf_gstate.c:pdfi_countup_current_font Unexecuted instantiation: pdf_page.c:pdfi_countup_current_font Unexecuted instantiation: pdf_annot.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font0.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font1.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font1C.c:pdfi_countup_current_font Unexecuted instantiation: pdf_fontps.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font3.c:pdfi_countup_current_font Unexecuted instantiation: pdf_fontTT.c:pdfi_countup_current_font Unexecuted instantiation: pdf_font11.c:pdfi_countup_current_font Unexecuted instantiation: pdf_fmap.c:pdfi_countup_current_font Unexecuted instantiation: pdf_text.c:pdfi_countup_current_font Unexecuted instantiation: pdf_obj.c:pdfi_countup_current_font Unexecuted instantiation: pdf_fapi.c:pdfi_countup_current_font |
38 | | |
39 | | static inline void pdfi_countdown_current_font(pdf_context *ctx) |
40 | 0 | { |
41 | 0 | pdf_font *font; |
42 | |
|
43 | 0 | if (ctx->pgs->font != NULL) { |
44 | 0 | font = (pdf_font *)ctx->pgs->font->client_data; |
45 | 0 | pdfi_countdown(font); |
46 | 0 | } |
47 | 0 | } Unexecuted instantiation: ghostpdf.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_int.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_gstate.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_page.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_annot.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font0.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font1.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font1C.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_fontps.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font3.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_fontTT.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_font11.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_fmap.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_text.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_obj.c:pdfi_countdown_current_font Unexecuted instantiation: pdf_fapi.c:pdfi_countdown_current_font |
48 | | |
49 | | static inline pdf_font *pdfi_get_current_pdf_font(pdf_context *ctx) |
50 | 45.4M | { |
51 | 45.4M | pdf_font *font; |
52 | | |
53 | 45.4M | if (ctx->pgs->font != NULL) { |
54 | 45.4M | font = (pdf_font *)ctx->pgs->font->client_data; |
55 | 45.4M | return(font); |
56 | 45.4M | } |
57 | 6.48k | return NULL; |
58 | 45.4M | } Unexecuted instantiation: ghostpdf.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_int.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_gstate.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_page.c:pdfi_get_current_pdf_font pdf_annot.c:pdfi_get_current_pdf_font Line | Count | Source | 50 | 48.8k | { | 51 | 48.8k | pdf_font *font; | 52 | | | 53 | 48.8k | if (ctx->pgs->font != NULL) { | 54 | 48.7k | font = (pdf_font *)ctx->pgs->font->client_data; | 55 | 48.7k | return(font); | 56 | 48.7k | } | 57 | 84 | return NULL; | 58 | 48.8k | } |
Unexecuted instantiation: pdf_font.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_font0.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_font1.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_font1C.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_fontps.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_font3.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_fontTT.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_font11.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_fmap.c:pdfi_get_current_pdf_font pdf_text.c:pdfi_get_current_pdf_font Line | Count | Source | 50 | 45.4M | { | 51 | 45.4M | pdf_font *font; | 52 | | | 53 | 45.4M | if (ctx->pgs->font != NULL) { | 54 | 45.4M | font = (pdf_font *)ctx->pgs->font->client_data; | 55 | 45.4M | return(font); | 56 | 45.4M | } | 57 | 6.39k | return NULL; | 58 | 45.4M | } |
Unexecuted instantiation: pdf_obj.c:pdfi_get_current_pdf_font Unexecuted instantiation: pdf_fapi.c:pdfi_get_current_pdf_font |
59 | | |
60 | | void pdfi_purge_cache_resource_font(pdf_context *ctx); |
61 | | |
62 | | int pdfi_create_Widths(pdf_context *ctx, pdf_dict *font_dict, pdf_font *pdffont); |
63 | | int pdfi_create_Encoding(pdf_context *ctx, pdf_font *ppdffont, pdf_obj *pdf_Encoding, pdf_obj *font_Encoding, pdf_obj **Encoding); |
64 | | gs_glyph pdfi_encode_char(gs_font * pfont, gs_char chr, gs_glyph_space_t not_used); |
65 | | int pdfi_glyph_index(gs_font *pfont, byte *str, uint size, uint *glyph); |
66 | | int pdfi_glyph_name(gs_font * pfont, gs_glyph glyph, gs_const_string * pstr); |
67 | | |
68 | | void pdfi_cidfont_cid_subst_tables(const char *reg, const int reglen, const char *ord, |
69 | | const int ordlen, pdfi_cid_decoding_t **decoding, pdfi_cid_subst_nwp_table_t **substnwp); |
70 | | |
71 | | int pdfi_cidfont_decode_glyph(gs_font *font, gs_glyph glyph, int ch, ushort *u, unsigned int length); |
72 | | |
73 | | int pdfi_tounicode_char_to_unicode(pdf_context *ctx, pdf_cmap *tounicode, gs_glyph glyph, int ch, ushort *unicode_return, unsigned int length); |
74 | | int pdfi_decode_glyph(gs_font * font, gs_glyph glyph, int ch, ushort *unicode_return, unsigned int length); |
75 | | |
76 | | /* This is in pdf_fapi.c, but since it is the only exported function |
77 | | from that module (so far) it doesn't seem worth a new header |
78 | | */ |
79 | | int pdfi_fapi_passfont(pdf_font *font, int subfont, char *fapi_request, |
80 | | char *file_name, byte * font_data, int font_data_len); |
81 | | |
82 | | int pdfi_fapi_check_cmap_for_GID(gs_font *pfont, uint c, uint *g); |
83 | | |
84 | | #ifdef UFST_BRIDGE |
85 | | bool pdfi_fapi_ufst_available(gs_memory_t *mem); |
86 | | int pdfi_fapi_get_mtype_font_name(gs_font * pfont, byte * data, int *size); |
87 | | int pdfi_fapi_get_mtype_font_number(gs_font * pfont, int *font_number); |
88 | | const char *pdfi_fapi_ufst_get_fco_list(gs_memory_t *mem); |
89 | | const char *pdfi_fapi_ufst_get_font_dir(gs_memory_t *mem); |
90 | | int pdfi_lookup_fco_char_code(const char *decname, int32_t decnamelen, const char *gname, int32_t gnamelen, int64_t *charcode); |
91 | | #else /* UFST_BRIDGE */ |
92 | | #define pdfi_fapi_get_mtype_font_name(pfont, data, size) gs_error_undefined |
93 | | #define pdfi_fapi_get_mtype_font_number(pfont, font_number) gs_error_undefined |
94 | | #define pdfi_lookup_fco_char_code(decname, decnamelen, gname, gnamelen, charcode) gs_error_undefined |
95 | | #endif /* UFST_BRIDGE */ |
96 | | |
97 | | |
98 | | int pdfi_map_glyph_name_via_agl(pdf_dict *cstrings, pdf_name *gname, pdf_string **cstring); |
99 | | |
100 | | int pdfi_init_font_directory(pdf_context *ctx); |
101 | | |
102 | | int pdfi_load_font(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict, pdf_dict *font_dict, gs_font **ppfont, bool cidfont); |
103 | | |
104 | | int pdfi_load_dict_font(pdf_context *ctx, pdf_dict *stream_dict, pdf_dict *page_dict, pdf_dict *font_dict, double point_size); |
105 | | |
106 | | /* Loads a (should be!) non-embedded font by name |
107 | | Only currently works for the Type 1 font set from romfs. |
108 | | */ |
109 | | int pdfi_load_font_by_name_string(pdf_context *ctx, const byte *fontname, size_t length, pdf_obj **ppdffont); |
110 | | |
111 | | /* Convenience function for using fonts created by |
112 | | pdfi_load_font_by_name_string |
113 | | */ |
114 | | int pdfi_set_font_internal(pdf_context *ctx, pdf_obj *fontobj, double point_size); |
115 | | |
116 | | int pdfi_font_set_internal_string(pdf_context *ctx, const char *fontname, double point_size); |
117 | | int pdfi_font_set_internal_name(pdf_context *ctx, pdf_name *fontname, double point_size); |
118 | | bool pdfi_font_known_symbolic(pdf_obj *basefont); |
119 | | |
120 | | |
121 | | enum { |
122 | | GLYPH_W0_WIDTH_INDEX = 0, |
123 | | GLYPH_W0_HEIGHT_INDEX = 1, |
124 | | GLYPH_W1_WIDTH_INDEX = 2, |
125 | | GLYPH_W1_HEIGHT_INDEX = 3, |
126 | | GLYPH_W1_V_X_INDEX = 4, |
127 | | GLYPH_W1_V_Y_INDEX = 5 |
128 | | }; |
129 | | |
130 | | int pdfi_get_cidfont_glyph_metrics(gs_font *pfont, gs_glyph cid, double *widths, bool vertical); |
131 | | int pdfi_font_create_widths(pdf_context *ctx, pdf_dict *fontdict, pdf_font *font, double wscale); |
132 | | void pdfi_font_set_first_last_char(pdf_context *ctx, pdf_dict *fontdict, pdf_font *font); |
133 | | int pdfi_font_generate_pseudo_XUID(pdf_context *ctx, pdf_dict *fontdict, gs_font_base *pfont); |
134 | | void pdfi_font_set_orig_fonttype(pdf_context *ctx, pdf_font *font); |
135 | | |
136 | | |
137 | | font_proc_font_info(pdfi_default_font_info); |
138 | | |
139 | | #endif |