Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/include/mupdf/pdf/cmap.h @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 // Copyright (C) 2004-2025 Artifex Software, Inc. | |
| 2 // | |
| 3 // This file is part of MuPDF. | |
| 4 // | |
| 5 // MuPDF is free software: you can redistribute it and/or modify it under the | |
| 6 // terms of the GNU Affero General Public License as published by the Free | |
| 7 // Software Foundation, either version 3 of the License, or (at your option) | |
| 8 // any later version. | |
| 9 // | |
| 10 // MuPDF is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 11 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | |
| 12 // FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more | |
| 13 // details. | |
| 14 // | |
| 15 // You should have received a copy of the GNU Affero General Public License | |
| 16 // along with MuPDF. If not, see <https://www.gnu.org/licenses/agpl-3.0.en.html> | |
| 17 // | |
| 18 // Alternative licensing terms are available from the licensor. | |
| 19 // For commercial licensing, see <https://www.artifex.com/> or contact | |
| 20 // Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, | |
| 21 // CA 94129, USA, for further information. | |
| 22 | |
| 23 #ifndef MUPDF_PDF_CMAP_H | |
| 24 #define MUPDF_PDF_CMAP_H | |
| 25 | |
| 26 #include "mupdf/fitz/store.h" | |
| 27 #include "mupdf/pdf/document.h" | |
| 28 | |
| 29 #define PDF_MRANGE_CAP 32 | |
| 30 | |
| 31 typedef struct | |
| 32 { | |
| 33 unsigned short low, high, out; | |
| 34 } pdf_range; | |
| 35 | |
| 36 typedef struct | |
| 37 { | |
| 38 unsigned int low, high, out; | |
| 39 } pdf_xrange; | |
| 40 | |
| 41 typedef struct | |
| 42 { | |
| 43 unsigned int low, out; | |
| 44 } pdf_mrange; | |
| 45 | |
| 46 typedef struct cmap_splay cmap_splay; | |
| 47 | |
| 48 typedef struct pdf_cmap | |
| 49 { | |
| 50 fz_storable storable; | |
| 51 char cmap_name[32]; | |
| 52 | |
| 53 char usecmap_name[32]; | |
| 54 struct pdf_cmap *usecmap; | |
| 55 | |
| 56 int wmode; | |
| 57 | |
| 58 int codespace_len; | |
| 59 struct | |
| 60 { | |
| 61 int n; | |
| 62 unsigned int low; | |
| 63 unsigned int high; | |
| 64 } codespace[40]; | |
| 65 | |
| 66 int rlen, rcap; | |
| 67 pdf_range *ranges; | |
| 68 | |
| 69 int xlen, xcap; | |
| 70 pdf_xrange *xranges; | |
| 71 | |
| 72 int mlen, mcap; | |
| 73 pdf_mrange *mranges; | |
| 74 | |
| 75 int dlen, dcap; | |
| 76 int *dict; | |
| 77 | |
| 78 int tlen, tcap, ttop; | |
| 79 cmap_splay *tree; | |
| 80 } pdf_cmap; | |
| 81 | |
| 82 pdf_cmap *pdf_new_cmap(fz_context *ctx); | |
| 83 pdf_cmap *pdf_keep_cmap(fz_context *ctx, pdf_cmap *cmap); | |
| 84 void pdf_drop_cmap(fz_context *ctx, pdf_cmap *cmap); | |
| 85 void pdf_drop_cmap_imp(fz_context *ctx, fz_storable *cmap); | |
| 86 size_t pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap); | |
| 87 | |
| 88 int pdf_cmap_wmode(fz_context *ctx, pdf_cmap *cmap); | |
| 89 void pdf_set_cmap_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode); | |
| 90 void pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap); | |
| 91 | |
| 92 /* | |
| 93 Add a codespacerange section. | |
| 94 These ranges are used by pdf_decode_cmap to decode | |
| 95 multi-byte encoded strings. | |
| 96 */ | |
| 97 void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, unsigned int low, unsigned int high, size_t n); | |
| 98 | |
| 99 /* | |
| 100 Add a range of contiguous one-to-one mappings (i.e. 1..5 maps to 21..25) | |
| 101 */ | |
| 102 void pdf_map_range_to_range(fz_context *ctx, pdf_cmap *cmap, unsigned int srclo, unsigned int srchi, int dstlo); | |
| 103 | |
| 104 /* | |
| 105 Add a single one-to-many mapping. | |
| 106 | |
| 107 len <= 256. | |
| 108 */ | |
| 109 void pdf_map_one_to_many(fz_context *ctx, pdf_cmap *cmap, unsigned int one, int *many, size_t len); | |
| 110 void pdf_sort_cmap(fz_context *ctx, pdf_cmap *cmap); | |
| 111 | |
| 112 /* | |
| 113 Lookup the mapping of a codepoint. | |
| 114 */ | |
| 115 int pdf_lookup_cmap(pdf_cmap *cmap, unsigned int cpt); | |
| 116 int pdf_lookup_cmap_full(pdf_cmap *cmap, unsigned int cpt, int *out); | |
| 117 | |
| 118 /* | |
| 119 Use the codespace ranges to extract a codepoint from a | |
| 120 multi-byte encoded string. | |
| 121 */ | |
| 122 int pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, unsigned char *e, unsigned int *cpt); | |
| 123 | |
| 124 /* | |
| 125 Create an Identity-* CMap (for both 1 and 2-byte encodings) | |
| 126 */ | |
| 127 pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes); | |
| 128 pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file); | |
| 129 | |
| 130 /* | |
| 131 Load predefined CMap from system. | |
| 132 */ | |
| 133 pdf_cmap *pdf_load_system_cmap(fz_context *ctx, const char *name); | |
| 134 | |
| 135 /* | |
| 136 Load built-in CMap resource. | |
| 137 */ | |
| 138 pdf_cmap *pdf_load_builtin_cmap(fz_context *ctx, const char *name); | |
| 139 | |
| 140 /* | |
| 141 Load CMap stream in PDF file | |
| 142 */ | |
| 143 pdf_cmap *pdf_load_embedded_cmap(fz_context *ctx, pdf_document *doc, pdf_obj *ref); | |
| 144 | |
| 145 #endif |
