Mention that README lists additional prereqs.
[pspp-builds.git] / src / output / font.h
1 /* PSPP - computes sample statistics.
2    Copyright (C) 1997-9, 2000 Free Software Foundation, Inc.
3    Written by Ben Pfaff <blp@gnu.org>.
4
5    This program is free software; you can redistribute it and/or
6    modify it under the terms of the GNU General Public License as
7    published by the Free Software Foundation; either version 2 of the
8    License, or (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful, but
11    WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13    General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18    02110-1301, USA. */
19
20 #if !font_h
21 #define font_h 1
22
23 /* Possible ligatures. */
24 #define LIG_ff  001
25 #define LIG_ffi 002
26 #define LIG_ffl 004
27 #define LIG_fi  010
28 #define LIG_fl  020
29
30 /* Character type constants. */
31 #define CTYP_NONE       000     /* Neither ascenders nor descenders. */
32 #define CTYP_ASCENDER   001     /* Character has an ascender. */
33 #define CTYP_DESCENDER  002     /* Character has a descender. */
34
35 /* Font metrics for a single character.  */
36 struct char_metrics
37   {
38     int code;                   /* Character code. */
39     int type;                   /* CTYP_* constants. */
40     int width;                  /* Width. */
41     int height;                 /* Height above baseline, never negative. */
42     int depth;                  /* Depth below baseline, never negative. */
43
44     /* These fields are not yet used, so to save memory, they are left
45        out. */
46 #if 0
47     int italic_correction;      /* Italic correction. */
48     int left_italic_correction; /* Left italic correction. */
49     int subscript_correction;   /* Subscript correction. */
50 #endif
51   };
52
53 /* Kerning for a pair of characters.  */
54 struct kern_pair
55   {
56     int ch1;                    /* First character. */
57     int ch2;                    /* Second character. */
58     int adjust;                 /* Kern amount. */
59   };
60
61 /* Font description.  */
62 struct font_desc
63   {
64     /* Housekeeping data. */
65     struct pool *owner;         /* Containing pool. */
66     char *name;                 /* Font name.  FIXME: this field's
67                                    role is uncertain. */
68     char *filename;             /* Normalized filename. */
69
70     /* PostScript-specific courtesy data. */
71     char *internal_name;        /* Font internal name. */
72     char *encoding;             /* Name of encoding file. */
73
74     /* Basic font characteristics. */
75     int space_width;            /* Width of a space character. */
76     double slant;               /* Slant angle, in degrees of forward slant. */
77     unsigned ligatures;         /* Characters that have ligatures. */
78     int special;                /* 1=This is a special font that will be
79                                    searched when a character is not present in
80                                    another font. */
81     int ascent, descent;        /* Height above, below the baseline. */
82
83     /* First dereferencing level is font_char_name_to_index(NAME). */
84     /* Second dereferencing level. */
85     short *deref;               /* Each entry is an index into metric.
86                                    metric[deref[lookup(NAME)]] is the metric
87                                    for character with name NAME. */
88     int deref_size;             /* Number of spaces for entries in deref. */
89
90     /* Third dereferencing level. */
91     struct char_metrics **metric;       /* Metrics for font characters. */
92     int metric_size;            /* Number of spaces for entries in metric. */
93     int metric_used;            /* Number of spaces used in metric. */
94
95     /* Kern pairs. */
96     struct kern_pair *kern;     /* Hash table for kerns. */
97     int kern_size;              /* Number of spaces for kerns in kern. */
98     int *kern_size_p;           /* Next larger hash table size. */
99     int kern_used;              /* Number of used spaces in kern. */
100     int kern_max_used;          /* Max number used before rehashing. */
101   };
102
103 /* Index into deref[] of character with name "space". */
104 extern int space_index;
105
106 /* A set of fonts. */
107 struct font_set
108   {
109     struct font_set *next, *prev;       /* Next, previous in chain. */
110     struct font_desc *font;             /* Current font. */
111   };
112
113 /* Functions to work with any font. */
114 #define destroy_font(FONT)                      \
115         pool_destroy (FONT->owner)
116
117 int font_char_name_to_index (const char *);
118 struct char_metrics *font_get_char_metrics (const struct font_desc *font,
119                                             int ch);
120 int font_get_kern_adjust (const struct font_desc *font, int ch1, int ch2);
121
122 /* groff fonts. */
123 struct groff_device_info
124   {
125     /* See groff_font man page. */
126     int res, horiz, vert;
127     int size_scale, unit_width;
128     int (*sizes)[2], n_sizes;
129     char *font_name[4];         /* Names of 4 default fonts. */
130     char *family;               /* Name of default font family. */
131   };
132
133 struct outp_driver;
134 struct font_desc *groff_read_font (const char *fn);
135 struct font_desc *groff_find_font (const char *dev, const char *name);
136 int groff_read_DESC (const char *dev_name, struct groff_device_info * dev);
137 void groff_init (void);
138 void groff_done (void);
139
140 struct font_desc *default_font (void);
141
142 #endif /* font_h */