beta-0.89.2
[luatex.git] / source / texk / web2c / luatexdir / luafontloader / fontforge / fontforge / PfEd.h
blobd7d5d8fa670fa7115ded94e10afe35505377c13c
1 /* Copyright (C) 2008 by George Williams */
2 /*
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
6 * Redistributions of source code must retain the above copyright notice, this
7 * list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright notice,
10 * this list of conditions and the following disclaimer in the documentation
11 * and/or other materials provided with the distribution.
13 * The name of the author may not be used to endorse or promote products
14 * derived from this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
17 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
18 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
19 * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #ifndef _PFED_H
29 # define _PFED_H
30 /* The PfEd table (from PfaEdit, former name of FontForge) is designed to */
31 /* store information useful for editing the font. This includes stuff like */
32 /* guidelines, background layers, spiro layers, comments, lookup names, etc*/
33 /* The idea is that much useful information can be retrieved even after the */
34 /* font has been generated into its final form: ttf/otf */
35 /* It is something of a catch all table composed of many subtables, each of */
36 /* which preserves one particular item. I expect more subtables will be */
37 /* added as I, or others, think of more things worth preserving. */
40 # ifndef CHR
41 # define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
42 # endif
44 /* 'PfEd' table format is as follows... */
45 /* uint32 version number 0x00010000 */
46 /* uint32 subtable count */
47 /* struct { uint32 tab, offset } tag/offset for first subtable */
48 /* struct { uint32 tab, offset } tag/offset for second subtable */
49 /* ... */
51 /* 'PfEd' 'fcmt' font comment subtable format */
52 /* short version number 0/1 */
53 /* short string length */
54 /* version 0=>String in latin1 (should be ASCII), version 1=>utf8*/
56 /* 'PfEd' 'cmnt' glyph comment subtable format */
57 /* THIS VERSION IS DEPRECATED IN FAVOR OF VERSION 1 DESCRIBED BELOW */
58 /* short version number 0 */
59 /* short count-of-ranges */
60 /* struct { short start-glyph, end-glyph, short offset } */
61 /* ... */
62 /* foreach glyph >=start-glyph, <=end-glyph(+1) */
63 /* uint32 offset to glyph comment string (in UCS2)*/
64 /* ... */
65 /* And one last offset pointing beyong the end of the last string to enable length calculations */
66 /* String table in UCS2 (NUL terminated). All offsets from start*/
67 /* of subtable */
69 /* 'PfEd' 'cmnt' glyph comment subtable format */
70 /* New version of 'cmnt' which uses utf8 rather than UCS2 */
71 /* short version number 1 */
72 /* short count-of-ranges */
73 /* struct { short start-glyph, end-glyph, short offset } */
74 /* ... */
75 /* foreach glyph >=start-glyph, <=end-glyph(+1) */
76 /* uint32 offset to glyph comment string (in utf8)*/
77 /* ... */
78 /* And one last offset pointing beyong the end of the last string to enable length calculations */
79 /* String table in utf8 (NUL terminated). All offsets from start*/
80 /* of subtable */
82 /* 'PfEd' 'cvt ' cvt comment subtable format */
83 /* short version number 0 */
84 /* short size of cvt comment array (might be less that cvt) */
85 /* ushort offset[size] to utf8 strings describing cvt entries */
86 /* (strings are NUL terminated) */
87 /* String table in utf8 (NUL terminated). All offsets from start*/
88 /* of subtable */
90 /* 'PfEd' 'colr' glyph colour subtable */
91 /* short version number 0 */
92 /* short count-of-ranges */
93 /* struct { short start-glyph, end-glyph, uint32 colour (rgb) } */
95 /* 'PfEd' 'GPOS' GPOS lookup/subtable/anchor names */
96 /* short version number 0 */
97 /* short count-of-lookups */
98 /* struct { short offset name, offset subtables; } */
99 /* A subtable: */
100 /* short count-of-subtables */
101 /* struct { short offset name, offset anchors; } */
102 /* An anchor */
103 /* short count-of-anchors */
104 /* struct { short offset name; } */
105 /* string data (utf8, nul terminated) */
106 /* (all offsets from start of subtable) */
108 /* 'PfEd' 'GSUB' GSUB lookup/subtable names */
109 /* Same as GPOS (anchors will always be NULL) */
111 /* The next two tables 'guid' and 'layr' will make use of the */
112 /* following data type. The glyph_layer. */
113 /* short contour-count */
114 /* short image-count (always 0 for now) */
115 /* struct { ushort offset; ushort name-off}[contour-count] */
116 /* struct { ??? }[image-count] */
117 /* Each contour consists of one byte of command and a random */
118 /* amount of data dependant on the command. */
119 /* See below for a description of the command verbs */
120 /* string data in utf8 */
121 /* (offsets relative to start of glyph_layer structure ) */
123 /* 'PfEd' 'guid' Horizontal/Vertical guideline data */
124 /* short version number 0 */
125 /* short # vertical guidelines */
126 /* short # horizontal guidelines */
127 /* short mbz */
128 /* offset guide spline data -- specifies all guides as splines */
129 /* May be NULL */
130 /* struct[# vert guidelines] { short x; short offset name} */
131 /* struct[# h guidelines] { short y; short offset name} */
132 /* a glyph_layer (includes all guides, even those listed above) */
133 /* (all offsets, except those in the glyph_layer, relative to start of subtable) */
135 /* 'PfEd' 'layr' layer data */
136 /* short version number 0 */
137 /* short layer-count */
138 /* struct { short typeflags; short offset-name; uint32 offset-to-layer-data; } */
139 /* the layer type is 2=>quadratic, 3=>PostScript, 1=>spiro */
140 /* 0x102=>quadratic fore, 0x103=>PS fore */
141 /* A layer: */
142 /* short count-of-ranges */
143 /* struct { short start-glyph, end-glyph, uint32 offset } */
144 /* ... */
145 /* foreach glyph >=start-glyph, <=end-glyph */
146 /* uint32 offset to per-glyph outline data */
147 /* many glyph_layers */
148 /* (all offsets, except those in the glyph_layers, relative to start of subtable) */
150 /* Main table tag */
151 # define PfEd_TAG CHR('P','f','E','d')
153 /* Subtable tags */
154 # define fcmt_TAG CHR('f','c','m','t') /* Font Comment */
155 # define flog_TAG CHR('f','l','o','g') /* Font Log */
156 # define cmnt_TAG CHR('c','m','n','t') /* Glyph Comments */
157 # define cvtc_TAG CHR('c','v','t','c') /* Comments for each cvt entry */
158 # define colr_TAG CHR('c','o','l','r') /* Glyph color flags */
159 # ifndef GPOS_TAG
160 # define GPOS_TAG CHR('G','P','O','S') /* Names for GPOS lookups */
161 # define GSUB_TAG CHR('G','S','U','B') /* Names for GSUB lookups */
162 # endif
163 # define guid_TAG CHR('g','u','i','d') /* Guideline data */
164 # define layr_TAG CHR('l','a','y','r') /* Any layers which aren't part of the font */
165 /* Backgrounds, spiros, etc. */
168 /* The layer commands used to draw quadratic and cubic layers have two */
169 /* componants: A verb, which says what to do, and a modifier which says */
170 /* how the data are stored. So a command looks like (verb)|(modifier) */
171 /* A moveto command with byte data looks like (V_MoveTo|V_B) */
172 /* The two commands to end a contour (V_Close and V_End) take no data */
173 /* and use no modifier */
175 /* layr subtable contour construction verb modifiers specifying data types */
176 # define V_B 0 /* data are signed bytes */
177 # define V_S 1 /* data are signed shorts */
178 # define V_F 2 /* data are fixed longs, divide by 256.0 */
180 /* layr subtable contour construction verbs */
181 # define V_MoveTo 0 /* Start contour, absolute data (2 coords) */
182 # define V_LineTo 4 /* Straight line, relative data (2 coords) */
183 # define V_HLineTo 8 /* Horizontal line, relative (1 coord, x-off) */
184 # define V_VLineTo 12 /* Vertical line, relative (1 coord, y-off) */
186 # define V_QCurveTo 16 /* Quadratic spline, rel, rel (4 coords, cp, p) */
187 # define V_QImplicit 20 /* Quadratic spline, rel (2 coords, cp) */
188 /* May only occur after a V_QCurveTo or V_QImplicit (may not start contour) */
189 /* Must be followed by a V_QCurveTo or V_QImplicit (this may end contour) */
190 /* The on-curve point is implicit by averaging the given cp with the cp in the next verb */
191 # define V_QHImplicit 24 /* Quadratic spline, rel (1 coord, cp.x) */
192 # define V_QVImplicit 28 /* Quadratic spline, rel (1 coord, cp.y) */
194 # define V_CurveTo 32 /* Cubic spline, rel, rel (6 coords, cp1, cp2, p) */
195 # define V_VHCurveTo 36 /* Cubic spline, rel, rel (4 coords, cp1.y cp2.* p.x) */
196 /* cp1.x == current.y, p.y == cp2.y */
197 # define V_HVCurveTo 40 /* Cubic spline, rel, rel (4 coords, cp1.x cp2.* p.y) */
199 # define V_Close 44 /* Close path (optionally adding a line) no data */
200 # define V_End 45 /* End path (leave open) no data */
202 #define COM_MOD(com) ((com)&3)
203 #define COM_VERB(com) ((com)&~3)
205 /* the layer commands used to draw spiro layers are the standard spiro verbs */
206 /* these will always take fixed long data (V_L) as described above */
207 # ifndef SPIRO_OPEN_CONTOUR
208 # define SPIRO_OPEN_CONTOUR '{'
209 # define SPIRO_CORNER 'v'
210 # define SPIRO_G4 'o'
211 # define SPIRO_G2 'c'
212 # define SPIRO_LEFT '['
213 # define SPIRO_RIGHT ']'
214 # define SPIRO_END 'z'
215 # endif
216 # define SPIRO_CLOSE_CONTOUR '}'
218 #endif /* _PFED_H */