Debian Codegraph @

podofo/3rdparty/adobe/afdko/include/t2cstr.h

raw
1 /* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved.
2 This software is licensed as OpenSource, under the Apache License, Version 2.0.
3 This license is available at: http://opensource.org/licenses/Apache-2.0. */
4
5 /*
6 * Type 2 charstring services.
7 */
8
9 #ifndef T2CSTR_H
10 #define T2CSTR_H
11
12 #include "ctlshare.h"
13
14 #define T2C_VERSION CTL_MAKE_VERSION(1, 0, 23)
15
16 #include "absfont.h"
17
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21
22 typedef struct
23 {
24 long flags;
25 #define T2C_WIDTH_ONLY (1 << 0)
26 #define T2C_USE_MATRIX (1 << 1)
27 #define T2C_UPDATE_OPS (1 << 2)
28 #define T2C_IS_CFF2 (1 << 7)
29 #define T2C_FLATTEN_BLEND (1 << 8)
30
31 void *src;
32 ctlStreamCallbacks *stm;
33 ctlSubrs subrs;
34 ctlSubrs gsubrs;
35 long gsubrsEnd;
36 long subrsEnd;
37 float defaultWidthX;
38 float nominalWidthX;
39 void *ctx;
40 long (*getStdEncGlyphOffset)(void *ctx, int stdcode);
41 unsigned char bchar;
42 unsigned char achar;
43 float matrix[6];
44 float WV[4];
45 void *dbg;
46 unsigned short default_vsIndex; /* this is the vsindex set in the private dict. */
47 struct var_itemVariationStore_ *varStore;
48 float *scalars;
49 } t2cAuxData;
50
51 typedef struct cff2GlyphCallbacks_ cff2GlyphCallbacks;
52
53 struct cff2GlyphCallbacks_ {
54 void *direct_ctx;
55 float (*getWidth)(cff2GlyphCallbacks *cb, unsigned short gid);
56 };
57
58 int t2cParse(long offset, long endOffset, t2cAuxData *aux, unsigned short gid, cff2GlyphCallbacks *cff2, abfGlyphCallbacks *glyph, ctlMemoryCallbacks *mem);
59
60 /* t2cParse() is called to parse a Type 2 charstring into its constituent
61 parts.
62
63 The "offset" parameter specifies the stream offset of the charstring to be
64 parsed.
65
66 The "endOffset" parameter specifies the stream offset of the end of charstring to be
67 parsed; it points one byte past the end end of the charstring.
68
69 The "aux" parameter specifies charstring parse data that is normally stable
70 across charstrings. A client may therefore set this up once before parsing
71 all the charstrings in a font. The "aux" parameter fields are described
72 below.
73
74 The "gid" parameter specifies the glyph ID.
75
76 The "cff2" parameter specifies the context for reading SFNT tables
77 for metrics and variation font data needed if this is a CFF2 font.
78
79 The "flags" field allows client control over the parse by setting bits as
80 follows:
81
82 T2C_WIDTH_ONLY - terminate parse after calling back the width
83
84 T2C_USE_MATRIX - transform path coordinates using the "matrix" field before
85 they are called back to the client. This facility would not normally be used
86 during font format conversion since it is generally better to leave the path
87 coordinates unmodified and specify a non-default matrix in the font
88
89 T2C_UPDATE_OPS - charstrings using the deprecated seac operator are
90 converted to a regular path by combining the component glyphs specified in
91 the charstring and the deprecated dotsection operator is removed
92
93 T2C_UPDATE_OPS - charstrings using the deprecated seac operator are
94 converted to a regular path by combining the component glyphs specified in
95 the charstring and the deprecated dotsection operator is removed
96
97 The "getStdEncGlyphOffset" field holds the address of a function that will
98 return the stream offset of a standard encoded glyph. It is only called when
99 the T2C_UPDATE_OPS bit is set and a seac operator is encountered. The glyph
100 is specified as a character code in StandardEncoding via the "stdcode"
101 parameter which is merely acts a synonym for the glyph's name. A client
102 should return the stream offset of a glyph whose name is at that standard
103 code point or -1 if an error is encountered. The function passes a copy of
104 the "ctx" field via the function's "ctx" parameter.
105
106 The "bchar" and "achar" fields specify the base and accent standard
107 character codes for seac charstrings, respectively. Non-zero values for
108 either of these fields after return from t1cParse() indicates that the
109 charstring contained a seac operator. A client building a subset font may
110 use this information to ensure that the glyphs with the standard encodings
111 of "achar" and "bchar" are added to the subset.
112
113 Charstring data is obtained via a stream interface specified by the
114 "src" stream field and the stream callbacks specified via the "stm"
115 field. The stream is assumed to have been opened by the client and will be
116 closed by the client. t2cParse() only make seek() and read() calls on the
117 source stream.
118
119 Type 2 charstrings are typically subroutinized with both local and global
120 subroutines whose offsets are specified by the "subrs" and "gsubrs"
121 fields, respectively (see ctlshare.h).
122
123 The "defaultWidthX" and "nominalWidthX" fields are copied from the relevant
124 CFF Private dictionary data and are used to compute correct widths from
125 the charstring data.
126
127 The "WV" field provides support for a private implementation of multiple
128 master substitution fonts which are assumed to have 4 master designs. This
129 field may be left uninitialized by clients who don't need to support
130 substitution.
131
132 The glyph callback functions are specified via the "glyph" parameter (see
133 absfont.h). The glyph callbacks pass path construction data back to the
134 client. However, the glyph.new() and glyph.end() callbacks are not called
135 from t2cParse() since the client is directly initiating the callbacks.
136
137 The parse proceeds until one of the following conditions:
138
139 o an endchar operator is encountered in the charstring or a subroutine
140 (t2cSuccess is returned)
141 o the end of the charstring is encountered.
142 o the width has be called back to the client and the T2C_WIDTH_ONLY bit
143 is set (t1cSuccess is returned)
144 o an error is encountered and returned
145
146 t2cParse() returns zero (t2cSuccess) if successful, but otherwise returns a
147 positive non-zero error code described below.
148
149 The gsubr array must have one more entry than there actually are gsubrs, in
150 order to allow getting the end of the last gubsr.
151
152 A charstring should terminate with one of the "endchar", "callsubr", or
153 "callgsubr" operators. A subroutine should terminate with one of the
154 preceding operators or "return". */
155
156 enum {
157 #undef CTL_DCL_ERR
158 #define CTL_DCL_ERR(name, string) name,
159 #include "t2cerr.h"
160 t2cErrCount
161 };
162
163 /* Library functions return either zero (t2cSuccess) to indicate success or a
164 positive non-zero error code that is defined in the above enumeration that
165 is built from t2cerr.h. */
166
167 char *t2cErrStr(int err_code);
168
169 /* t2cErrStr() maps the "err_code" parameter to a null-terminated error
170 string. */
171
172 void t2cGetVersion(ctlVersionCallbacks *cb);
173
174 /* t2cGetVersion() returns the library version number and name via the client
175 callbacks passed with the "cb" parameter (see ctlshare.h). */
176
177 #ifdef __cplusplus
178 }
179 #endif
180
181 #endif /* T2CSTR_H */