beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / font / mapfile.h
blob8ad05c77bb1491ea45d9db068b29656873eb744e
1 /* mapfile.h
3 Copyright 2009 Taco Hoekwater <taco@luatex.org>
5 This file is part of LuaTeX.
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.
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.
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/>. */
21 #ifndef MAPFILE_H
22 # define MAPFILE_H
24 # define F_INCLUDED (1 << 0)
25 # define F_SUBSETTED (1 << 1)
26 # define F_STDT1FONT (1 << 2)
27 # define F_SUBFONT (1 << 3)
28 # define F_TYPE1 (1 << 4)
29 # define F_TRUETYPE (1 << 5)
30 # define F_OTF (1 << 6)
31 # define F_CIDKEYED (1 << 7)
32 # define F_SLANTSET (1 << 8)
33 # define F_EXTENDSET (1 << 9)
34 # define F_INUSE (1 << 10)
36 typedef enum { MAPFILE, MAPLINE } maptype;
38 # define set_included(fm) ((fm)->type = (unsigned short)((fm)->type | F_INCLUDED))
39 # define set_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBSETTED))
40 # define set_std_t1font(fm) ((fm)->type = (unsigned short)((fm)->type | F_STDT1FONT))
41 # define set_subfont(fm) ((fm)->type = (unsigned short)((fm)->type | F_SUBFONT))
42 # define set_type1(fm) ((fm)->type = (unsigned short)((fm)->type | F_TYPE1))
43 # define set_truetype(fm) ((fm)->type = (unsigned short)((fm)->type | F_TRUETYPE))
44 # define set_opentype(fm) ((fm)->type = (unsigned short)((fm)->type | F_OTF))
45 # define set_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type | F_CIDKEYED))
46 # define set_slantset(fm) ((fm)->type = (unsigned short)((fm)->type | F_SLANTSET))
47 # define set_extendset(fm) ((fm)->type = (unsigned short)((fm)->type | F_EXTENDSET))
48 # define set_inuse(fm) ((fm)->type = (unsigned short)((fm)->type | F_INUSE))
50 # define unset_included(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INCLUDED))
51 # define unset_subsetted(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBSETTED))
52 # define unset_std_t1font(fm)((fm)->type = (unsigned short)((fm)->type & ~F_STDT1FONT))
53 # define unset_subfont(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SUBFONT))
54 # define unset_type1(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TYPE1))
55 # define unset_truetype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_TRUETYPE))
56 # define unset_opentype(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_OTF))
57 # define unset_cidkeyed(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_CIDKEYED))
58 # define unset_slantset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_SLANTSET))
59 # define unset_extendset(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_EXTENDSET))
60 # define unset_inuse(fm) ((fm)->type = (unsigned short)((fm)->type & ~F_INUSE))
62 # define is_included(fm) (((fm)->type & F_INCLUDED) != 0)
63 # define is_subsetted(fm) (((fm)->type & F_SUBSETTED) != 0)
64 # define is_std_t1font(fm) (((fm)->type & F_STDT1FONT) != 0)
65 # define is_subfont(fm) (((fm)->type & F_SUBFONT) != 0)
66 # define is_type1(fm) (((fm)->type & F_TYPE1) != 0)
67 # define is_truetype(fm) (((fm)->type & F_TRUETYPE) != 0)
68 # define is_opentype(fm) (((fm)->type & F_OTF) != 0)
69 # define is_cidkeyed(fm) (((fm)->type & F_CIDKEYED) != 0)
70 # define is_slantset(fm) (((fm)->type & F_SLANTSET) != 0)
71 # define is_extendset(fm) (((fm)->type & F_EXTENDSET) != 0)
72 # define is_inuse(fm) (((fm)->type & F_INUSE) != 0)
74 # define fm_slant(fm) (fm)->slant
75 # define fm_extend(fm) (fm)->extend
76 # define fm_fontfile(fm) (fm)->ff_name
78 # define is_reencoded(fm) ((fm)->encname != NULL)
79 # define is_fontfile(fm) (fm_fontfile(fm) != NULL)
80 # define is_t1fontfile(fm) (is_fontfile(fm) && is_type1(fm))
81 # define is_builtin(fm) (!is_fontfile(fm))
83 /**********************************************************************/
85 typedef struct {
86 /* parameters scanned from the map file: */
87 char *tfm_name; /* TFM file name (1st field in map line) */
88 char *sfd_name; /* subfont directory name, like @sfd_name@ */
89 char *ps_name; /* PostScript name (optional 2nd field in map line) */
90 int fd_flags; /* font descriptor /Flags (PDF Ref. section 5.7.1) */
91 int slant; /* SlantFont */
92 int extend; /* ExtendFont */
93 char *encname; /* encoding file name */
94 char *ff_name; /* font file name */
95 unsigned short type; /* various flags */
96 short pid; /* Pid for truetype fonts */
97 short eid; /* Eid for truetype fonts */
98 /* parameters NOT scanned from the map file: */
99 subfont_entry *subfont; /* subfont mapping */
100 } fm_entry;
102 typedef struct {
103 char *ff_name; /* base name of font file */
104 char *ff_path; /* full path to font file */
105 } ff_entry;
107 /**********************************************************************/
109 # define FONT_SLANT_MIN -2000
110 # define FONT_SLANT_MAX 2000
111 # define FONT_EXTEND_MIN -5000
112 # define FONT_EXTEND_MAX 5000
114 /**********************************************************************/
116 fm_entry *getfontmap(char *tfm_name);
117 void fm_free(void);
118 ff_entry *check_ff_exist(char *, boolean);
119 void pdfmapfile(int);
120 void pdfmapline(int);
121 void pdf_init_map_file(char *map_name);
122 fm_entry *new_fm_entry(void);
123 void delete_fm_entry(fm_entry *);
124 int avl_do_entry(fm_entry *, int);
125 int check_std_t1font(char *s);
126 int is_subsetable(fm_entry * fm);
127 void process_map_item(char *s, int type);
129 #endif /* MAPFILE_H */