| 1 |
/* |
| 2 |
Copyright 1996-2019 Han The Thanh, <[email protected]> |
| 3 |
|
| 4 |
This file is part of pdfTeX. |
| 5 |
|
| 6 |
pdfTeX is free software; you can redistribute it and/or modify |
| 7 |
it under the terms of the GNU General Public License as published by |
| 8 |
the Free Software Foundation; either version 2 of the License, or |
| 9 |
(at your option) any later version. |
| 10 |
|
| 11 |
pdfTeX is distributed in the hope that it will be useful, |
| 12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License along |
| 17 |
with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
*/ |
| 19 |
|
| 20 |
#include "ptexlib.h" |
| 21 |
#include <string.h> |
| 22 |
|
| 23 |
|
| 24 |
int is_subsetable(fm_entry * fm) |
| 25 |
{ |
| 26 |
assert(is_included(fm)); |
| 27 |
return is_subsetted(fm); |
| 28 |
} |
| 29 |
|
| 30 |
fd_entry *epdf_create_fontdescriptor(fm_entry * fm, int stemV) |
| 31 |
{ |
| 32 |
fd_entry *fd; |
| 33 |
if ((fd = lookup_fd_entry(fm->ff_name, fm->slant, fm->extend)) == NULL) { |
| 34 |
fm->in_use = true; |
| 35 |
fd = new_fd_entry(); |
| 36 |
fd->fm = fm; |
| 37 |
register_fd_entry(fd); |
| 38 |
fd->fd_objnum = pdfnewobjnum(); |
| 39 |
assert(fm->ps_name != NULL); |
| 40 |
fd->fontname = xstrdup(fm->ps_name); /* just fallback */ |
| 41 |
// stemV must be copied |
| 42 |
fd->font_dim[STEMV_CODE].val = stemV; |
| 43 |
fd->font_dim[STEMV_CODE].set = true; |
| 44 |
fd->gl_tree = avl_create(comp_string_entry, NULL, &avl_xallocator); |
| 45 |
assert(fd->gl_tree != NULL); |
| 46 |
} |
| 47 |
return fd; |
| 48 |
} |
| 49 |
|
| 50 |
int get_fd_objnum(fd_entry * fd) |
| 51 |
{ |
| 52 |
assert(fd->fd_objnum != 0); |
| 53 |
return fd->fd_objnum; |
| 54 |
} |
| 55 |
|
| 56 |
int get_fn_objnum(fd_entry * fd) |
| 57 |
{ |
| 58 |
if (fd->fn_objnum == 0) |
| 59 |
fd->fn_objnum = pdfnewobjnum(); |
| 60 |
return fd->fn_objnum; |
| 61 |
} |
| 62 |
|
| 63 |
/*********************************************************************** |
| 64 |
* Mark glyphs used by embedded PDF file: |
| 65 |
* 1. build fontdescriptor, if not yet existing |
| 66 |
* 2. mark glyphs directly there |
| 67 |
* |
| 68 |
* Input charset from xpdf is a string of glyph names including |
| 69 |
* leading slashes, with optional generic spaces, including tabs, |
| 70 |
* \n, \r, and \f, preceding or between them: |
| 71 |
/a/b/c or /a /b /c or /a/b /c, etc. |
| 72 |
***********************************************************************/ |
| 73 |
|
| 74 |
#define Isgenericspace(c) (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f') |
| 75 |
|
| 76 |
void epdf_mark_glyphs(fd_entry * fd, char *charset) |
| 77 |
{ |
| 78 |
char *p, *q, *s; |
| 79 |
char *glyph; |
| 80 |
void **aa; |
| 81 |
if (charset == NULL) |
| 82 |
return; |
| 83 |
assert(fd != NULL); |
| 84 |
while (Isgenericspace(*charset)) |
| 85 |
charset++; |
| 86 |
for (s = charset + 1, q = charset + strlen(charset); s < q; s = p + 1) { |
| 87 |
for (p = s; *p != '\0' && *p != '/' && !Isgenericspace(*p); p++); |
| 88 |
if (Isgenericspace(*p)) { |
| 89 |
*p = '\0'; |
| 90 |
p++; |
| 91 |
while (Isgenericspace(*p)) |
| 92 |
p++; |
| 93 |
} |
| 94 |
*p = '\0'; |
| 95 |
if ((char *) avl_find(fd->gl_tree, s) == NULL) { |
| 96 |
glyph = xstrdup(s); |
| 97 |
aa = avl_probe(fd->gl_tree, glyph); |
| 98 |
assert(aa != NULL); |
| 99 |
} |
| 100 |
} |
| 101 |
} |
| 102 |
|
| 103 |
void embed_whole_font(fd_entry * fd) |
| 104 |
{ |
| 105 |
fd->all_glyphs = true; |
| 106 |
} |
| 107 |
|
| 108 |
void epdf_free(void) |
| 109 |
{ |
| 110 |
epdf_check_mem(); |
| 111 |
} |