Added stroke fonts.
[freeglut] / genfonts / wfont.h
1 /* $XConsortium: wfont.h,v 5.2 94/04/17 20:10:09 rws Exp $ */
2
3 /*****************************************************************
4
5 Copyright (c) 1989,1990, 1991  X Consortium
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23
24 Except as contained in this notice, the name of the X Consortium shall not be
25 used in advertising or otherwise to promote the sale, use or other dealings
26 in this Software without prior written authorization from the X Consortium.
27
28 Copyright (c) 1989,1990, 1991 by Sun Microsystems, Inc.
29
30                         All Rights Reserved
31
32 Permission to use, copy, modify, and distribute this software and its 
33 documentation for any purpose and without fee is hereby granted, 
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in 
36 supporting documentation, and that the names of Sun Microsystems,
37 and the X Consortium, not be used in advertising or publicity 
38 pertaining to distribution of the software without specific, written 
39 prior permission.  
40
41 SUN MICROSYSTEMS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, 
42 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT 
43 SHALL SUN MICROSYSTEMS BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL 
44 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
45 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
46 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47 SOFTWARE.
48
49 ******************************************************************/
50
51
52 #ifndef WFONT_INCLUDED
53 #define WFONT_INCLUDED
54
55 #define WFONT_MAGIC     0x813
56 #define WFONT_MAGIC_PLUS 0x715
57 #define WFONT_MAGIC_PEX 0x70686e74
58 #define START_PROPS 0x100
59 #define START_DISPATCH(_num_props)  (START_PROPS + 160 * _num_props)
60 #define START_PATH(_num_ch_, _num_props)  (START_DISPATCH(_num_props) + sizeof(Dispatch) * _num_ch_)
61 #define NUM_DISPATCH    128
62
63 typedef struct {
64         unsigned short  x;
65         unsigned short  y;
66 } Path_point2dpx;
67
68 typedef struct {
69         float   x;
70         float   y;
71 } Path_point2df;
72
73 typedef struct {
74         int     x;
75         int     y;
76         int     z;
77 } Path_point3di;
78
79 typedef struct {
80         float   x;
81         float   y;
82         float   z;
83 } Path_point3df;
84
85 typedef struct {
86         float   x;
87         float   y;
88         float   z;
89         float   w;
90 } Path_point4df;
91
92 typedef union {
93         Path_point2dpx  *pt2dpx;
94         Path_point2df   *pt2df;
95         Path_point3di   *pt3di;
96         Path_point3df   *pt3df;
97         Path_point4df   *pt4df;
98 } Path_pt_ptr;
99
100 typedef enum {
101         PATH_2DF, 
102         PATH_2DPX, 
103         PATH_3DF, 
104         PATH_3DI, 
105         PATH_4DF 
106 } Path_type;
107
108 typedef struct {
109         int             n_pts;          /* number of points in the subpath */
110         Path_pt_ptr     pts;            /* pointer to them */
111         int             closed;         /* true if the subpath is closed */
112         int             dcmp_flag;      /* flag for pgon dcmp, pgon type 
113                                        and dcmped triangle type */
114 } Path_subpath;
115
116 typedef struct {
117         Path_type       type;           /* type of vertices in this path */
118         int             n_subpaths;     /* number of subpaths */
119         int             n_vertices;     /* total number of vertices */
120         Path_subpath    *subpaths;      /* array of subpaths */
121 } Path;
122
123 typedef Path    *Path_handle;
124
125 typedef struct {
126         char    propname[80];          /* font property name */
127         char    propvalue[80];         /* font property value */
128 }Property;
129
130 typedef struct {
131         int             magic;         /* magic number */
132         char            name[80];      /* name of this font */
133         float           top,           /* extreme values */
134                         bottom,
135                         max_width;
136         int             num_ch;        /* no. of fonts in the set */
137         int             num_props;     /* no. of font properties */
138         Property        *properties;   /* array of properties */
139 } Font_header;
140
141 typedef struct {
142         float           center,        /* center of the character */
143                         right;         /* right edge */
144         long            offset;        /* offset in the file of the character
145                                         * description*/
146 } Dispatch;     
147
148
149 typedef struct {
150         float           center,
151                         right;
152         Path            strokes;
153 } Ch_font;
154
155 typedef struct {
156         char            name[80];
157         float           top,
158                         bottom,
159                         max_width;
160         int             num_ch;         /* # characters in the font*/
161         Ch_font         **ch_data;
162 } Phg_font;
163
164 #endif  /*WFONT_INCLUDED*/