| 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 1 and 2 charstring operators. |
| 7 |
* |
| 8 |
* The Type 2 operator set was derived from the Type 1 set by the removal of |
| 9 |
* some old operators and the addition of new operators. In some cases the |
| 10 |
* functionality of retained operators has also been extended by utilizing |
| 11 |
* operand count information. Spare (unassigned) operators are shown reserved. |
| 12 |
* |
| 13 |
* Macro prefixes: |
| 14 |
* |
| 15 |
* tx_ Shared by Type 1 and Type 2 |
| 16 |
* t1_ Found in Type 1 only |
| 17 |
* t2_ Found in Type 2 only |
| 18 |
*/ |
| 19 |
|
| 20 |
#ifndef PUBLIC_TXOPS_H |
| 21 |
#define PUBLIC_TXOPS_H |
| 22 |
|
| 23 |
/* ----------------------- One Byte Operators (0-31) ----------------------- */ |
| 24 |
|
| 25 |
/* Type 2 */ |
| 26 |
#define tx_reserved0 0 /* used internally by coretype */ |
| 27 |
#define tx_hstem 1 |
| 28 |
#define tx_reserved2 2 /* was Cube compose */ |
| 29 |
#define tx_vstem 3 |
| 30 |
#define tx_vmoveto 4 |
| 31 |
#define tx_rlineto 5 |
| 32 |
#define tx_hlineto 6 |
| 33 |
#define tx_vlineto 7 |
| 34 |
#define tx_rrcurveto 8 |
| 35 |
#define t2_reserved9 9 /* Subroutinizer cstr separator */ |
| 36 |
#define tx_callsubr 10 |
| 37 |
#define tx_return 11 |
| 38 |
#define tx_escape 12 |
| 39 |
#define t2_reserved13 13 |
| 40 |
#define tx_endchar 14 |
| 41 |
#define t2_vsindex 15 |
| 42 |
#define t2_blend 16 |
| 43 |
#define tx_reserved17 17 /* was Cube callgrel */ |
| 44 |
#define t2_hstemhm 18 |
| 45 |
#define t2_hintmask 19 |
| 46 |
#define t2_cntrmask 20 |
| 47 |
#define tx_rmoveto 21 |
| 48 |
#define tx_hmoveto 22 |
| 49 |
#define t2_vstemhm 23 |
| 50 |
#define t2_rcurveline 24 |
| 51 |
#define t2_rlinecurve 25 |
| 52 |
#define t2_vvcurveto 26 |
| 53 |
#define t2_hhcurveto 27 |
| 54 |
#define t2_shortint 28 |
| 55 |
#define t2_callgsubr 29 |
| 56 |
#define tx_vhcurveto 30 |
| 57 |
#define tx_hvcurveto 31 |
| 58 |
|
| 59 |
/* Type 1 (where different from above) */ |
| 60 |
#define t1_closepath 9 |
| 61 |
#define t1_hsbw 13 |
| 62 |
#define t1_moveto 15 /* Not in Black Book, used in a few fonts */ |
| 63 |
#define t1_reserved16 16 |
| 64 |
#define t1_reserved17 17 /* was t1 curveto or Cube callgrel */ |
| 65 |
#define t1_reserved18 18 |
| 66 |
#define t1_reserved19 19 /* was Cube setwv */ |
| 67 |
#define t1_reserved20 20 |
| 68 |
#define t1_reserved23 23 |
| 69 |
#define t1_reserved24 24 |
| 70 |
#define t1_reserved25 25 |
| 71 |
#define t1_reserved26 26 |
| 72 |
#define t1_reserved27 27 |
| 73 |
#define t1_reserved28 28 |
| 74 |
#define t1_reserved29 29 |
| 75 |
|
| 76 |
/* --------------------------- Two byte Operators -------------------------- */ |
| 77 |
|
| 78 |
/* Make escape operator value; may be redefined to suit implementation */ |
| 79 |
#ifndef tx_ESC |
| 80 |
#define tx_ESC(op) (tx_escape << 8 | (op)) |
| 81 |
#endif |
| 82 |
|
| 83 |
/* Type 2 */ |
| 84 |
#define tx_dotsection tx_ESC(0) /* Deprecated */ |
| 85 |
#define t2_reservedESC1 tx_ESC(1) |
| 86 |
#define t2_reservedESC2 tx_ESC(2) |
| 87 |
#define tx_and tx_ESC(3) |
| 88 |
#define tx_or tx_ESC(4) |
| 89 |
#define tx_not tx_ESC(5) |
| 90 |
#define t2_reservedESC6 tx_ESC(6) |
| 91 |
#define t2_reservedESC7 tx_ESC(7) |
| 92 |
#define t2_reservedESC8 tx_ESC(8) |
| 93 |
#define tx_abs tx_ESC(9) |
| 94 |
#define tx_add tx_ESC(10) |
| 95 |
#define tx_sub tx_ESC(11) |
| 96 |
#define tx_div tx_ESC(12) |
| 97 |
#define t2_reservedESC13 tx_ESC(13) |
| 98 |
#define tx_neg tx_ESC(14) |
| 99 |
#define tx_eq tx_ESC(15) |
| 100 |
#define t2_reservedESC16 tx_ESC(16) |
| 101 |
#define t2_reservedESC17 tx_ESC(17) |
| 102 |
#define tx_drop tx_ESC(18) |
| 103 |
#define tx_reservedESC19 tx_ESC(19) |
| 104 |
#define tx_put tx_ESC(20) |
| 105 |
#define tx_get tx_ESC(21) |
| 106 |
#define tx_ifelse tx_ESC(22) |
| 107 |
#define tx_random tx_ESC(23) |
| 108 |
#define tx_mul tx_ESC(24) |
| 109 |
#define tx_reservedESC25 tx_ESC(25) |
| 110 |
#define tx_sqrt tx_ESC(26) |
| 111 |
#define tx_dup tx_ESC(27) |
| 112 |
#define tx_exch tx_ESC(28) |
| 113 |
#define tx_index tx_ESC(29) |
| 114 |
#define tx_roll tx_ESC(30) |
| 115 |
#define tx_reservedESC31 tx_ESC(31) /* was Cube rotate */ |
| 116 |
#define tx_reservedESC32 tx_ESC(32) /* was Cube attach */ |
| 117 |
#define t2_reservedESC33 tx_ESC(33) /* used internally by */ |
| 118 |
/* coretype for cntroff */ |
| 119 |
#define t2_hflex tx_ESC(34) |
| 120 |
#define t2_flex tx_ESC(35) |
| 121 |
#define t2_hflex1 tx_ESC(36) |
| 122 |
#define t2_flex1 tx_ESC(37) |
| 123 |
#define t2_cntron tx_ESC(38) /* Deprecated/undocumented */ |
| 124 |
/* 39-255 Reserved */ |
| 125 |
|
| 126 |
/* The following were for use with Cube fonts: */ |
| 127 |
/* blend1 ESC 39 */ |
| 128 |
/* blend2 ESC 40 */ |
| 129 |
/* blend3 ESC 41 */ |
| 130 |
/* blend4 ESC 42 */ |
| 131 |
/* blend6 ESC 43 */ |
| 132 |
/* setwv1 ESC 44 */ |
| 133 |
/* setwv2 ESC 45 */ |
| 134 |
/* setwv3 ESC 46 */ |
| 135 |
/* setwv4 ESC 47 */ |
| 136 |
/* setwv5 ESC 48 */ |
| 137 |
/* setwvN ESC 49 */ |
| 138 |
/* transform ESC 50 */ |
| 139 |
|
| 140 |
|
| 141 |
/* Type 1 (where different from above) */ |
| 142 |
#define t1_vstem3 tx_ESC(1) |
| 143 |
#define t1_hstem3 tx_ESC(2) |
| 144 |
#define t1_seac tx_ESC(6) /* Deprecated */ |
| 145 |
#define t1_sbw tx_ESC(7) |
| 146 |
#define t1_store tx_ESC(8) |
| 147 |
#define t1_load tx_ESC(13) |
| 148 |
#define t1_callother tx_ESC(16) |
| 149 |
#define t1_pop tx_ESC(17) |
| 150 |
#define t1_div2 tx_ESC(25) |
| 151 |
#define t1_setcurrentpt tx_ESC(33) |
| 152 |
|
| 153 |
/* ------------------------------- Othersubrs ------------------------------ */ |
| 154 |
|
| 155 |
/* Type 1 */ |
| 156 |
#define t1_otherFlex 0 |
| 157 |
#define t1_otherPreflex1 1 |
| 158 |
#define t1_otherPreflex2 2 |
| 159 |
#define t1_otherHintSubs 3 |
| 160 |
#define t1_otherReserved4 4 |
| 161 |
#define t1_otherGlobalColor 6 |
| 162 |
#define t1_otherReserved7 7 |
| 163 |
#define t1_otherReserved8 8 |
| 164 |
#define t1_otherReserved9 9 |
| 165 |
#define t1_otherReserved10 10 |
| 166 |
#define t1_otherReserved11 11 |
| 167 |
#define t1_otherCntr1 12 |
| 168 |
#define t1_otherCntr2 13 |
| 169 |
#define t1_otherBlend1 14 |
| 170 |
#define t1_otherBlend2 15 |
| 171 |
#define t1_otherBlend3 16 |
| 172 |
#define t1_otherBlend4 17 |
| 173 |
#define t1_otherBlend6 18 |
| 174 |
#define t1_otherStoreWV 19 |
| 175 |
#define t1_otherAdd 20 |
| 176 |
#define t1_otherSub 21 |
| 177 |
#define t1_otherMul 22 |
| 178 |
#define t1_otherDiv 23 |
| 179 |
#define t1_otherPut 24 |
| 180 |
#define t1_otherGet 25 |
| 181 |
#define t1_otherReserved26 26 |
| 182 |
#define t1_otherIfelse 27 |
| 183 |
#define t1_otherRandom 28 |
| 184 |
#define t1_otherDup 29 |
| 185 |
#define t1_otherExch 30 |
| 186 |
|
| 187 |
/* ----------------------------- Miscellaneous ----------------------------- */ |
| 188 |
|
| 189 |
/* Return operator size from definition (doesn't handle mask or number ops) */ |
| 190 |
#define TXOPSIZE(op) (((op)&0xff00)?2:1) |
| 191 |
|
| 192 |
/* Interpreter limits/definitions */ |
| 193 |
#define TX_MAX_SUBR_DEPTH 10 /* Max recursion level allowed */ |
| 194 |
#define T2_MAX_OP_STACK 48 /* Max operand stack depth */ |
| 195 |
#define CFF2_DEFAULT_OP_STACK 193 /* Max operand stack depth */ |
| 196 |
#define CFF2_MAX_OP_STACK 513 /* Max stack for CFF2 dict and charstrings.*/ |
| 197 |
#define TX_MAX_CALL_STACK 10 /* Max callsubr stack depth */ |
| 198 |
#define T2_MAX_STEMS 96 /* Max stems */ |
| 199 |
#define TX_STD_FLEX_DEPTH 50 /* Standard flex depth (100ths/pixel) */ |
| 200 |
#define TX_MAX_BLUE_VALUES 14 /* 14 values (7 pairs) */ |
| 201 |
#define TX_MAX_OTHER_BLUES 10 /* 10 values (5 pairs) */ |
| 202 |
#define TX_MAX_STEM_SNAP 12 /* Max StemSnap elements */ |
| 203 |
#define TX_BCA_LENGTH 32 /* BuildCharArray length (elements) */ |
| 204 |
#define TX_MAX_XUID 16 /* Max XUID elements */ |
| 205 |
|
| 206 |
/* Type 1 (where different from above) */ |
| 207 |
#define T1_MAX_OP_STACK 24 /* Max operand stack depth */ |
| 208 |
#define T1_MAX_AXES 4 /* Max design axes */ |
| 209 |
#define T1_MAX_MASTERS 16 /* Max master designs */ |
| 210 |
#define T1_MAX_AXIS_MAPS 12 /* Max axis maps (piecewise division) */ |
| 211 |
|
| 212 |
/* CFF2 (where different from above) */ |
| 213 |
#define CFF2_MAX_AXES 512 /* Max design axes */ |
| 214 |
#define CFF2_MAX_MASTERS 512 /* Max master designs */ |
| 215 |
#define CFF2_MAX_AXIS_MAPS 512 /* Max axis maps (piecewise division) */ |
| 216 |
|
| 217 |
|
| 218 |
/* load/store registry ids */ |
| 219 |
#define T1_REG_WV 0 /* WeightVector */ |
| 220 |
#define T1_REG_NDV 1 /* NormalizedDesignVector */ |
| 221 |
#define T1_REG_UDV 2 /* UserDesignVector */ |
| 222 |
|
| 223 |
#define RND_ON_READ(val) (((int)((val)*10000))/10000.0) /* Truncate at 4 decimal places, the most that CFF supports as a real. I truncate because if a value is a hair below x.5, I don't want it rounding up to x.5, which will later round to x+1.*/ |
| 224 |
#define RND_ON_WRITE(val) (roundf(val*100)/100.0) /* round to 2 decimal places for output. */ |
| 225 |
|
| 226 |
#endif /* PUBLIC_TXOPS_H */ |