1 /****************************************************************************\ 2 Part of the XeTeX typesetting system 3 Copyright (c) 1994-2008 by SIL International 4 Copyright (c) 2009 by Jonathan Kew 5 6 SIL Author(s): Jonathan Kew 7 8 Permission is hereby granted, free of charge, to any person obtaining 9 a copy of this software and associated documentation files (the 10 "Software"), to deal in the Software without restriction, including 11 without limitation the rights to use, copy, modify, merge, publish, 12 distribute, sublicense, and/or sell copies of the Software, and to 13 permit persons to whom the Software is furnished to do so, subject to 14 the following conditions: 15 16 The above copyright notice and this permission notice shall be 17 included in all copies or substantial portions of the Software. 18 19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22 NONINFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE 23 FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 27 Except as contained in this notice, the name of the copyright holders 28 shall not be used in advertising or otherwise to promote the sale, 29 use or other dealings in this Software without prior written 30 authorization from the copyright holders. 31 \****************************************************************************/ 32 33 /* additional declarations we want to slip in for xetex */ 34 35 #define native_node_size 6 36 #define native_node_text(p) ((unsigned short*)(&(mem[(p) + native_node_size]))) 37 38 #define getnativechar(p,i) native_node_text(p)[i] 39 #define setnativechar(p,i,v) native_node_text(p)[i] = v 40 41 #define getnativeusv(p,i) \ 42 ((native_node_text(p)[i] >= 0xd800 && native_node_text(p)[i] < 0xdc00) ? \ 43 0x10000 + (native_node_text(p)[i] - 0xd800) * 0x400 + native_node_text(p)[(i)+1] - 0xdc00 : \ 44 native_node_text(p)[i]) 45 46 /* p is native_word node; g is XeTeX_use_glyph_metrics flag */ 47 #define setnativemetrics(p,g) measure_native_node(&(mem[p]), g) 48 49 #define setnativeglyphmetrics(p,g) measure_native_glyph(&(mem[p]), g) 50 51 #define setjustifiednativeglyphs(p) store_justified_native_glyphs(&(mem[p])) 52 53 #define getnativeitaliccorrection(p) get_native_italic_correction(&(mem[p])) 54 #define getnativeglyphitaliccorrection(p) get_native_glyph_italic_correction(&(mem[p])) 55 56 #define getnativeglyph(p,i) get_native_glyph(&(mem[p]), i) 57 58 #define makexdvglypharraydata(p) makeXDVGlyphArrayData(&(mem[p])) 59 #define xdvbufferbyte(i) xdvbuffer[i] 60 61 #define getcpcode get_cp_code 62 #define setcpcode set_cp_code 63 #define getnativewordcp(p,s) get_native_word_cp(&(mem[p]), s) 64 65 #define pic_node_size 8 66 67 #define deref(p) (*(p)) 68 69 #define findpicfile(a,b,c,d) find_pic_file(a, b, c, d) 70 71 #define picpathbyte(p,i) ((unsigned char*)&(mem[p+pic_node_size]))[i] 72 73 #define dviopenout(f) open_dvi_output(&(f)) 74 75 #define nullptr (NULL) 76 #define glyphinfobyte(p,k) ((unsigned char*)p)[k] 77 #define casttoushort(x) (unsigned short)(x) 78 79 /* easier to do the bit-twiddling here than in Pascal */ 80 /* read fields from a 32-bit math code */ 81 #define mathfamfield(x) (((unsigned)(x) >> 24) & 0xFF) 82 #define mathclassfield(x) (((unsigned)(x) >> 21) & 0x07) 83 #define mathcharfield(x) ((unsigned)(x) & 0x1FFFFF) 84 /* calculate pieces to assign to a math code */ 85 #define setfamilyfield(x) (((unsigned)(x) & 0xFF) << 24) 86 #define setclassfield(x) (((unsigned)(x) & 0x07) << 21) 87 88 /* aliases */ 89 #define getnativemathsyparam get_native_mathsy_param 90 #define getnativemathexparam get_native_mathex_param 91 #define getotmathconstant get_ot_math_constant 92 #define getotmathvariant get_ot_math_variant 93 #define getotassemblyptr get_ot_assembly_ptr 94 #define getotmathitalcorr get_ot_math_ital_corr 95 #define getotmathaccentpos get_ot_math_accent_pos 96 #define getotmathkern get_ot_math_kern 97 #define otpartcount ot_part_count 98 #define otpartglyph ot_part_glyph 99 #define otpartisextender ot_part_is_extender 100 #define otpartstartconnector ot_part_start_connector 101 #define otpartendconnector ot_part_end_connector 102 #define otpartfulladvance ot_part_full_advance 103 #define otminconnectoroverlap ot_min_connector_overlap 104 /* prototypes used in xetex.web */ 105 #include "XeTeXOTMath.h" 106 107 /* Unicode file reading modes */ 108 #define AUTO 0 /* default: will become one of 1..3 at file open time, after sniffing */ 109 #define UTF8 1 110 #define UTF16BE 2 111 #define UTF16LE 3 112 #define RAW 4 113 #define ICUMAPPING 5 114 #ifdef WIN32 115 #define WIN32CONSOLE 6 116 #endif 117 118 /* we don't use xchr, so change the cpascal.h definition of this... */ 119 #undef Xchr 120 #define Xchr(x) (x) 121 122 #include "trans.h" /* functions for affine transform operations */ 123 #include <teckit/TECkit_Common.h> /* include this before XeTeX_ext.h */ 124 #include "XeTeX_ext.h" /* other extension functions */ 125 126 #include <math.h> 127 /* apparently M_PI isn't defined by <math.h> under VC++ */ 128 #ifndef M_PI 129 #define M_PI 3.14159265358979323846 130 #endif 131