| 1 |
/* texfont.h Main font API implementation for the pascal parts |
| 2 |
|
| 3 |
Copyright 2006-2010 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 |
/* Here we have the interface to LuaTeX's font system, as seen from the |
| 22 |
main pascal program. There is a companion list in luatex.defines to |
| 23 |
keep web2c happy */ |
| 24 |
|
| 25 |
/* |
| 26 |
This file is read at the end of ptexlib.h, which is called for at |
| 27 |
the end of luatexcoerce.h, as well as from the C sources. |
| 28 |
*/ |
| 29 |
|
| 30 |
#ifndef TEXFONT_H |
| 31 |
# define TEXFONT_H |
| 32 |
|
| 33 |
# define pointer halfword |
| 34 |
|
| 35 |
# define FONT_SLANT_MIN -2000 |
| 36 |
# define FONT_SLANT_MAX 2000 |
| 37 |
# define FONT_EXTEND_MIN -5000 |
| 38 |
# define FONT_EXTEND_MAX 5000 |
| 39 |
# define FONT_SQUEEZE_MIN -5000 |
| 40 |
# define FONT_SQUEEZE_MAX 5000 |
| 41 |
# define FONT_MODE_MIN 0 |
| 42 |
# define FONT_MODE_MAX 3 /* pdf values */ |
| 43 |
# define FONT_WIDTH_MIN 0 |
| 44 |
# define FONT_WIDTH_MAX 5000 |
| 45 |
|
| 46 |
/* these are dumped en block, so they need endianness tests */ |
| 47 |
|
| 48 |
typedef struct liginfo { |
| 49 |
# ifdef WORDS_BIGENDIAN |
| 50 |
int adj; |
| 51 |
int lig; |
| 52 |
int type; |
| 53 |
# else |
| 54 |
int type; |
| 55 |
int lig; |
| 56 |
int adj; |
| 57 |
# endif |
| 58 |
} liginfo; |
| 59 |
|
| 60 |
/* these are dumped en block, so they need endianness tests */ |
| 61 |
|
| 62 |
typedef struct kerninfo { |
| 63 |
# ifdef WORDS_BIGENDIAN |
| 64 |
int adj; |
| 65 |
scaled sc; |
| 66 |
# else |
| 67 |
scaled sc; |
| 68 |
int adj; |
| 69 |
# endif |
| 70 |
} kerninfo; |
| 71 |
|
| 72 |
typedef struct extinfo { |
| 73 |
struct extinfo *next; |
| 74 |
int glyph; |
| 75 |
int start_overlap; |
| 76 |
int end_overlap; |
| 77 |
int advance; |
| 78 |
int extender; |
| 79 |
} extinfo; |
| 80 |
|
| 81 |
/* todo: maybe create a 'math info structure' */ |
| 82 |
|
| 83 |
typedef struct charinfo { |
| 84 |
char *name; /* postscript character name */ |
| 85 |
liginfo *ligatures; /* ligature items */ |
| 86 |
kerninfo *kerns; /* kern items */ |
| 87 |
eight_bits *packets; /* virtual commands. */ |
| 88 |
unsigned short index; /* CID index */ |
| 89 |
int remainder; /* spare value for odd items, could be union-ed with extensible */ |
| 90 |
scaled width; /* width */ |
| 91 |
scaled height; /* height */ |
| 92 |
scaled depth; /* depth */ |
| 93 |
scaled italic; /* italic correction */ |
| 94 |
scaled vert_italic; /* italic correction */ |
| 95 |
scaled top_accent; /* top accent alignment */ |
| 96 |
scaled bot_accent; /* bot accent alignment */ |
| 97 |
int ef; /* font expansion factor */ |
| 98 |
int lp; /* left protruding factor */ |
| 99 |
int rp; /* right protruding factor */ |
| 100 |
char tag; /* list / ext taginfo */ |
| 101 |
char used; /* char is typeset ? */ |
| 102 |
char *tounicode; /* unicode equivalent */ |
| 103 |
extinfo *hor_variants; /* horizontal variants */ |
| 104 |
extinfo *vert_variants; /* vertical variants */ |
| 105 |
int top_left_math_kerns; |
| 106 |
int top_right_math_kerns; |
| 107 |
int bottom_right_math_kerns; |
| 108 |
int bottom_left_math_kerns; |
| 109 |
scaled *top_left_math_kern_array; |
| 110 |
scaled *top_right_math_kern_array; |
| 111 |
scaled *bottom_right_math_kern_array; |
| 112 |
scaled *bottom_left_math_kern_array; |
| 113 |
} charinfo; |
| 114 |
|
| 115 |
# define EXT_NORMAL 0 |
| 116 |
# define EXT_REPEAT 1 |
| 117 |
|
| 118 |
extern extinfo *get_charinfo_vert_variants(charinfo * ci); |
| 119 |
extern extinfo *get_charinfo_hor_variants(charinfo * ci); |
| 120 |
extern void set_charinfo_hor_variants(charinfo * ci, extinfo * ext); |
| 121 |
extern void set_charinfo_vert_variants(charinfo * ci, extinfo * ext); |
| 122 |
extern void add_charinfo_vert_variant(charinfo * ci, extinfo * ext); |
| 123 |
extern void add_charinfo_hor_variant(charinfo * ci, extinfo * ext); |
| 124 |
|
| 125 |
extern extinfo *copy_variants(extinfo * o); |
| 126 |
|
| 127 |
extern extinfo *new_variant(int glyph, int startconnect, int endconnect, int advance, int repeater); |
| 128 |
|
| 129 |
extern scaled_whd get_charinfo_whd(internal_font_number f, int c); |
| 130 |
|
| 131 |
typedef struct texfont { |
| 132 |
int _font_size; |
| 133 |
int _font_dsize; |
| 134 |
int _font_units_per_em; |
| 135 |
char *_font_name; |
| 136 |
char *_font_area; |
| 137 |
char *_font_filename; |
| 138 |
char *_font_fullname; |
| 139 |
char *_font_psname; |
| 140 |
char *_font_encodingname; |
| 141 |
char *_font_cidregistry; |
| 142 |
char *_font_cidordering; |
| 143 |
int _font_cidversion; |
| 144 |
int _font_cidsupplement; |
| 145 |
int _font_ec; |
| 146 |
unsigned _font_checksum; /* internal information */ |
| 147 |
char _font_used; /* internal information */ |
| 148 |
char _font_touched; /* internal information */ |
| 149 |
int _font_cache_id; /* internal information */ |
| 150 |
char _font_encodingbytes; /* 1 or 2 bytes */ |
| 151 |
int _font_subfont; |
| 152 |
boolean _font_oldmath; /* default to false when MathConstants seen */ |
| 153 |
int _font_slant; /* a slant in ppt */ |
| 154 |
int _font_extend; /* an extension in ppt, or 1000 */ |
| 155 |
int _font_squeeze; /* an extension in ppt, or 1000 */ |
| 156 |
int _font_width; |
| 157 |
int _font_mode; |
| 158 |
int _font_max_shrink; |
| 159 |
int _font_max_stretch; |
| 160 |
int _font_step; /* amount of one step of expansion */ |
| 161 |
char _font_tounicode; /* 1 if info is present */ |
| 162 |
fm_entry *_font_map; |
| 163 |
int _font_type; |
| 164 |
int _font_format; |
| 165 |
int _font_writingmode; |
| 166 |
int _font_identity; |
| 167 |
int _font_embedding; |
| 168 |
int _font_streamprovider; |
| 169 |
int _font_bc; |
| 170 |
int _hyphen_char; |
| 171 |
int _skew_char; |
| 172 |
int _font_natural_dir; |
| 173 |
charinfo *_left_boundary; |
| 174 |
charinfo *_right_boundary; |
| 175 |
int _font_params; |
| 176 |
scaled *_param_base; |
| 177 |
int _font_math_params; |
| 178 |
scaled *_math_param_base; |
| 179 |
sa_tree _characters; |
| 180 |
int _charinfo_count; |
| 181 |
int _charinfo_size; |
| 182 |
charinfo *_charinfo; |
| 183 |
int _ligatures_disabled; |
| 184 |
int _pdf_font_num; /* maps to a PDF resource ID */ |
| 185 |
str_number _pdf_font_attr; /* pointer to additional attributes */ |
| 186 |
} texfont; |
| 187 |
|
| 188 |
typedef enum { |
| 189 |
unknown_font_type = 0, /* new font (has not been used yet) */ |
| 190 |
virtual_font_type, /* virtual font */ |
| 191 |
real_font_type, /* real font */ |
| 192 |
} font_types; |
| 193 |
|
| 194 |
typedef enum { |
| 195 |
unknown_format = 0, |
| 196 |
type1_format, |
| 197 |
type3_format, |
| 198 |
truetype_format, |
| 199 |
opentype_format, |
| 200 |
} font_formats; |
| 201 |
|
| 202 |
typedef enum { |
| 203 |
unknown_writingmode = 0, |
| 204 |
horizontal_writingmode, |
| 205 |
vertical_writingmode, |
| 206 |
} writingmode_types; |
| 207 |
|
| 208 |
typedef enum { |
| 209 |
unknown_identity = 0, |
| 210 |
horizontal_identity, |
| 211 |
vertical_identity, |
| 212 |
} identity_types; |
| 213 |
|
| 214 |
typedef enum { |
| 215 |
unknown_embedding = 0, |
| 216 |
no_embedding, |
| 217 |
subset_embedding, |
| 218 |
full_embedding, |
| 219 |
} font_embedding_option; |
| 220 |
|
| 221 |
extern const char *font_type_strings[]; |
| 222 |
extern const char *font_format_strings[]; |
| 223 |
extern const char *font_writingmodes_strings[]; |
| 224 |
extern const char *font_identity_strings[]; |
| 225 |
extern const char *font_embedding_strings[]; |
| 226 |
|
| 227 |
# define font_checksum(a) font_tables[a]->_font_checksum |
| 228 |
# define set_font_checksum(a,b) font_checksum(a) = b |
| 229 |
|
| 230 |
# define font_check_0(a) ((font_tables[a]->_font_checksum&0xFF000000)>>24) |
| 231 |
# define font_check_1(a) ((font_tables[a]->_font_checksum&0x00FF0000)>>16) |
| 232 |
# define font_check_2(a) ((font_tables[a]->_font_checksum&0x0000FF00)>>8) |
| 233 |
# define font_check_3(a) (font_tables[a]->_font_checksum&0x000000FF) |
| 234 |
|
| 235 |
# define font_size(a) font_tables[a]->_font_size |
| 236 |
# define set_font_size(a,b) font_size(a) = b |
| 237 |
# define font_dsize(a) font_tables[a]->_font_dsize |
| 238 |
# define set_font_dsize(a,b) font_dsize(a) = b |
| 239 |
|
| 240 |
# define font_units_per_em(a) font_tables[a]->_font_units_per_em |
| 241 |
# define set_font_units_per_em(a,b) font_units_per_em(a) = b |
| 242 |
|
| 243 |
# define font_name(a) font_tables[a]->_font_name |
| 244 |
# define get_font_name(a) (unsigned char *)font_name(a) |
| 245 |
# define set_font_name(f,b) font_name(f) = b |
| 246 |
# define tex_font_name(a) maketexstring(font_name(a)) |
| 247 |
|
| 248 |
# define font_area(a) font_tables[a]->_font_area |
| 249 |
# define get_font_area(a) (unsigned char *)font_area(a) |
| 250 |
# define set_font_area(f,b) font_area(f) = b |
| 251 |
# define tex_font_area(a) maketexstring(font_area(a)) |
| 252 |
|
| 253 |
boolean cmp_font_area(int, str_number); |
| 254 |
|
| 255 |
# define font_reassign(a,b) { if (a!=NULL) free(a); a = b; } |
| 256 |
|
| 257 |
# define font_filename(a) font_tables[a]->_font_filename |
| 258 |
# define set_font_filename(f,b) font_reassign(font_filename(f),b) |
| 259 |
|
| 260 |
# define font_fullname(a) font_tables[a]->_font_fullname |
| 261 |
# define set_font_fullname(f,b) font_reassign(font_fullname(f),b) |
| 262 |
|
| 263 |
# define font_psname(a) font_tables[a]->_font_psname |
| 264 |
# define set_font_psname(f,b) font_reassign(font_psname(f),b) |
| 265 |
|
| 266 |
# define font_encodingname(a) font_tables[a]->_font_encodingname |
| 267 |
# define set_font_encodingname(f,b) font_reassign(font_encodingname(f),b) |
| 268 |
|
| 269 |
# define cmp_font_filename(a,b) (!(font_filename(a)!=NULL || font_filename(b)!=NULL || \ |
| 270 |
strcmp(font_filename(a),font_filename(b)))) |
| 271 |
# define cmp_font_fullname(a,b) (!(font_fullname(a)!=NULL || font_fullname(b)!=NULL || \ |
| 272 |
strcmp(font_fullname(a),font_fullname(b)))) |
| 273 |
# define cmp_font_encodingname(a,b) (!(font_encoding(a)!=NULL || font_encodingname(b)!=NULL || \ |
| 274 |
strcmp(font_encodingname(a),font_encodingname(b)))) |
| 275 |
# define font_bc(a) font_tables[a]->_font_bc |
| 276 |
# define set_font_bc(f,b) font_bc(f) = b |
| 277 |
|
| 278 |
# define font_ec(a) font_tables[a]->_font_ec |
| 279 |
# define set_font_ec(f,b) font_ec(f) = b |
| 280 |
|
| 281 |
# define font_used(a) (font_tables[a]!=NULL && font_tables[a]->_font_used) |
| 282 |
# define set_font_used(a,b) font_tables[a]->_font_used = b |
| 283 |
|
| 284 |
# define font_touched(a) font_tables[a]->_font_touched |
| 285 |
# define set_font_touched(a,b) font_touched(a) = b |
| 286 |
|
| 287 |
# define font_type(a) font_tables[a]->_font_type |
| 288 |
# define set_font_type(a,b) font_type(a) = b; |
| 289 |
|
| 290 |
# define font_format(a) font_tables[a]->_font_format |
| 291 |
# define font_format_name(a) font_format_strings[font_tables[a]->_font_format] |
| 292 |
# define set_font_format(a,b) font_format(a) = b |
| 293 |
|
| 294 |
# define font_writingmode(a) font_tables[a]->_font_writingmode |
| 295 |
# define font_writingmode_name(a) font_writingmode_strings[font_tables[a]->_font_writingmode] |
| 296 |
# define set_font_writingmode(a,b) font_writingmode(a) = b |
| 297 |
|
| 298 |
# define font_identity(a) font_tables[a]->_font_identity |
| 299 |
# define font_identity_name(a) font_identity_strings[font_tables[a]->_font_identity] |
| 300 |
# define set_font_identity(a,b) font_identity(a) = b |
| 301 |
|
| 302 |
# define font_embedding(a) font_tables[a]->_font_embedding |
| 303 |
# define set_font_embedding(a,b) font_embedding(a) = b |
| 304 |
|
| 305 |
# define font_cidversion(a) font_tables[a]->_font_cidversion |
| 306 |
# define set_font_cidversion(a,b) font_cidversion(a) = b |
| 307 |
|
| 308 |
# define font_cidsupplement(a) font_tables[a]->_font_cidsupplement |
| 309 |
# define set_font_cidsupplement(a,b) font_cidsupplement(a) = b |
| 310 |
|
| 311 |
# define font_cidordering(a) font_tables[a]->_font_cidordering |
| 312 |
# define set_font_cidordering(f,b) font_reassign(font_cidordering(f),b) |
| 313 |
|
| 314 |
# define font_cidregistry(a) font_tables[a]->_font_cidregistry |
| 315 |
# define set_font_cidregistry(f,b) font_reassign(font_cidregistry(f),b) |
| 316 |
|
| 317 |
# define font_map(a) font_tables[a]->_font_map |
| 318 |
# define set_font_map(a,b) font_map(a) = b |
| 319 |
|
| 320 |
# define font_cache_id(a) font_tables[a]->_font_cache_id |
| 321 |
# define set_font_cache_id(a,b) font_cache_id(a) = b |
| 322 |
|
| 323 |
# define font_encodingbytes(a) font_tables[a]->_font_encodingbytes |
| 324 |
# define set_font_encodingbytes(a,b) font_encodingbytes(a) = b |
| 325 |
|
| 326 |
# define font_subfont(a) font_tables[a]->_font_subfont |
| 327 |
# define set_font_subfont(a,b) font_subfont(a) = b |
| 328 |
|
| 329 |
# define font_streamprovider(a) font_tables[a]->_font_streamprovider |
| 330 |
# define set_font_streamprovider(a,b) font_streamprovider(a) = b |
| 331 |
|
| 332 |
# define font_oldmath(a) font_tables[a]->_font_oldmath |
| 333 |
# define set_font_oldmath(a,b) font_oldmath(a) = b |
| 334 |
|
| 335 |
# define font_slant(a) font_tables[a]->_font_slant |
| 336 |
# define set_font_slant(a,b) font_slant(a) = b |
| 337 |
|
| 338 |
# define font_extend(a) font_tables[a]->_font_extend |
| 339 |
# define set_font_extend(a,b) font_extend(a) = b |
| 340 |
|
| 341 |
# define font_squeeze(a) font_tables[a]->_font_squeeze |
| 342 |
# define set_font_squeeze(a,b) font_squeeze(a) = b |
| 343 |
|
| 344 |
# define font_width(a) font_tables[a]->_font_width |
| 345 |
# define set_font_width(a,b) font_width(a) = b |
| 346 |
|
| 347 |
# define font_mode(a) font_tables[a]->_font_mode |
| 348 |
# define set_font_mode(a,b) font_mode(a) = b |
| 349 |
|
| 350 |
# define font_shrink(a) font_tables[a]->_font_shrink |
| 351 |
# define set_font_shrink(a,b) font_shrink(a) = b |
| 352 |
|
| 353 |
# define font_stretch(a) font_tables[a]->_font_stretch |
| 354 |
# define set_font_stretch(a,b) font_stretch(a) = b |
| 355 |
|
| 356 |
# define font_max_shrink(a) font_tables[a]->_font_max_shrink |
| 357 |
# define set_font_max_shrink(a,b) font_max_shrink(a) = b |
| 358 |
|
| 359 |
# define font_max_stretch(a) font_tables[a]->_font_max_stretch |
| 360 |
# define set_font_max_stretch(a,b) font_max_stretch(a) = b |
| 361 |
|
| 362 |
# define font_step(a) font_tables[a]->_font_step |
| 363 |
# define set_font_step(a,b) font_step(a) = b |
| 364 |
|
| 365 |
# define font_tounicode(a) font_tables[a]->_font_tounicode |
| 366 |
# define set_font_tounicode(a,b) font_tounicode(a) = b |
| 367 |
|
| 368 |
# define hyphen_char(a) font_tables[a]->_hyphen_char |
| 369 |
# define set_hyphen_char(a,b) hyphen_char(a) = b |
| 370 |
|
| 371 |
# define skew_char(a) font_tables[a]->_skew_char |
| 372 |
# define set_skew_char(a,b) skew_char(a) = b |
| 373 |
|
| 374 |
# define font_natural_dir(a) font_tables[a]->_font_natural_dir |
| 375 |
# define set_font_natural_dir(a,b) font_natural_dir(a) = b |
| 376 |
|
| 377 |
# define pdf_font_num(a) font_tables[a]->_pdf_font_num |
| 378 |
# define set_pdf_font_num(a,b) pdf_font_num(a) = b |
| 379 |
|
| 380 |
# define pdf_font_attr(a) font_tables[a]->_pdf_font_attr |
| 381 |
# define set_pdf_font_attr(a,b) pdf_font_attr(a) = b |
| 382 |
|
| 383 |
# define charinfo_size(a) font_tables[a]->_charinfo_size |
| 384 |
|
| 385 |
# define left_boundarychar -1 |
| 386 |
# define right_boundarychar -2 |
| 387 |
# define non_boundarychar -3 |
| 388 |
|
| 389 |
# define left_boundary(a) font_tables[a]->_left_boundary |
| 390 |
# define has_left_boundary(a) (left_boundary(a)!=NULL) |
| 391 |
# define set_left_boundary(a,b) font_reassign(left_boundary(a),b) |
| 392 |
|
| 393 |
# define right_boundary(a) font_tables[a]->_right_boundary |
| 394 |
# define has_right_boundary(a) (right_boundary(a)!=NULL) |
| 395 |
# define set_right_boundary(a,b) font_reassign(right_boundary(a),b) |
| 396 |
|
| 397 |
# define font_bchar(a) (right_boundary(a)!=NULL ? right_boundarychar : non_boundarychar) |
| 398 |
|
| 399 |
/* font parameters */ |
| 400 |
|
| 401 |
# define font_params(a) font_tables[a]->_font_params |
| 402 |
# define param_base(a) font_tables[a]->_param_base |
| 403 |
# define font_param(a,b) font_tables[a]->_param_base[b] |
| 404 |
|
| 405 |
extern void set_font_params(internal_font_number f, int b); |
| 406 |
|
| 407 |
# define set_font_param(f,n,b) { \ |
| 408 |
if (font_params(f)<n) \ |
| 409 |
set_font_params(f,n); \ |
| 410 |
font_param(f,n) = b; \ |
| 411 |
} |
| 412 |
# define font_math_params(a) font_tables[a]->_font_math_params |
| 413 |
# define math_param_base(a) font_tables[a]->_math_param_base |
| 414 |
# define font_math_param(a,b) font_tables[a]->_math_param_base[b] |
| 415 |
|
| 416 |
extern void set_font_math_params(internal_font_number f, int b); |
| 417 |
|
| 418 |
# define set_font_math_param(f,n,b) { \ |
| 419 |
if (font_math_params(f)<n) \ |
| 420 |
set_font_math_params(f,n); \ |
| 421 |
font_math_param(f,n) = b; \ |
| 422 |
} |
| 423 |
|
| 424 |
/* Font parameters are sometimes referred to as |slant(f)|, |space(f)|, etc.*/ |
| 425 |
|
| 426 |
typedef enum { |
| 427 |
slant_code = 1, |
| 428 |
space_code = 2, |
| 429 |
space_stretch_code = 3, |
| 430 |
space_shrink_code = 4, |
| 431 |
x_height_code = 5, |
| 432 |
quad_code = 6, |
| 433 |
extra_space_code = 7 |
| 434 |
} font_parameter_codes; |
| 435 |
|
| 436 |
# define slant(f) font_param(f,slant_code) |
| 437 |
# define space(f) font_param(f,space_code) |
| 438 |
# define space_stretch(f) font_param(f,space_stretch_code) |
| 439 |
# define space_shrink(f) font_param(f,space_shrink_code) |
| 440 |
# define x_height(f) font_param(f,x_height_code) |
| 441 |
# ifdef quad |
| 442 |
# undef quad |
| 443 |
# endif |
| 444 |
# define quad(f) font_param(f,quad_code) |
| 445 |
# define extra_space(f) font_param(f,extra_space_code) |
| 446 |
|
| 447 |
/* now for characters */ |
| 448 |
|
| 449 |
typedef enum { |
| 450 |
top_right_kern = 1, |
| 451 |
bottom_right_kern = 2, |
| 452 |
bottom_left_kern = 3, |
| 453 |
top_left_kern = 4 |
| 454 |
} font_math_kern_codes; |
| 455 |
|
| 456 |
extern charinfo *get_charinfo(internal_font_number f, int c); |
| 457 |
extern int char_exists(internal_font_number f, int c); |
| 458 |
extern int lua_glyph_not_found_callback(internal_font_number f, int c); |
| 459 |
extern charinfo *char_info(internal_font_number f, int c); |
| 460 |
|
| 461 |
/* |
| 462 |
Here is a quick way to test if a glyph exists, when you are |
| 463 |
already certain the font |f| exists, and that the |c| is a regular |
| 464 |
glyph id, not one of the two special boundary objects. |
| 465 |
*/ |
| 466 |
|
| 467 |
# define quick_char_exists(f,c) (get_sa_item(font_tables[f]->_characters,c).int_value) |
| 468 |
|
| 469 |
extern void set_charinfo_width(charinfo * ci, scaled val); |
| 470 |
extern void set_charinfo_height(charinfo * ci, scaled val); |
| 471 |
extern void set_charinfo_depth(charinfo * ci, scaled val); |
| 472 |
extern void set_charinfo_italic(charinfo * ci, scaled val); |
| 473 |
extern void set_charinfo_vert_italic(charinfo * ci, scaled val); |
| 474 |
extern void set_charinfo_top_accent(charinfo * ci, scaled val); |
| 475 |
extern void set_charinfo_bot_accent(charinfo * ci, scaled val); |
| 476 |
extern void set_charinfo_tag(charinfo * ci, scaled val); |
| 477 |
extern void set_charinfo_remainder(charinfo * ci, scaled val); |
| 478 |
extern void set_charinfo_used(charinfo * ci, scaled val); |
| 479 |
extern void set_charinfo_index(charinfo * ci, scaled val); |
| 480 |
extern void set_charinfo_name(charinfo * ci, char *val); |
| 481 |
extern void set_charinfo_tounicode(charinfo * ci, char *val); |
| 482 |
extern void set_charinfo_ligatures(charinfo * ci, liginfo * val); |
| 483 |
extern void set_charinfo_kerns(charinfo * ci, kerninfo * val); |
| 484 |
extern void set_charinfo_packets(charinfo * ci, eight_bits * val); |
| 485 |
extern void set_charinfo_extensible(charinfo * ci, int a, int b, int c, int d); |
| 486 |
extern void set_charinfo_ef(charinfo * ci, scaled val); |
| 487 |
extern void set_charinfo_lp(charinfo * ci, scaled val); |
| 488 |
extern void set_charinfo_rp(charinfo * ci, scaled val); |
| 489 |
|
| 490 |
extern void add_charinfo_math_kern(charinfo * ci, int type, scaled ht, scaled krn); |
| 491 |
extern int get_charinfo_math_kerns(charinfo * ci, int id); |
| 492 |
|
| 493 |
# define set_char_used(f,a,b) do { \ |
| 494 |
if (char_exists(f,a)) \ |
| 495 |
set_charinfo_used(char_info(f,a),b); \ |
| 496 |
} while (0) |
| 497 |
|
| 498 |
extern scaled get_charinfo_width(charinfo * ci); |
| 499 |
extern scaled get_charinfo_height(charinfo * ci); |
| 500 |
extern scaled get_charinfo_depth(charinfo * ci); |
| 501 |
extern scaled get_charinfo_italic(charinfo * ci); |
| 502 |
extern scaled get_charinfo_vert_italic(charinfo * ci); |
| 503 |
extern scaled get_charinfo_top_accent(charinfo * ci); |
| 504 |
extern scaled get_charinfo_bot_accent(charinfo * ci); |
| 505 |
extern char get_charinfo_tag(charinfo * ci); |
| 506 |
extern int get_charinfo_remainder(charinfo * ci); |
| 507 |
extern char get_charinfo_used(charinfo * ci); |
| 508 |
extern int get_charinfo_index(charinfo * ci); |
| 509 |
extern char *get_charinfo_name(charinfo * ci); |
| 510 |
extern char *get_charinfo_tounicode(charinfo * ci); |
| 511 |
extern liginfo *get_charinfo_ligatures(charinfo * ci); |
| 512 |
extern kerninfo *get_charinfo_kerns(charinfo * ci); |
| 513 |
extern eight_bits *get_charinfo_packets(charinfo * ci); |
| 514 |
extern int get_charinfo_ef(charinfo * ci); |
| 515 |
extern int get_charinfo_rp(charinfo * ci); |
| 516 |
extern int get_charinfo_lp(charinfo * ci); |
| 517 |
extern int get_charinfo_extensible(charinfo * ci, int which); |
| 518 |
|
| 519 |
extern int ext_top(internal_font_number f, int c); |
| 520 |
extern int ext_bot(internal_font_number f, int c); |
| 521 |
extern int ext_rep(internal_font_number f, int c); |
| 522 |
extern int ext_mid(internal_font_number f, int c); |
| 523 |
|
| 524 |
# define set_ligature_item(f,b,c,d) { f.type = b; f.adj = c; f.lig = d; } |
| 525 |
# define set_kern_item(f,b,c) { f.adj = b; f.sc = c; } |
| 526 |
|
| 527 |
/* character information */ |
| 528 |
|
| 529 |
# define non_char 65536 /* a code that can't match a real character */ |
| 530 |
# define non_address 0 /* a spurious |bchar_label| */ |
| 531 |
|
| 532 |
/* character kerns and ligatures */ |
| 533 |
|
| 534 |
# define end_kern 0x7FFFFF /* otherchar value meaning "stop" */ |
| 535 |
# define ignored_kern 0x800000 /* otherchar value meaning "disabled" */ |
| 536 |
|
| 537 |
# define charinfo_kern(b,c) b->kerns[c] |
| 538 |
|
| 539 |
# define kern_char(b) (b).adj |
| 540 |
# define kern_kern(b) (b).sc |
| 541 |
# define kern_end(b) ((b).adj == end_kern) |
| 542 |
# define kern_disabled(b) ((b).adj > end_kern) |
| 543 |
|
| 544 |
/* character ligatures */ |
| 545 |
|
| 546 |
# define end_ligature 0x7FFFFF /* otherchar value meaning "stop" */ |
| 547 |
# define ignored_ligature 0x800000 /* otherchar value meaning "disabled" */ |
| 548 |
|
| 549 |
# define charinfo_ligature(b,c) b->ligatures[c] |
| 550 |
|
| 551 |
# define is_valid_ligature(a) ((a).type!=0) |
| 552 |
# define lig_type(a) ((a).type>>1) |
| 553 |
# define lig_char(a) (a).adj |
| 554 |
# define lig_replacement(a) (a).lig |
| 555 |
# define lig_end(a) (lig_char(a) == end_ligature) |
| 556 |
# define lig_disabled(a) (lig_char(a) > end_ligature) |
| 557 |
|
| 558 |
# define no_tag 0 /* vanilla character */ |
| 559 |
# define lig_tag 1 /* character has a ligature/kerning program */ |
| 560 |
# define list_tag 2 /* character has a successor in a charlist */ |
| 561 |
# define ext_tag 3 /* character is extensible */ |
| 562 |
|
| 563 |
extern scaled char_height(internal_font_number f, int c); |
| 564 |
extern scaled calc_char_width(internal_font_number f, int c, int ex); |
| 565 |
extern scaled char_width(internal_font_number f, int c); |
| 566 |
extern scaled char_depth(internal_font_number f, int c); |
| 567 |
extern scaled char_italic(internal_font_number f, int c); |
| 568 |
extern scaled char_vert_italic(internal_font_number f, int c); |
| 569 |
extern scaled char_top_accent(internal_font_number f, int c); |
| 570 |
extern scaled char_bot_accent(internal_font_number f, int c); |
| 571 |
|
| 572 |
extern liginfo *char_ligatures(internal_font_number f, int c); |
| 573 |
extern kerninfo *char_kerns(internal_font_number f, int c); |
| 574 |
extern eight_bits *char_packets(internal_font_number f, int c); |
| 575 |
|
| 576 |
# define has_lig(f,b) (char_exists(f,b) &&( char_ligatures(f,b) != NULL)) |
| 577 |
# define has_kern(f,b) (char_exists(f,b) && (char_kerns(f,b) != NULL)) |
| 578 |
# define has_packet(f,b) (char_exists(f,b) && (char_packets(f,b) != NULL)) |
| 579 |
|
| 580 |
extern int char_remainder(internal_font_number f, int c); |
| 581 |
extern char char_tag(internal_font_number f, int c); |
| 582 |
extern char char_used(internal_font_number f, int c); |
| 583 |
extern char *char_name(internal_font_number f, int c); |
| 584 |
extern int char_index(internal_font_number f, int c); |
| 585 |
|
| 586 |
scaled raw_get_kern(internal_font_number f, int lc, int rc); |
| 587 |
scaled get_kern(internal_font_number f, int lc, int rc); |
| 588 |
liginfo get_ligature(internal_font_number f, int lc, int rc); |
| 589 |
|
| 590 |
# define EXT_TOP 0 |
| 591 |
# define EXT_BOT 1 |
| 592 |
# define EXT_MID 2 |
| 593 |
# define EXT_REP 3 |
| 594 |
|
| 595 |
extern texfont **font_tables; |
| 596 |
|
| 597 |
int new_font(void); |
| 598 |
extern void font_malloc_charinfo(internal_font_number f, int num); |
| 599 |
int copy_font(int id); |
| 600 |
int scale_font(int id, int atsize); |
| 601 |
int max_font_id(void); |
| 602 |
void set_max_font_id(int id); |
| 603 |
int new_font_id(void); |
| 604 |
void create_null_font(void); |
| 605 |
void delete_font(int id); |
| 606 |
boolean is_valid_font(int id); |
| 607 |
|
| 608 |
void dump_font(int font_number); |
| 609 |
void undump_font(int font_number); |
| 610 |
|
| 611 |
int test_no_ligatures(internal_font_number f); |
| 612 |
void set_no_ligatures(internal_font_number f); |
| 613 |
|
| 614 |
extern int get_tag_code(internal_font_number f, int c); |
| 615 |
extern int get_lp_code(internal_font_number f, int c); |
| 616 |
extern int get_rp_code(internal_font_number f, int c); |
| 617 |
extern int get_ef_code(internal_font_number f, int c); |
| 618 |
|
| 619 |
extern void set_tag_code(internal_font_number f, int c, int i); |
| 620 |
extern void set_lp_code(internal_font_number f, int c, int i); |
| 621 |
extern void set_rp_code(internal_font_number f, int c, int i); |
| 622 |
extern void set_ef_code(internal_font_number f, int c, int i); |
| 623 |
|
| 624 |
int read_tfm_info(internal_font_number f, const char *nom, scaled s); |
| 625 |
|
| 626 |
/* from dofont.c */ |
| 627 |
|
| 628 |
extern int read_font_info(pointer u, char *cnom, scaled s, int ndir); |
| 629 |
extern int find_font_id(const char *nom, scaled s); |
| 630 |
|
| 631 |
/* for and from vfpacket.c */ |
| 632 |
|
| 633 |
typedef enum { packet_char_code, |
| 634 |
packet_font_code, |
| 635 |
packet_pop_code, |
| 636 |
packet_push_code, |
| 637 |
packet_special_code, |
| 638 |
packet_image_code, |
| 639 |
packet_right_code, |
| 640 |
packet_down_code, |
| 641 |
packet_rule_code, |
| 642 |
packet_node_code, |
| 643 |
packet_nop_code, |
| 644 |
packet_end_code, |
| 645 |
packet_scale_code, |
| 646 |
packet_lua_code, |
| 647 |
packet_pdf_code, |
| 648 |
packet_pdf_mode |
| 649 |
} packet_command_codes; |
| 650 |
|
| 651 |
extern scaled store_scaled_f(scaled sq, int fw); |
| 652 |
|
| 653 |
extern void do_vf_packet(PDF pdf, internal_font_number vf_f, int c, int ex); |
| 654 |
extern int vf_packet_bytes(charinfo * co); |
| 655 |
|
| 656 |
extern charinfo *copy_charinfo(charinfo * ci); |
| 657 |
|
| 658 |
/* this function is in vfovf.c for the moment */ |
| 659 |
|
| 660 |
extern int make_vf_table(lua_State * L, const char *name, scaled s); |
| 661 |
|
| 662 |
/* some bits of the old interface, used by e.g. writet3.c */ |
| 663 |
|
| 664 |
# define get_x_height(f) x_height(f) |
| 665 |
# define get_quad(f) quad(f) |
| 666 |
# define get_slant(f) slant(f) |
| 667 |
# define get_charwidth(f,c) (char_exists(f,c) ? char_width(f,c) : 0) |
| 668 |
# define get_charheight(f,c) (char_exists(f,c) ? char_height(f,c) : 0) |
| 669 |
# define get_chardepth(f,c) (char_exists(f,c) ? char_depth(f,c) : 0) |
| 670 |
|
| 671 |
extern int pk_dpi; /* PK pixel density value from \.{texmf.cnf} */ |
| 672 |
|
| 673 |
extern internal_font_number tfm_lookup(char *s, scaled fs); |
| 674 |
|
| 675 |
extern int fix_expand_value(internal_font_number f, int e); |
| 676 |
|
| 677 |
extern void set_expand_params(internal_font_number f, int stretch_limit, int shrink_limit, int font_step); |
| 678 |
|
| 679 |
extern void read_expand_font(void); |
| 680 |
extern void new_letterspaced_font(small_number a); |
| 681 |
extern void make_font_copy(small_number a); |
| 682 |
|
| 683 |
extern void glyph_to_unicode(void); |
| 684 |
|
| 685 |
#endif |