/src/ghostpdl/devices/vector/gdevpdt.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 | | /* Miscellaneous external entry points for pdfwrite text */ |
18 | | #include "gx.h" |
19 | | #include "memory_.h" |
20 | | #include "gdevpdfx.h" |
21 | | #include "gdevpdtx.h" |
22 | | #include "gdevpdtf.h" |
23 | | #include "gdevpdti.h" |
24 | | |
25 | | /* GC descriptors */ |
26 | | private_st_pdf_text_data(); |
27 | | |
28 | | /* ---------------- Initialization ---------------- */ |
29 | | |
30 | | /* |
31 | | * Allocate and initialize the text data structure. |
32 | | */ |
33 | | pdf_text_data_t * |
34 | | pdf_text_data_alloc(gs_memory_t *mem) |
35 | 34.0k | { |
36 | 34.0k | pdf_text_data_t *ptd = |
37 | 34.0k | gs_alloc_struct(mem, pdf_text_data_t, &st_pdf_text_data, |
38 | 34.0k | "pdf_text_data_alloc"); |
39 | 34.0k | pdf_outline_fonts_t *pofs = pdf_outline_fonts_alloc(mem); |
40 | 34.0k | pdf_bitmap_fonts_t *pbfs = pdf_bitmap_fonts_alloc(mem); |
41 | 34.0k | pdf_text_state_t *pts = pdf_text_state_alloc(mem); |
42 | | |
43 | 34.0k | if (pts == 0 || pbfs == 0 || pofs == 0 || ptd == 0) { |
44 | 0 | gs_free_object(mem, pts, "pdf_text_data_alloc"); |
45 | 0 | gs_free_object(mem, pbfs, "pdf_text_data_alloc"); |
46 | 0 | gs_free_object(mem, pofs, "pdf_text_data_alloc"); |
47 | 0 | gs_free_object(mem, ptd, "pdf_text_data_alloc"); |
48 | 0 | return 0; |
49 | 0 | } |
50 | 34.0k | memset(ptd, 0, sizeof(*ptd)); |
51 | 34.0k | ptd->outline_fonts = pofs; |
52 | 34.0k | ptd->bitmap_fonts = pbfs; |
53 | 34.0k | ptd->text_state = pts; |
54 | 34.0k | return ptd; |
55 | 34.0k | } |
56 | | |
57 | | int text_data_free(gs_memory_t *mem, pdf_text_data_t *ptd) |
58 | 34.0k | { |
59 | 34.0k | gs_free_object(mem, ptd->outline_fonts->standard_fonts, "Free text Outline standard fonts");; |
60 | 34.0k | gs_free_object(mem, ptd->outline_fonts, "Free text Outline fonts");; |
61 | 34.0k | gs_free_object(mem, ptd->bitmap_fonts, "Free text Bitmap fotns");; |
62 | 34.0k | gs_free_object(mem, ptd->text_state, "Free text state");; |
63 | 34.0k | gs_free_object(mem, ptd, "Free text"); |
64 | | |
65 | 34.0k | return 0; |
66 | 34.0k | } |