| 1 |
/* This is dvipdfmx, an eXtended version of dvipdfm by Mark A. Wicks. |
| 2 |
|
| 3 |
Copyright (C) 2002-2020 by Jin-Hwan Cho and Shunsaku Hirata, |
| 4 |
the dvipdfmx project team. |
| 5 |
|
| 6 |
This program 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 |
This program 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 |
| 17 |
along with this program; if not, write to the Free Software |
| 18 |
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef _CFF_H_ |
| 22 |
#define _CFF_H_ |
| 23 |
|
| 24 |
#include "mfileio.h" |
| 25 |
#include "cff_types.h" |
| 26 |
|
| 27 |
/* Flag */ |
| 28 |
#define FONTTYPE_CIDFONT (1 << 0) |
| 29 |
#define FONTTYPE_FONT (1 << 1) |
| 30 |
#define FONTTYPE_MMASTER (1 << 2) |
| 31 |
|
| 32 |
#define ENCODING_STANDARD (1 << 3) |
| 33 |
#define ENCODING_EXPERT (1 << 4) |
| 34 |
|
| 35 |
#define CHARSETS_ISOADOBE (1 << 5) |
| 36 |
#define CHARSETS_EXPERT (1 << 6) |
| 37 |
#define CHARSETS_EXPSUB (1 << 7) |
| 38 |
|
| 39 |
#define HAVE_STANDARD_ENCODING (ENCODING_STANDARD|ENCODING_EXPERT) |
| 40 |
#define HAVE_STANDARD_CHARSETS \ |
| 41 |
(CHARSETS_ISOADOBE|CHARSETS_EXPERT|CHARSETS_EXPSUB) |
| 42 |
|
| 43 |
#define CFF_STRING_NOTDEF 65535 |
| 44 |
|
| 45 |
typedef struct |
| 46 |
{ |
| 47 |
char *fontname; /* FontName */ |
| 48 |
|
| 49 |
/* - CFF structure - */ |
| 50 |
cff_header header; /* CFF Header */ |
| 51 |
cff_index *name; /* Name INDEX */ |
| 52 |
cff_dict *topdict; /* Top DICT (single) */ |
| 53 |
cff_index *string; /* String INDEX */ |
| 54 |
cff_index *gsubr; /* Global Subr INDEX */ |
| 55 |
cff_encoding *encoding; /* Encodings */ |
| 56 |
cff_charsets *charsets; /* Charsets */ |
| 57 |
cff_fdselect *fdselect; /* FDSelect, CIDFont only */ |
| 58 |
cff_index *cstrings; /* CharStrings */ |
| 59 |
cff_dict **fdarray; /* CIDFont only */ |
| 60 |
cff_dict **private; /* per-Font DICT */ |
| 61 |
cff_index **subrs; /* Local Subr INDEX, per-Private DICT */ |
| 62 |
|
| 63 |
/* -- extra data -- */ |
| 64 |
l_offset offset; /* non-zero for OpenType or PostScript wrapped */ |
| 65 |
l_offset gsubr_offset; |
| 66 |
card16 num_glyphs; /* number of glyphs (CharString INDEX count) */ |
| 67 |
card8 num_fds; /* number of Font DICT */ |
| 68 |
|
| 69 |
/* Updated String INDEX. |
| 70 |
* Please fix this. We should separate input and output. |
| 71 |
*/ |
| 72 |
cff_index *_string; |
| 73 |
|
| 74 |
FILE *stream; |
| 75 |
|
| 76 |
int filter; /* not used, ASCII Hex filter if needed */ |
| 77 |
|
| 78 |
int index; /* CFF fontset index */ |
| 79 |
int flag; /* Flag: see above */ |
| 80 |
int is_notdef_notzero; /* 1 if .notdef is not the 1st glyph */ |
| 81 |
} cff_font; |
| 82 |
|
| 83 |
extern cff_font *cff_open (FILE *file, int offset, int idx); |
| 84 |
#define cff_seek_set(c, p) seek_absolute (((c)->stream), ((c)->offset) + (p)); |
| 85 |
#define cff_read_data(d, l, c) fread(d, 1, l, (c)->stream) |
| 86 |
#define cff_tell(c) ftell((c)->stream) |
| 87 |
#define cff_seek(c, p) seek_absolute((c)->stream, p) |
| 88 |
|
| 89 |
extern void cff_close (cff_font *cff); |
| 90 |
|
| 91 |
/* CFF Header */ |
| 92 |
extern int cff_put_header (cff_font *cff, card8 *dest, int destlen); |
| 93 |
|
| 94 |
/* CFF INDEX */ |
| 95 |
extern cff_index *cff_get_index (cff_font *cff); |
| 96 |
extern cff_index *cff_get_index_header (cff_font *cff); |
| 97 |
extern void cff_release_index (cff_index *idx); |
| 98 |
extern cff_index *cff_new_index (card16 count); |
| 99 |
extern int cff_index_size (cff_index *idx); |
| 100 |
extern int cff_pack_index (cff_index *idx, card8 *dest, int destlen); |
| 101 |
|
| 102 |
/* Name INDEX */ |
| 103 |
extern char *cff_get_name (cff_font *cff); |
| 104 |
extern int cff_set_name (cff_font *cff, char *name); |
| 105 |
|
| 106 |
/* Global and Local Subrs INDEX */ |
| 107 |
extern int cff_read_subrs (cff_font *cff); |
| 108 |
|
| 109 |
/* Encoding */ |
| 110 |
extern int cff_read_encoding (cff_font *cff); |
| 111 |
extern int cff_pack_encoding (cff_font *cff, card8 *dest, int destlen); |
| 112 |
extern card16 cff_encoding_lookup (cff_font *cff, card8 code); |
| 113 |
extern void cff_release_encoding (cff_encoding *encoding); |
| 114 |
|
| 115 |
/* Charsets */ |
| 116 |
extern int cff_read_charsets (cff_font *cff); |
| 117 |
extern int cff_pack_charsets (cff_font *cff, card8 *dest, int destlen); |
| 118 |
|
| 119 |
/* Returns GID of PS name "glyph" */ |
| 120 |
extern card16 cff_glyph_lookup (cff_font *cff, const char *glyph); |
| 121 |
/* Return PS name of "gid" */ |
| 122 |
extern char* cff_get_glyphname (cff_font *cff, card16 gid); |
| 123 |
/* Returns GID of glyph with SID/CID "cid" */ |
| 124 |
extern card16 cff_charsets_lookup (cff_font *cff, card16 cid); |
| 125 |
extern card16 cff_charsets_lookup_gid (cff_charsets *charset, card16 cid); |
| 126 |
extern void cff_release_charsets (cff_charsets *charset); |
| 127 |
/* Returns SID or CID */ |
| 128 |
extern card16 cff_charsets_lookup_inverse (cff_font *cff, card16 gid); |
| 129 |
extern card16 cff_charsets_lookup_cid(cff_charsets *charset, card16 gid); |
| 130 |
|
| 131 |
/* FDSelect */ |
| 132 |
extern int cff_read_fdselect (cff_font *cff); |
| 133 |
extern int cff_pack_fdselect (cff_font *cff, card8 *dest, int destlen); |
| 134 |
extern card8 cff_fdselect_lookup (cff_font *cff, card16 gid); |
| 135 |
extern void cff_release_fdselect (cff_fdselect *fdselect); |
| 136 |
|
| 137 |
/* Font DICT(s) */ |
| 138 |
extern int cff_read_fdarray (cff_font *cff); |
| 139 |
|
| 140 |
/* Private DICT(s) */ |
| 141 |
extern int cff_read_private (cff_font *cff); |
| 142 |
|
| 143 |
/* String */ |
| 144 |
extern char *cff_get_string (cff_font *cff, s_SID id); |
| 145 |
extern int cff_get_sid (cff_font *cff, const char *str); |
| 146 |
extern int cff_get_seac_sid (cff_font *cff, const char *str); |
| 147 |
extern s_SID cff_add_string (cff_font *cff, const char *str, int unique); |
| 148 |
extern void cff_update_string (cff_font *cff); |
| 149 |
|
| 150 |
#endif /* _CFF_H_ */ |