| 1 |
/* |
| 2 |
|
| 3 |
Copyright 2008-2013 Taco Hoekwater <[email protected]> |
| 4 |
|
| 5 |
This file is part of LuaTeX. |
| 6 |
|
| 7 |
LuaTeX is free software; you can redistribute it and/or modify it under |
| 8 |
the terms of the GNU General Public License as published by the Free |
| 9 |
Software Foundation; either version 2 of the License, or (at your |
| 10 |
option) any later version. |
| 11 |
|
| 12 |
LuaTeX is distributed in the hope that it will be useful, but WITHOUT |
| 13 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 14 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public |
| 15 |
License for more details. |
| 16 |
|
| 17 |
You should have received a copy of the GNU General Public License along |
| 18 |
with LuaTeX; if not, see <http://www.gnu.org/licenses/>. |
| 19 |
|
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef LUATEXFONT_H |
| 23 |
|
| 24 |
#define LUATEXFONT_H |
| 25 |
|
| 26 |
#include "ptexlib.h" |
| 27 |
#include "sfnt.h" |
| 28 |
|
| 29 |
#define ASCENT_CODE 0 |
| 30 |
#define CAPHEIGHT_CODE 1 |
| 31 |
#define DESCENT_CODE 2 |
| 32 |
#define ITALIC_ANGLE_CODE 3 |
| 33 |
#define STEMV_CODE 4 |
| 34 |
#define XHEIGHT_CODE 5 |
| 35 |
#define FONTBBOX1_CODE 6 |
| 36 |
#define FONTBBOX2_CODE 7 |
| 37 |
#define FONTBBOX3_CODE 8 |
| 38 |
#define FONTBBOX4_CODE 9 |
| 39 |
#define FONTNAME_CODE 10 |
| 40 |
#define GEN_KEY_NUM (XHEIGHT_CODE + 1) |
| 41 |
#define MAX_KEY_CODE (FONTBBOX1_CODE + 1) |
| 42 |
#define INT_KEYS_NUM (FONTBBOX4_CODE + 1) |
| 43 |
#define FONT_KEYS_NUM (FONTNAME_CODE + 1) |
| 44 |
|
| 45 |
#define FD_FLAGS_NOT_SET_IN_MAPLINE -1 |
| 46 |
#define FD_FLAGS_DEFAULT_EMBED 4 /* a symbol font */ |
| 47 |
#define FD_FLAGS_DEFAULT_NON_EMBED 0x22 /* a nonsymbolic serif font */ |
| 48 |
|
| 49 |
typedef struct { |
| 50 |
const char *pdfname; |
| 51 |
const char *t1name; |
| 52 |
boolean valid; |
| 53 |
} key_entry; |
| 54 |
|
| 55 |
extern const key_entry font_key[FONT_KEYS_NUM]; |
| 56 |
|
| 57 |
#include "mapfile.h" |
| 58 |
|
| 59 |
typedef struct { |
| 60 |
int val; /* value */ |
| 61 |
boolean set; /* true if parameter has been set */ |
| 62 |
} intparm; |
| 63 |
|
| 64 |
typedef struct { |
| 65 |
int fe_objnum; /* object number */ |
| 66 |
char *name; /* encoding file name */ |
| 67 |
char **glyph_names; /* array of glyph names */ |
| 68 |
struct avl_table *tx_tree; /* tree of encoding positions marked as used by TeX */ |
| 69 |
} fe_entry; |
| 70 |
|
| 71 |
typedef struct fd_entry_ { |
| 72 |
int fd_objnum; /* object number of the font descriptor object */ |
| 73 |
char *fontname; /* /FontName (without subset tag) */ |
| 74 |
char *subset_tag; /* 6-character subset tag */ |
| 75 |
boolean ff_found; |
| 76 |
int ff_objnum; /* object number of the font program stream */ |
| 77 |
boolean all_glyphs; /* embed all glyphs? */ |
| 78 |
boolean write_ttf_glyph_names; |
| 79 |
intparm font_dim[FONT_KEYS_NUM]; |
| 80 |
fe_entry *fe; /* pointer to encoding structure */ |
| 81 |
char **builtin_glyph_names; /* builtin encoding as read from the Type1 font file */ |
| 82 |
fm_entry *fm; /* pointer to font map structure */ |
| 83 |
struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ |
| 84 |
struct avl_table *gl_tree; /* tree of all marked glyphs */ |
| 85 |
internal_font_number tex_font; /* needed for variable */ |
| 86 |
} fd_entry; |
| 87 |
|
| 88 |
typedef struct fo_entry_ { |
| 89 |
int fo_objnum; /* object number of the font dictionary */ |
| 90 |
internal_font_number tex_font; /* needed only for \pdffontattr{} */ |
| 91 |
fm_entry *fm; /* pointer to font map structure for this font dictionary */ |
| 92 |
fd_entry *fd; /* pointer to /FontDescriptor object structure */ |
| 93 |
fe_entry *fe; /* pointer to encoding structure */ |
| 94 |
int cw_objnum; /* object number of the font program object */ |
| 95 |
int first_char; /* first character used in this font */ |
| 96 |
int last_char; /* last character used in this font */ |
| 97 |
struct avl_table *tx_tree; /* tree of non-reencoded TeX characters marked as used */ |
| 98 |
int tounicode_objnum; /* object number of ToUnicode */ |
| 99 |
} fo_entry; |
| 100 |
|
| 101 |
typedef struct { |
| 102 |
char *name; /* glyph name */ |
| 103 |
long code; /* -1 = undefined; -2 = multiple codes, stored as string in unicode_seq; otherwise unicode value */ |
| 104 |
char *unicode_seq; /* multiple unicode sequence */ |
| 105 |
} glyph_unicode_entry; |
| 106 |
|
| 107 |
typedef struct glw_entry_ { /* subset glyphs for inclusion in CID-based fonts */ |
| 108 |
unsigned int id; /* glyph CID */ |
| 109 |
signed int wd; /* glyph width in 1/1000 em parts */ |
| 110 |
} glw_entry; |
| 111 |
|
| 112 |
typedef struct { |
| 113 |
int charcode, cwidth, cheight, xoff, yoff, xescape, rastersize; |
| 114 |
halfword *raster; |
| 115 |
} chardesc; |
| 116 |
|
| 117 |
#include "texfont.h" |
| 118 |
|
| 119 |
/* tounicode.c */ |
| 120 |
|
| 121 |
int write_cid_tounicode(PDF, fo_entry *, internal_font_number); |
| 122 |
int write_tounicode(PDF, char **, char *, internal_font_number); |
| 123 |
int write_raw_tounicode(PDF, internal_font_number, char *); |
| 124 |
void def_tounicode(str_number, str_number); |
| 125 |
void glyph_unicode_free(void); |
| 126 |
|
| 127 |
/* vfpacket.c */ |
| 128 |
|
| 129 |
void replace_packet_fonts(internal_font_number f, int *old_fontid, int *new_fontid, int count); |
| 130 |
int *packet_local_fonts(internal_font_number f, int *num); |
| 131 |
|
| 132 |
extern int packet_cur_s; /* current |do_vf_packet()| recursion level */ |
| 133 |
extern int packet_stack_ptr; /* pointer into |packet_stack| */ |
| 134 |
vf_struct *new_vfstruct(void); |
| 135 |
|
| 136 |
/* writecff.c */ |
| 137 |
|
| 138 |
void writetype1w(PDF pdf, fd_entry * fd); |
| 139 |
|
| 140 |
/* writetype0.c */ |
| 141 |
|
| 142 |
void writetype0(PDF pdf, fd_entry * fd); |
| 143 |
|
| 144 |
/* writefont.c */ |
| 145 |
|
| 146 |
void do_pdf_font(PDF, internal_font_number); |
| 147 |
int do_pdf_preroll_font(PDF, internal_font_number); |
| 148 |
fd_entry *lookup_fd_entry(char *); |
| 149 |
fd_entry *new_fd_entry(internal_font_number); |
| 150 |
void write_fontstuff(PDF); |
| 151 |
void register_fd_entry(fd_entry * fd); |
| 152 |
|
| 153 |
/* writet1.c */ |
| 154 |
|
| 155 |
boolean t1_subset(char *, char *, unsigned char *); |
| 156 |
char **load_enc_file(char *); |
| 157 |
void writet1(PDF, fd_entry *, int wide); |
| 158 |
void t1_free(void); |
| 159 |
extern int t1_length1, t1_length2, t1_length3; |
| 160 |
|
| 161 |
extern int t1_wide_mode; |
| 162 |
|
| 163 |
/* writetype2.c */ |
| 164 |
|
| 165 |
boolean writetype2(PDF, fd_entry *); |
| 166 |
extern unsigned long cidtogid_obj; |
| 167 |
unsigned long ttc_read_offset(sfnt * sfont, int ttc_idx, fd_entry *fd); |
| 168 |
|
| 169 |
/* writeenc.c */ |
| 170 |
|
| 171 |
fe_entry *get_fe_entry(char *); |
| 172 |
void enc_free(void); |
| 173 |
void write_fontencodings(PDF pdf); |
| 174 |
|
| 175 |
/* writettf.c */ |
| 176 |
|
| 177 |
void writettf(PDF, fd_entry *); |
| 178 |
void writeotf(PDF, fd_entry *); |
| 179 |
void ttf_free(void); |
| 180 |
extern int ttf_length; |
| 181 |
|
| 182 |
/* pkin.c */ |
| 183 |
|
| 184 |
int readchar(boolean, chardesc *); |
| 185 |
|
| 186 |
/* macnames.c */ |
| 187 |
|
| 188 |
extern char notdef[]; |
| 189 |
|
| 190 |
/* vfovf.c */ |
| 191 |
|
| 192 |
internal_font_number letter_space_font(internal_font_number f, int e, boolean nolig); |
| 193 |
void pdf_check_vf(internal_font_number f); |
| 194 |
internal_font_number copy_font_info(internal_font_number f); |
| 195 |
|
| 196 |
/* writet3.c */ |
| 197 |
|
| 198 |
extern FILE *t3_file; |
| 199 |
|
| 200 |
void writet3pk(PDF, internal_font_number); |
| 201 |
void prerollt3user(PDF, internal_font_number); |
| 202 |
void writet3user(PDF, internal_font_number); |
| 203 |
|
| 204 |
extern unsigned char *t3_buffer; |
| 205 |
extern int t3_size; |
| 206 |
extern int t3_curbyte; |
| 207 |
|
| 208 |
#define t3_read_file() readbinfile(t3_file, &t3_buffer, &t3_size) |
| 209 |
#define t3_close() xfclose(t3_file, cur_file_name) |
| 210 |
#define t3_getchar() t3_buffer[t3_curbyte++] |
| 211 |
#define t3_eof() (t3_curbyte>t3_size) |
| 212 |
#define t3_prefix(s) (!strncmp(t3_line_array, s, strlen(s))) |
| 213 |
#define t3_putchar(c) pdfout(c) |
| 214 |
|
| 215 |
#endif |