Debian Codegraph @

texk/web2c/xetexdir/XeTeX_ext.h

raw
1 /****************************************************************************\
2 Part of the XeTeX typesetting system
3 Copyright (c) 1994-2008 by SIL International
4 Copyright (c) 2009, 2011 by Jonathan Kew
5 Copyright (c) 2012, 2013 by Jiang Jiang
6 Copyright (c) 2012-2015 by Khaled Hosny
7
8 SIL Author(s): Jonathan Kew
9
10 Permission is hereby granted, free of charge, to any person obtaining
11 a copy of this software and associated documentation files (the
12 "Software"), to deal in the Software without restriction, including
13 without limitation the rights to use, copy, modify, merge, publish,
14 distribute, sublicense, and/or sell copies of the Software, and to
15 permit persons to whom the Software is furnished to do so, subject to
16 the following conditions:
17
18 The above copyright notice and this permission notice shall be
19 included in all copies or substantial portions of the Software.
20
21 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE
25 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
26 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28
29 Except as contained in this notice, the name of the copyright holders
30 shall not be used in advertising or otherwise to promote the sale,
31 use or other dealings in this Software without prior written
32 authorization from the copyright holders.
33 \****************************************************************************/
34
35 #ifndef __XETEXEXT_H
36 #define __XETEXEXT_H
37
38 #include <unicode/utypes.h>
39
40 #ifndef XETEX_UNICODE_FILE_DEFINED
41 typedef struct UFILE* unicodefile;
42 #endif
43
44 #define AAT_FONT_FLAG 0xFFFFU
45 #define OTGR_FONT_FLAG 0xFFFEU
46
47 #define FONT_FLAGS_COLORED 0x01
48 #define FONT_FLAGS_VERTICAL 0x02
49
50 /* some typedefs that XeTeX uses - on Mac OS, we get these from Apple headers,
51 but otherwise we'll need these substitute definitions */
52
53 #ifdef XETEX_MAC
54 #include <CoreFoundation/CoreFoundation.h>
55 #include <ApplicationServices/ApplicationServices.h>
56 #else
57 typedef int32_t Fixed;
58 typedef struct {
59 Fixed x;
60 Fixed y;
61 } FixedPoint;
62 #endif
63
64 typedef uint32_t OTTag;
65 typedef uint16_t GlyphID;
66 typedef struct {
67 float x;
68 float y;
69 } FloatPoint;
70
71
72 /* these are also in xetex.web and must correspond! */
73
74 #define pdfbox_crop 1
75 #define pdfbox_media 2
76 #define pdfbox_bleed 3
77 #define pdfbox_trim 4
78 #define pdfbox_art 5
79
80
81 #define XeTeX_count_glyphs 1
82
83 #define XeTeX_count_features 8
84 #define XeTeX_feature_code 9
85 #define XeTeX_find_feature_by_name 10
86 #define XeTeX_is_exclusive_feature 11
87 #define XeTeX_count_selectors 12
88 #define XeTeX_selector_code 13
89 #define XeTeX_find_selector_by_name 14
90 #define XeTeX_is_default_selector 15
91
92 #define XeTeX_OT_count_scripts 16
93 #define XeTeX_OT_count_languages 17
94 #define XeTeX_OT_count_features 18
95 #define XeTeX_OT_script_code 19
96 #define XeTeX_OT_language_code 20
97 #define XeTeX_OT_feature_code 21
98
99 #define XeTeX_map_char_to_glyph_code 22
100
101 #define XeTeX_feature_name 8
102 #define XeTeX_selector_name 9
103
104
105 /* definitions used to access info in a native_word_node; must correspond with defines in xetex.web */
106 #define width_offset 1
107 #define depth_offset 2
108 #define height_offset 3
109 #define native_info_offset 4
110 #define native_glyph_info_offset 5
111
112 #define node_width(node) node[width_offset].cint
113 #define node_depth(node) node[depth_offset].cint
114 #define node_height(node) node[height_offset].cint
115 #define native_length(node) node[native_info_offset].qqqq.b2
116 #define native_font(node) node[native_info_offset].qqqq.b1
117 #define native_glyph_count(node) node[native_info_offset].qqqq.b3
118 #define native_glyph_info_ptr(node) node[native_glyph_info_offset].ptr
119 #define native_glyph_info_size 10 /* info for each glyph is location (FixedPoint) + glyph ID (uint16_t) */
120
121 #define native_glyph(p) native_length(p) /* glyph ID field in a glyph_node */
122
123 /* OT-related constants we need */
124 #define kGSUB HB_TAG('G','S','U','B')
125 #define kGPOS HB_TAG('G','P','O','S')
126
127 typedef struct
128 {
129 float xMin;
130 float yMin;
131 float xMax;
132 float yMax;
133 } GlyphBBox;
134
135
136 /* For Unicode encoding form interpretation... */
137 extern const uint32_t offsetsFromUTF8[6];
138 extern const uint8_t bytesFromUTF8[256];
139 extern const uint8_t firstByteMark[7];
140
141 extern const int halfShift;
142 extern const uint32_t halfBase;
143 extern const uint32_t halfMask;
144 extern const uint32_t kSurrogateHighStart;
145 extern const uint32_t kSurrogateHighEnd;
146 extern const uint32_t kSurrogateLowStart;
147 extern const uint32_t kSurrogateLowEnd;
148 extern const uint32_t byteMask;
149 extern const uint32_t byteMark;
150
151 extern const char *papersize;
152 extern const char *outputdriver;
153
154 /* gFreeTypeLibrary is defined in XeTeXFontInst_FT2.cpp,
155 * also used in XeTeXFontMgr_FC.cpp and XeTeX_ext.c. */
156 #include <ft2build.h>
157 #include FT_FREETYPE_H
158 #ifdef __cplusplus
159 extern "C" {
160 #endif
161 extern FT_Library gFreeTypeLibrary;
162 #ifdef __cplusplus
163 }
164 #endif
165
166 #include <stdio.h> /* for FILE */
167
168 #ifdef WIN32
169 #undef fputs
170 #undef putc
171 #define fputs win32_fputs
172 #define putc win32_putc
173 #endif
174
175 #include "trans.h"
176
177 #ifdef HAVE_STDBOOL_H
178 # include <stdbool.h>
179 #else
180 /* boolean is an enum type from kpathsea/types.h loaded in
181 kpathsea/kpathsea.h, use it as fallback */
182 #ifndef __cplusplus
183 # define bool boolean
184 #endif
185 #endif
186
187 #include "XeTeXLayoutInterface.h"
188
189 #ifdef XETEX_MAC
190 extern const CFStringRef kXeTeXEmboldenAttributeName;
191 #endif
192
193 #ifdef __cplusplus
194 extern "C" {
195 #endif
196 void initversionstring(char **versions);
197
198 void setinputfileencoding(unicodefile f, integer mode, integer encodingData);
199 void linebreakstart(int f, integer localeStrNum, uint16_t* text, integer textLength);
200 int linebreaknext(void);
201 int getencodingmodeandinfo(integer* info);
202 void printutf8str(const unsigned char* str, int len);
203 void printchars(const unsigned short* str, int len);
204 void* findnativefont(unsigned char* name, integer scaled_size);
205 void releasefontengine(void* engine, int type_flag);
206 int readCommonFeatures(const char* feat, const char* end, float* extend, float* slant, float* embolden, float* letterspace, uint32_t* rgbValue);
207
208 /* the metrics params here are really TeX 'scaled' values, but that typedef isn't available every place this is included */
209 void otgetfontmetrics(void* engine, integer* ascent, integer* descent, integer* xheight, integer* capheight, integer* slant);
210 void getnativecharheightdepth(integer font, integer ch, integer* height, integer* depth);
211 void getnativecharsidebearings(integer font, integer ch, integer* lsb, integer* rsb);
212
213 /* single-purpose metrics accessors */
214 integer getnativecharwd(integer font, integer ch);
215 integer getnativecharht(integer font, integer ch);
216 integer getnativechardp(integer font, integer ch);
217 integer getnativecharic(integer font, integer ch);
218
219 integer getglyphbounds(integer font, integer edge, integer gid);
220
221 integer otfontget(integer what, void* engine);
222 integer otfontget1(integer what, void* engine, integer param);
223 integer otfontget2(integer what, void* engine, integer param1, integer param2);
224 integer otfontget3(integer what, void* engine, integer param1, integer param2, integer param3);
225 int makeXDVGlyphArrayData(void* p);
226 int makefontdef(integer f);
227 int applymapping(void* cnv, uint16_t* txtPtr, int txtLen);
228 void store_justified_native_glyphs(void* node);
229 void measure_native_node(void* node, int use_glyph_metrics);
230 Fixed get_native_italic_correction(void* node);
231 Fixed get_native_glyph_italic_correction(void* node);
232 integer get_native_word_cp(void* node, int side);
233 void measure_native_glyph(void* node, int use_glyph_metrics);
234 integer mapchartoglyph(integer font, integer ch);
235 integer mapglyphtoindex(integer font);
236 integer getfontcharrange(integer font, int first);
237 void printglyphname(integer font, integer gid);
238 uint16_t get_native_glyph(void* pNode, unsigned index);
239
240 void grprintfontname(integer what, void* pEngine, integer param1, integer param2);
241 integer grfontgetnamed(integer what, void* pEngine);
242 integer grfontgetnamed1(integer what, void* pEngine, integer param);
243
244 double read_double(const char** s);
245 unsigned int read_rgb_a(const char** cp);
246
247 int countpdffilepages(void);
248 int find_pic_file(char** path, realrect* bounds, int pdfBoxType, int page);
249 int u_open_in(unicodefile* f, integer filefmt, const char* fopen_mode, integer mode, integer encodingData);
250 void u_close_inout(unicodefile* f);
251 int open_dvi_output(FILE** fptr);
252 int dviclose(FILE* fptr);
253 int get_uni_c(UFILE* f);
254 int input_line(UFILE* f);
255 void makeutf16name(void);
256
257 void terminatefontmanager(void);
258 int maketexstring(const char* s);
259
260 void checkfortfmfontmapping(void);
261 void* loadtfmfontmapping(void);
262 int applytfmfontmapping(void* mapping, int c);
263
264 #ifndef XETEX_MAC
265 typedef void* CFDictionaryRef; /* dummy declaration just so the stubs can compile */
266 #endif
267
268 int aatfontget(int what, CFDictionaryRef attrs);
269 int aatfontget1(int what, CFDictionaryRef attrs, int param);
270 int aatfontget2(int what, CFDictionaryRef attrs, int param1, int param2);
271 int aatfontgetnamed(int what, CFDictionaryRef attrs);
272 int aatfontgetnamed1(int what, CFDictionaryRef attrs, int param);
273 void aatprintfontname(int what, CFDictionaryRef attrs, int param1, int param2);
274 /* the metrics params here are really TeX 'scaled' (or MacOS 'Fixed') values, but that typedef isn't available every place this is included */
275 void aatgetfontmetrics(CFDictionaryRef attrs, integer* ascent, integer* descent, integer* xheight, integer* capheight, integer* slant);
276
277 void set_cp_code(int fontNum, unsigned int code, int side, int value);
278 int get_cp_code(int fontNum, unsigned int code, int side);
279
280 #ifdef XETEX_MAC
281
282 /* functions in XeTeX_mac.c */
283 void* loadAATfont(CTFontDescriptorRef descriptor, integer scaled_size, const char* cp1);
284 void DoAATLayout(void* node, int justify);
285 void GetGlyphBBox_AAT(CFDictionaryRef fontAttrs, uint16_t gid, GlyphBBox* bbox);
286 double GetGlyphWidth_AAT(CFDictionaryRef fontAttrs, uint16_t gid);
287 void GetGlyphHeightDepth_AAT(CFDictionaryRef fontAttrs, uint16_t gid, float* ht, float* dp);
288 void GetGlyphSidebearings_AAT(CFDictionaryRef fontAttrs, uint16_t gid, float* lsb, float* rsb);
289 double GetGlyphItalCorr_AAT(CFDictionaryRef fontAttrs, uint16_t gid);
290 int MapCharToGlyph_AAT(CFDictionaryRef fontAttrs, UInt32 ch);
291 int MapGlyphToIndex_AAT(CFDictionaryRef attributes, const char* glyphName);
292 char* GetGlyphNameFromCTFont(CTFontRef ctFontRef, uint16_t gid, int* len);
293 CFDictionaryRef findDictionaryInArray(CFArrayRef array, const void* nameKey, const char* name, int nameLength);
294 CFDictionaryRef findDictionaryInArrayWithIdentifier(CFArrayRef array, const void* identifierKey, int identifier);
295 CFNumberRef findSelectorByName(CFDictionaryRef feature, const char* name, int nameLength);
296 char* getNameFromCTFont(CTFontRef ctFontRef, CFStringRef nameKey);
297 char* getFileNameFromCTFont(CTFontRef ctFontRef, uint32_t* index);
298 int GetFontCharRange_AAT(CFDictionaryRef fontAttrs, int reqFirst);
299 CTFontRef fontFromAttributes(CFDictionaryRef fontAttrs);
300 CTFontRef fontFromInteger(integer font);
301 #endif
302 #ifdef __cplusplus
303 };
304 #endif
305
306 #ifdef __cplusplus
307 extern "C" {
308 #endif
309 double Fix2D(Fixed f);
310 Fixed D2Fix(double d);
311 #ifdef __cplusplus
312 };
313 #endif
314
315 // copied from xetex.web
316 #define LEFT_SIDE 0
317 #define RIGHT_SIDE 1
318
319 #endif /* __XETEX_EXT_H */