Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

825 lines
35 KiB

  1. /***
  2. **
  3. ** Module: Encoding
  4. **
  5. ** Description:
  6. ** This is a module of the T1 to TT font converter. The module
  7. ** contains interface functions for the global encoding table,
  8. ** i.e. this is an abstract data type.
  9. **
  10. ** Author: Michael Jansson
  11. **
  12. ** Created: 6/13/93
  13. **
  14. ***/
  15. /**** INCLUDES */
  16. #include <string.h>
  17. #include "types.h"
  18. #include "encoding.h"
  19. #include "safemem.h"
  20. /***** LOCAL TYPES */
  21. struct encoding {
  22. const char *name; /* Postscript name of a glyph. */
  23. USHORT codes[ENC_MAXCODES]; /* Character codes for each encoding scheme. */
  24. };
  25. /***** CONSTANTS */
  26. static const struct encoding StdEncoding[] = {
  27. {".notdef", {0xffff, 0xffff, 0xffff, 0xffff}},
  28. {"A", {0x0041, 0x0041, 0x0041, 0x0041}},
  29. {"AE", {0x00c6, 0x00c6, 0x00e1, 174 }},
  30. {"Aacute", {0x00c1, 0x00c1, 0xffff, 231 }},
  31. {"Abreve", {0x0102, 0xffff, 0xffff, 0xffff}},
  32. {"Acircumflex", {0x00c2, 0x00c2, 0xffff, 229 }},
  33. {"Adieresis", {0x00c4, 0x00c4, 0xffff, 128 }},
  34. {"Agrave", {0x00c0, 0x00c0, 0xffff, 203 }},
  35. {"Aogonek", {0x0104, 0xffff, 0xffff, 0xffff}},
  36. {"Aring", {0x00c5, 0x00c5, 0xffff, 129 }},
  37. {"Atilde", {0x00c3, 0x00c3, 0xffff, 204 }},
  38. {"B", {0x0042, 0x0042, 0x0042, 0x0042}},
  39. {"C", {0x0043, 0x0043, 0x0043, 0x0043}},
  40. {"Cacute", {0x0106, 0xffff, 0xffff, 0xffff}},
  41. {"Ccaron", {0x010c, 0xffff, 0xffff, 0xffff}},
  42. {"Ccedilla", {0x00c7, 0x00c7, 0xffff, 130 }},
  43. {"D", {0x0044, 0x0044, 0x0044, 0x0044}},
  44. {"Dcaron", {0x010e, 0xffff, 0xffff, 0xffff}},
  45. {"Delta", {0x2206, 0xffff, 0xffff, 198 }},
  46. {"Dslash", {0x0110, 0xffff, 0xffff, 0xffff}},
  47. {"E", {0x0045, 0x0045, 0x0045, 0x0045}},
  48. {"Eacute", {0x00c9, 0x00c9, 0xffff, 131 }},
  49. {"Ecaron", {0x011a, 0xffff, 0xffff, 0xffff}},
  50. {"Ecircumflex", {0x00ca, 0x00ca, 0xffff, 230 }},
  51. {"Edieresis", {0x00cb, 0x00cb, 0xffff, 232 }},
  52. {"Egrave", {0x00c8, 0x00c8, 0xffff, 233 }},
  53. {"Eogonek", {0x0118, 0xffff, 0xffff, 0xffff}},
  54. {"Eth", {0x00d0, 0x00d0, 0xffff, 0xffff}},
  55. {"F", {0x0046, 0x0046, 0x0046, 0x0046}},
  56. {"G", {0x0047, 0x0047, 0x0047, 0x0047}},
  57. {"Gamma", {0x0393, 0xffff, 0xffff, 0xffff}},
  58. {"Gbreve", {0x011e, 0xffff, 0xffff, 0xffff}},
  59. {"H", {0x0048, 0x0048, 0x0048, 0x0048}},
  60. {"I", {0x0049, 0x0049, 0x0049, 0x0049}},
  61. {"Iacute", {0x00cd, 0x00cd, 0xffff, 234 }},
  62. {"Icircumflex", {0x00ce, 0x00ce, 0xffff, 235 }},
  63. {"Idieresis", {0x00cf, 0x00cf, 0xffff, 236 }},
  64. {"Idot", {0x0130, 0xffff, 0xffff, 0xffff}},
  65. {"Igrave", {0x00cc, 0x00cc, 0xffff, 237 }},
  66. {"J", {0x004a, 0x004a, 0x004a, 0x004a}},
  67. {"K", {0x004b, 0x004b, 0x004b, 0x004b}},
  68. {"L", {0x004c, 0x004c, 0x004c, 0x004c}},
  69. {"Lacute", {0x0139, 0xffff, 0xffff, 0xffff}},
  70. {"Lcaron", {0x013d, 0xffff, 0xffff, 0xffff}},
  71. {"Ldot", {0x013f, 0xffff, 0xffff, 0xffff}},
  72. {"Lslash", {0x0141, 0xffff, 0x00e8, 0xffff}},
  73. {"M", {0x004d, 0x004d, 0x004d, 0x004d}},
  74. {"N", {0x004e, 0x004e, 0x004e, 0x004e}},
  75. {"Nacute", {0x0143, 0xffff, 0xffff, 0xffff}},
  76. {"Ncaron", {0x0147, 0xffff, 0xffff, 0xffff}},
  77. {"Ntilde", {0x00d1, 0x00d1, 0xffff, 132 }},
  78. {"O", {0x004f, 0x004f, 0x004f, 0x004f}},
  79. {"OE", {0x0152, 0x008c, 0x00ea, 206 }},
  80. {"Oacute", {0x00d3, 0x00d3, 0xffff, 238 }},
  81. {"Ocircumflex", {0x00d4, 0x00d4, 0xffff, 239 }},
  82. {"Odblacute", {0x0150, 0xffff, 0xffff, 0xffff}},
  83. {"Odieresis", {0x00d6, 0x00d6, 0xffff, 133 }},
  84. {"Ograve", {0x00d2, 0x00d2, 0xffff, 241 }},
  85. {"Oslash", {0x00d8, 0x00d8, 0x00e9, 175 }},
  86. {"Otilde", {0x00d5, 0x00d5, 0xffff, 205 }},
  87. {"P", {0x0050, 0x0050, 0x0050, 0x0050}},
  88. {"Phi", {0x03a6, 0xffff, 0xffff, 0xffff}},
  89. {"Q", {0x0051, 0x0051, 0x0051, 0x0051}},
  90. {"R", {0x0052, 0x0052, 0x0052, 0x0052}},
  91. {"Racute", {0x0154, 0xffff, 0xffff, 0xffff}},
  92. {"Rcaron", {0x0158, 0xffff, 0xffff, 0xffff}},
  93. {"S", {0x0053, 0x0053, 0x0053, 0x0053}},
  94. {"Sacute", {0x015a, 0xffff, 0xffff, 0xffff}},
  95. {"Scaron", {0x0160, 0x008A, 0xffff, 0xffff}},
  96. {"Scedilla", {0x015e, 0xffff, 0xffff, 0xffff}},
  97. {"T", {0x0054, 0x0054, 0x0054, 0x0054}},
  98. {"Tcaron", {0x0164, 0xffff, 0xffff, 0xffff}},
  99. {"Tcedilla", {0x0162, 0xffff, 0xffff, 0xffff}},
  100. {"Theta", {0x0398, 0xffff, 0xffff, 0xffff}},
  101. {"Thorn", {0x00de, 0x00de, 0xffff, 0xffff}},
  102. {"U", {0x0055, 0x0055, 0x0055, 0x0055}},
  103. {"Uacute", {0x00da, 0x00da, 0xffff, 242 }},
  104. {"Ucircumflex", {0x00db, 0x00db, 0xffff, 243 }},
  105. {"Udblacute", {0x0170, 0xffff, 0xffff, 0xffff}},
  106. {"Udieresis", {0x00dc, 0x00dc, 0xffff, 134 }},
  107. {"Ugrave", {0x00d9, 0x00d9, 0xffff, 244 }},
  108. {"Uring", {0x016e, 0xffff, 0xffff, 0xffff}},
  109. {"V", {0x0056, 0x0056, 0x0056, 0x0056}},
  110. {"W", {0x0057, 0x0057, 0x0057, 0x0057}},
  111. {"X", {0x0058, 0x0058, 0x0058, 0x0058}},
  112. {"Y", {0x0059, 0x0059, 0x0059, 0x0059}},
  113. {"Yacute", {0x00dd, 0x00dd, 0xffff, 0xffff}},
  114. {"Ydieresis", {0x0178, 0x009f, 0xffff, 217 }},
  115. {"Z", {0x005a, 0x005a, 0x005a, 0x005a}},
  116. {"Zacute", {0x0179, 0xffff, 0xffff, 0xffff}},
  117. {"Zcaron", {0x017d, 0xffff, 0xffff, 0xffff}},
  118. {"Zdot", {0x017b, 0xffff, 0xffff, 0xffff}},
  119. {"a", {0x0061, 0x0061, 0x0061, 0x0061}},
  120. {"aacute", {0x00e1, 0x00e1, 0xffff, 135 }},
  121. {"abreve", {0x0103, 0xffff, 0xffff, 0xffff}},
  122. {"acircumflex", {0x00e2, 0x00e2, 0xffff, 137 }},
  123. {"acute", {0x00b4, 0x00b4, 0x00c2, 171 }},
  124. {"adieresis", {0x00e4, 0x00e4, 0xffff, 138 }},
  125. {"ae", {0x00e6, 0x00e6, 0x00f1, 190 }},
  126. {"agrave", {0x00e0, 0x00e0, 0xffff, 136 }},
  127. {"alpha", {0x03b1, 0xffff, 0xffff, 0xffff}},
  128. {"ampersand", {0x0026, 0x0026, 0x0026, 0x0026}},
  129. {"aogonek", {0x0105, 0xffff, 0xffff, 0xffff}},
  130. {"apple", {0xf000, 0x000, 0xffff, 240 }},
  131. {"approxequal", {0x2248, 0xffff, 0xffff, 197 }},
  132. {"aring", {0x00e5, 0x00e5, 0xffff, 140 }},
  133. {"arrowboth", {0x2194, 0xffff, 0xffff, 0xffff}},
  134. {"arrowdown", {0x2193, 0xffff, 0xffff, 0xffff}},
  135. {"aroowleft", {0x2190, 0xffff, 0xffff, 0xffff}},
  136. {"arrowright", {0x2192, 0xffff, 0xffff, 0xffff}},
  137. {"arrowup", {0x2191, 0xffff, 0xffff, 0xffff}},
  138. {"arrowupdn", {0x2195, 0xffff, 0xffff, 0xffff}},
  139. {"arrowupdnbse", {0x21a8, 0xffff, 0xffff, 0xffff}},
  140. {"asciicircum", {0x005e, 0x005e, 0x005e, 0x005e}},
  141. {"asciitilde", {0x007e, 0x007e, 0x007e, 0x007e}},
  142. {"asterisk", {0x002a, 0x002a, 0x002a, 0x002a}},
  143. {"at", {0x0040, 0x0040, 0x0040, 0x0040}},
  144. {"atilde", {0x00e3, 0x00e3, 0xffff, 139 }},
  145. {"b", {0x0062, 0x0062, 0x0062, 0x0062}},
  146. {"backslash", {0x005c, 0x005c, 0x005c, 0x005c}},
  147. {"bar", {0x007c, 0x007c, 0x007c, 0x007c}},
  148. {"block", {0x2588, 0xffff, 0xffff, 0xffff}},
  149. {"braceleft", {0x007b, 0x007b, 0x007b, 0x007b}},
  150. {"braceright", {0x007d, 0x007d, 0x007d, 0x007d}},
  151. {"bracketleft", {0x005b, 0x005b, 0x005b, 0x005b}},
  152. {"bracketright", {0x005d, 0x005d, 0x005d, 0x005d}},
  153. {"breve", {0x02d8, 0xffff, 0x00c6, 249 }},
  154. {"brokenbar", {0x00a6, 0x00a6, 0xffff, 0xffff}},
  155. {"bullet", {0x2022, 0x0095, 0x00b7, 165 }},
  156. {"c", {0x0063, 0x0063, 0x0063, 0x0063}},
  157. {"cacute", {0x0107, 0xffff, 0xffff, 0xffff}},
  158. {"caron", {0x02c7, 0xffff, 0x00cf, 255 }},
  159. {"ccaron", {0x010d, 0xffff, 0xffff, 0xffff}},
  160. {"ccedilla", {0x00e7, 0x00e7, 0xffff, 141 }},
  161. {"cedilla", {0x00b8, 0x00b8, 0x00cb, 252 }},
  162. {"cent", {0x00a2, 0x00a2, 0x00a2, 162 }},
  163. {"circle", {0x25cb, 0xffff, 0xffff, 0xffff}},
  164. {"circumflex", {0x02c6, 0x0088, 0x00c3, 246 }},
  165. {"club", {0x2663, 0xffff, 0xffff, 0xffff}},
  166. {"colon", {0x003a, 0x003a, 0x003a, 0x003a}},
  167. {"comma", {0x002c, 0x002c, 0x002c, 0x002c}},
  168. {"copyright", {0x00a9, 0x00a9, 0xffff, 169 }},
  169. {"currency", {0x00a4, 0x00a4, 0x00a8, 219 }},
  170. {"d", {0x0064, 0x0064, 0x0064, 0x0064}},
  171. {"dagger", {0x2020, 0x0086, 0x00b2, 160 }},
  172. {"daggerdbl", {0x2021, 0x0087, 0x00b3, 224 }},
  173. {"dcaron", {0x010f, 0xffff, 0xffff, 0xffff}},
  174. {"degree", {0x00b0, 0x00b0, 0xffff, 161 }},
  175. {"delta", {0x03b4, 0xffff, 0xffff, 0xffff}},
  176. {"diamond", {0x2666, 0xffff, 0xffff, 0xffff}},
  177. {"dieresis", {0x00a8, 0x00a8, 0x00c8, 172 }},
  178. {"divide", {0x00f7, 0x00f7, 0xffff, 214 }},
  179. {"dkshade", {0x2593, 0xffff, 0xffff, 0xffff}},
  180. {"dmacron", {0x0111, 0xffff, 0xffff, 0xffff}},
  181. {"dnblock", {0x2584, 0xffff, 0xffff, 0xffff}},
  182. {"dollar", {0x0024, 0x0024, 0x0024, 0x0024}},
  183. {"dotaccent", {0x02d9, 0xffff, 0x00c7, 250 }},
  184. {"dotlessi", {0x0131, 0xffff, 0x00f5, 245 }},
  185. {"e", {0x0065, 0x0065, 0x0065, 0x0065}},
  186. {"eacute", {0x00e9, 0x00e9, 0xffff, 142 }},
  187. {"ecaron", {0x011b, 0xffff, 0xffff, 0xffff}},
  188. {"ecircumflex", {0x00ea, 0x00ea, 0xffff, 144 }},
  189. {"edieresis", {0x00eb, 0x00eb, 0xffff, 145 }},
  190. {"egrave", {0x00e8, 0x00e8, 0xffff, 143 }},
  191. {"eight", {0x0038, 0x0038, 0x0038, 0x0038}},
  192. {"ellipsis", {0x2026, 0x0085, 0x00bc, 201 }},
  193. {"emdash", {0x2014, 0x0097, 0x00d0, 209 }},
  194. {"endash", {0x2013, 0x0096, 0x00b1, 208 }},
  195. {"eogonek", {0x0119, 0xffff, 0xffff, 0xffff}},
  196. {"epsilon", {0x03b4, 0xffff, 0xffff, 0xffff}},
  197. {"equal", {0x003d, 0x003d, 0x003d, 0x003d}},
  198. {"equivalence", {0x2261, 0xffff, 0xffff, 0xffff}},
  199. {"eth", {0x00f0, 0x00f0, 0xffff, 0xffff}},
  200. {"exclam", {0x0021, 0x0021, 0x0021, 0x0021}},
  201. {"exclamdbl", {0x203c, 0xffff, 0xffff, 0xffff}},
  202. {"exclamdown", {0x00a1, 0x00a1, 0x00a1, 193 }},
  203. {"f", {0x0066, 0x0066, 0x0066, 0x0066}},
  204. {"female", {0x2640, 0xffff, 0xffff, 0xffff}},
  205. {"fi", {0xf001, 0xffff, 0x00ae, 222 }},
  206. {"filledbox", {0x25a0, 0xffff, 0xffff, 0xffff}},
  207. {"filledrect", {0x25ac, 0xffff, 0xffff, 0xffff}},
  208. {"five", {0x0035, 0x0035, 0x0035, 0x0035}},
  209. {"fl", {0xf002, 0xffff, 0x00af, 223 }},
  210. {"florin", {0x0192, 0x0083, 0x00a6, 196 }},
  211. {"four", {0x0034, 0x0034, 0x0034, 0x0034}},
  212. {"fraction", {0x2215, 0xffff, 0x00a4, 218 }},
  213. {"franc", {0x20a3, 0xffff, 0xffff, 0xffff}},
  214. {"g", {0x0067, 0x0067, 0x0067, 0x0067}},
  215. {"gbreve", {0x011f, 0xffff, 0xffff, 0xffff}},
  216. {"germandbls", {0x00df, 0x00df, 0x00fb, 167 }},
  217. {"grave", {0x0060, 0x0060, 0x00c1, 0x0060}},
  218. {"greater", {0x003e, 0x003e, 0x003e, 0x003e}},
  219. {"greaterequal", {0x2265, 0xffff, 0xffff, 179 }},
  220. {"guillemotleft", {0x00ab, 0x00ab, 0x00ab, 199 }},
  221. {"guillemotright",{0x00bb, 0x00bb, 0x00bb, 200 }},
  222. {"guilsinglleft", {0x2039, 0x008b, 0x00ac, 220 }},
  223. {"guilsinglright",{0x203a, 0x009b, 0x00ad, 221 }},
  224. {"h", {0x0068, 0x0068, 0x0068, 0x0068}},
  225. {"heart", {0x2665, 0xffff, 0xffff, 0xffff}},
  226. {"house", {0x2302, 0xffff, 0xffff, 0xffff}},
  227. {"hungarumlaut", {0x02dd, 0xffff, 0x00cd, 0xffff}},
  228. {"hyphen", {0x002d, 0x002d, 0x002d, 0x002d}},
  229. {"i", {0x0069, 0x0069, 0x0069, 0x0069}},
  230. {"iacute", {0x00ed, 0x00ed, 0xffff, 146 }},
  231. {"icircumflex", {0x00ee, 0x00ee, 0xffff, 148 }},
  232. {"idieresis", {0x00ef, 0x00ef, 0xffff, 149 }},
  233. {"igrave", {0x00ec, 0x00ec, 0xffff, 147 }},
  234. {"infinity", {0x221e, 0xffff, 0xffff, 176 }},
  235. {"integral", {0x222b, 0xffff, 0xffff, 186 }},
  236. {"integralbt", {0x2321, 0xffff, 0xffff, 0xffff}},
  237. {"integraltp", {0x2320, 0xffff, 0xffff, 0xffff}},
  238. {"intersection", {0x2229, 0xffff, 0xffff, 0xffff}},
  239. {"invbullet", {0x25d8, 0xffff, 0xffff, 0xffff}},
  240. {"invcircle", {0x25d9, 0xffff, 0xffff, 0xffff}},
  241. {"invsmileface", {0x263b, 0xffff, 0xffff, 0xffff}},
  242. {"j", {0x006a, 0x006a, 0x006a, 0x006a}},
  243. {"k", {0x006b, 0x006b, 0x006b, 0x006b}},
  244. {"l", {0x006c, 0x006c, 0x006c, 0x006c}},
  245. {"lacute", {0x013a, 0xffff, 0xffff, 0xffff}},
  246. {"lcaron", {0x013e, 0xffff, 0xffff, 0xffff}},
  247. {"ldot", {0x0140, 0xffff, 0xffff, 0xffff}},
  248. {"less", {0x003c, 0x003c, 0x003c, 0x003c}},
  249. {"lessequal", {0x2264, 0xffff, 0xffff, 178 }},
  250. {"lfblock", {0x258c, 0xffff, 0xffff, 0xffff}},
  251. {"logicalnot", {0x00ac, 0x00ac, 0xffff, 194 }},
  252. {"lozenge", {0x25ca, 0xffff, 0xffff, 215 }},
  253. {"lslash", {0x0142, 0xffff, 0x00f8, 0xffff}},
  254. {"ltshade", {0x2591, 0xffff, 0xffff, 0xffff}},
  255. {"m", {0x006d, 0x006d, 0x006d, 0x006d}},
  256. {"macron", {0x00af, 0xffff, 0x00c5, 248 }},
  257. {"male", {0x2642, 0xffff, 0xffff, 0xffff}},
  258. {"middot", {0x00b7, 0x00b7, 0xffff, 0xffff}},
  259. {"minus", {0x2212, 0xffff, 0xffff, 0xffff}},
  260. {"mu", {0x00b5, 0x00b5, 0xffff, 181 }},
  261. {"multiply", {0x00d7, 0x00d7, 0xffff, 0xffff}},
  262. {"musicalnote", {0x266a, 0xffff, 0xffff, 0xffff}},
  263. {"musicalnotedbl",{0x266b, 0xffff, 0xffff, 0xffff}},
  264. {"n", {0x006e, 0x006e, 0x006e, 0x006e}},
  265. {"nacute", {0x0144, 0xffff, 0xffff, 0xffff}},
  266. {"nbspace", {0x00a0, 0x00a0, 0xffff, 0xffff}},
  267. {"ncaron", {0x0148, 0xffff, 0xffff, 0xffff}},
  268. {"nine", {0x0039, 0x0039, 0x0039, 0x0039}},
  269. {"notequal", {0x2260, 0xffff, 0xffff, 173 }},
  270. {"nsuperior", {0x207f, 0xffff, 0xffff, 0xffff}},
  271. {"ntilde", {0x00f1, 0x00f1, 0xffff, 150 }},
  272. {"numbersign", {0x0023, 0x0023, 0x0023, 0x0023}},
  273. {"o", {0x006f, 0x006f, 0x006f, 0x006f}},
  274. {"oacute", {0x00f3, 0x00f3, 0xffff, 151 }},
  275. {"ocircumflex", {0x00f4, 0x00f4, 0xffff, 153 }},
  276. {"odblacute", {0x0151, 0xffff, 0xffff, 0xffff}},
  277. {"odieresis", {0x00f6, 0x00f6, 0xffff, 154 }},
  278. {"oe", {0x0153, 0x009c, 0x00fa, 207 }},
  279. {"ogonek", {0x02db, 0xffff, 0x00ce, 254 }},
  280. {"ograve", {0x00f2, 0x00f2, 0xffff, 152 }},
  281. {"ohm", {0x2126, 0xffff, 0xffff, 189 }},
  282. {"one", {0x0031, 0x0031, 0x0031, 0x0031}},
  283. {"onehalf", {0x00bd, 0x00bd, 0xffff, 0xffff}},
  284. {"onequarter", {0x00bc, 0x00bc, 0xffff, 0xffff}},
  285. {"onesuperior", {0x00b9, 0x00b9, 0xffff, 0xffff}},
  286. {"ordfeminine", {0x00aa, 0x00aa, 0x00e3, 187 }},
  287. {"ordmasculine", {0x00ba, 0x00ba, 0x00eb, 188 }},
  288. {"orthogonal", {0x221f, 0xffff, 0xffff, 0xffff}},
  289. {"oslash", {0x00f8, 0x00f8, 0x00f9, 191 }},
  290. {"otilde", {0x00f5, 0x00f5, 0xffff, 155 }},
  291. {"overscore", {0x00af, 0x00af, 0xffff, 0xffff}},
  292. {"p", {0x0070, 0x0070, 0x0070, 0x0070}},
  293. {"paragraph", {0x00b6, 0x00b6, 0x00b6, 166 }},
  294. {"parenleft", {0x0028, 0x0028, 0x0028, 0x0028}},
  295. {"parenright", {0x0029, 0x0029, 0x0029, 0x0029}},
  296. {"partialdiff", {0x2202, 0xffff, 0xffff, 182 }},
  297. {"percent", {0x0025, 0x0025, 0x0025, 0x0025}},
  298. {"period", {0x002e, 0x002e, 0x002e, 0x002e}},
  299. {"periodcentered",{0x2219, 0xffff, 0x00b4, 225 }},
  300. {"perthousand", {0x2030, 0x0089, 0x00bd, 228 }},
  301. {"peseta", {0x20a7, 0xffff, 0xffff, 0xffff}},
  302. {"phi", {0x03c6, 0xffff, 0xffff, 0xffff}},
  303. {"pi", {0x03c0, 0xffff, 0xffff, 185 }},
  304. {"plus", {0x002b, 0x002b, 0x002b, 0x002b}},
  305. {"plusminus", {0x00b1, 0x00b1, 0xffff, 177 }},
  306. {"product", {0x220f, 0xffff, 0xffff, 184 }},
  307. {"q", {0x0071, 0x0071, 0x0071, 0x0071}},
  308. {"question", {0x003f, 0x003f, 0x003f, 0x003f}},
  309. {"questiondown", {0x00bf, 0x00bf, 0x00bf, 192 }},
  310. {"quotedbl", {0x0022, 0x0022, 0x0022, 0x0022}},
  311. {"quotedblbase", {0x201e, 0x0084, 0x00b9, 227 }},
  312. {"quotedblleft", {0x201c, 0x0093, 0x00aa, 210 }},
  313. {"quotedblright", {0x201d, 0x0094, 0x00ba, 211 }},
  314. {"quoteleft", {0x2018, 0x0091, 0x0060, 212 }},
  315. {"quoteright", {0x2019, 0x0092, 0x0027, 213 }},
  316. {"quotesinglbase",{0x201a, 0x0082, 0x00b8, 226 }},
  317. {"quotesingle", {0x0027, 0x0027, 0x00a9, 0x0027}},
  318. {"r", {0x0072, 0x0072, 0x0072, 0x0072}},
  319. {"racute", {0x0155, 0xffff, 0xffff, 0xffff}},
  320. {"radical", {0x221a, 0xffff, 0xffff, 195 }},
  321. {"rcaron", {0x0159, 0xffff, 0xffff, 0xffff}},
  322. {"registered", {0x00ae, 0x00ae, 0xffff, 168 }},
  323. {"revlogicalnot", {0x2310, 0xffff, 0xffff, 0xffff}},
  324. {"ring", {0x02da, 0xffff, 0x00ca, 251 }},
  325. {"rtblock", {0x2590, 0xffff, 0xffff, 0xffff}},
  326. {"s", {0x0073, 0x0073, 0x0073, 0x0073}},
  327. {"sacute", {0x015b, 0xffff, 0xffff, 0xffff}},
  328. {"scaron", {0x0161, 0x009a, 0xffff, 0xffff}},
  329. {"scedilla", {0x015f, 0xffff, 0xffff, 0xffff}},
  330. {"section", {0x00a7, 0x00a7, 0x00a7, 164 }},
  331. {"semicolon", {0x003b, 0x003b, 0x003b, 0x003b}},
  332. {"seven", {0x0037, 0x0037, 0x0037, 0x0037}},
  333. {"sfthyphen", {0x00ad, 0x00ad, 0xffff, 0xffff}},
  334. {"shade", {0x2592, 0xffff, 0xffff, 0xffff}},
  335. {"sigma", {0x03c3, 0xffff, 0xffff, 0xffff}},
  336. {"six", {0x0036, 0x0036, 0x0036, 0x0036}},
  337. {"slash", {0x002f, 0x002f, 0x002f, 0x002f}},
  338. {"smileface", {0x263a, 0xffff, 0xffff, 0xffff}},
  339. {"space", {0x0020, 0x0020, 0x0020, 0x0020}},
  340. {"spade", {0x2660, 0xffff, 0xffff, 0xffff}},
  341. {"sterling", {0x00a3, 0x00a3, 0x00a3, 163 }},
  342. {"summation", {0x2211, 0xffff, 0xffff, 183 }},
  343. {"sun", {0x263c, 0xffff, 0xffff, 0xffff}},
  344. {"t", {0x0074, 0x0074, 0x0074, 0x0074}},
  345. {"tau", {0x03c4, 0xffff, 0xffff, 0xffff}},
  346. {"tcaron", {0x0165, 0xffff, 0xffff, 0xffff}},
  347. {"tcedilla", {0x0163, 0xffff, 0xffff, 0xffff}},
  348. {"thorn", {0x00fe, 0x00fe, 0xffff, 0xffff}},
  349. {"three", {0x0033, 0x0033, 0x0033, 0x0033}},
  350. {"threequarters", {0x00be, 0x00be, 0xffff, 0xffff}},
  351. {"threesuperior", {0x00b3, 0x00b3, 0xffff, 0xffff}},
  352. {"tilde", {0x02dc, 0x0098, 0x00c4, 245 }},
  353. {"trademark", {0x2122, 0x0099, 0xffff, 170 }},
  354. {"triagdn", {0x25bc, 0xffff, 0xffff, 0xffff}},
  355. {"triagrt", {0x25ba, 0xffff, 0xffff, 0xffff}},
  356. {"triagup", {0x25b2, 0xffff, 0xffff, 0xffff}},
  357. {"traglf", {0x25c4, 0xffff, 0xffff, 0xffff}},
  358. {"two", {0x0032, 0x0032, 0x0032, 0x0032}},
  359. {"twosuperior", {0x00b2, 0x00b2, 0xffff, 0xffff}},
  360. {"u", {0x0075, 0x0075, 0x0075, 0x0075}},
  361. {"uacute", {0x00fa, 0x00fa, 0xffff, 156 }},
  362. {"ucircumflex", {0x00fb, 0x00fb, 0xffff, 158 }},
  363. {"udblacute", {0x0171, 0xffff, 0xffff, 0xffff}},
  364. {"udieresis", {0x00fc, 0x00fc, 0xffff, 159 }},
  365. {"ugrave", {0x00f9, 0x00f9, 0xffff, 157 }},
  366. {"underscore", {0x005f, 0x005f, 0x005f, 0x005f}},
  367. {"underscoredbl", {0x2017, 0xffff, 0xffff, 0xffff}},
  368. {"upblock", {0x2580, 0xffff, 0xffff, 0xffff}},
  369. {"uring", {0x016f, 0xffff, 0xffff, 0xffff}},
  370. {"v", {0x0076, 0x0076, 0x0076, 0x0076}},
  371. {"w", {0x0077, 0x0077, 0x0077, 0x0077}},
  372. {"x", {0x0078, 0x0078, 0x0078, 0x0078}},
  373. {"y", {0x0079, 0x0079, 0x0079, 0x0079}},
  374. {"yacute", {0x00fd, 0x00fd, 0xffff, 0xffff}},
  375. {"ydieresis", {0x00ff, 0x00ff, 0xffff, 216 }},
  376. {"yen", {0x00a5, 0x00a5, 0x00a5, 180 }},
  377. {"z", {0x007a, 0x007a, 0x007a, 0x007a}},
  378. {"zacute", {0x017a, 0xffff, 0xffff, 0xffff}},
  379. {"zcaron", {0x017e, 0xffff, 0xffff, 0xffff}},
  380. {"zdot", {0x017c, 0xffff, 0xffff, 0xffff}},
  381. {"zero", {0x0030, 0x0030, 0x0030, 0x0030}},
  382. };
  383. static const struct encoding SeacEncoding[] = {
  384. {"A", {0xf041, 0x0041, 0x0041, 0x0041}},
  385. {"AE", {0xf0c6, 0x00c6, 0x00e1, 174 }},
  386. {"B", {0xf042, 0x0042, 0x0042, 0x0042}},
  387. {"C", {0xf043, 0x0043, 0x0043, 0x0043}},
  388. {"D", {0xf044, 0x0044, 0x0044, 0x0044}},
  389. {"E", {0xf045, 0x0045, 0x0045, 0x0045}},
  390. {"F", {0xf046, 0x0046, 0x0046, 0x0046}},
  391. {"G", {0xf047, 0x0047, 0x0047, 0x0047}},
  392. {"H", {0xf048, 0x0048, 0x0048, 0x0048}},
  393. {"I", {0xf049, 0x0049, 0x0049, 0x0049}},
  394. {"J", {0xf04a, 0x004a, 0x004a, 0x004a}},
  395. {"K", {0xf04b, 0x004b, 0x004b, 0x004b}},
  396. {"L", {0xf04c, 0x004c, 0x004c, 0x004c}},
  397. {"Lslash", {0xf141, 0xffff, 0x00e8, 0xffff}},
  398. {"M", {0xf04d, 0x004d, 0x004d, 0x004d}},
  399. {"N", {0xf04e, 0x004e, 0x004e, 0x004e}},
  400. {"O", {0xf04f, 0x004f, 0x004f, 0x004f}},
  401. {"OE", {0xf152, 0x008c, 0x00ea, 206 }},
  402. {"Oslash", {0xf0d8, 0x00d8, 0x00e9, 175 }},
  403. {"P", {0xf050, 0x0050, 0x0050, 0x0050}},
  404. {"Q", {0xf051, 0x0051, 0x0051, 0x0051}},
  405. {"R", {0xf052, 0x0052, 0x0052, 0x0052}},
  406. {"S", {0xf053, 0x0053, 0x0053, 0x0053}},
  407. {"T", {0xf054, 0x0054, 0x0054, 0x0054}},
  408. {"U", {0xf055, 0x0055, 0x0055, 0x0055}},
  409. {"V", {0xf056, 0x0056, 0x0056, 0x0056}},
  410. {"W", {0xf057, 0x0057, 0x0057, 0x0057}},
  411. {"X", {0xf058, 0x0058, 0x0058, 0x0058}},
  412. {"Y", {0xf059, 0x0059, 0x0059, 0x0059}},
  413. {"Z", {0xf05a, 0x005a, 0x005a, 0x005a}},
  414. {"a", {0xf061, 0x0061, 0x0061, 0x0061}},
  415. {"acute", {0xf0b4, 0x00b4, 0x00c2, 171 }},
  416. {"ae", {0xf0e6, 0x00e6, 0x00f1, 190 }},
  417. {"ampersand", {0xf026, 0x0026, 0x0026, 0x0026}},
  418. {"asciicircum", {0xf05e, 0x005e, 0x005e, 0x005e}},
  419. {"asciitilde", {0xf07e, 0x007e, 0x007e, 0x007e}},
  420. {"asterisk", {0xf02a, 0x002a, 0x002a, 0x002a}},
  421. {"at", {0xf040, 0x0040, 0x0040, 0x0040}},
  422. {"b", {0xf062, 0x0062, 0x0062, 0x0062}},
  423. {"backslash", {0xf05c, 0x005c, 0x005c, 0x005c}},
  424. {"bar", {0xf07c, 0x007c, 0x007c, 0x007c}},
  425. {"braceleft", {0xf07b, 0x007b, 0x007b, 0x007b}},
  426. {"braceright", {0xf07d, 0x007d, 0x007d, 0x007d}},
  427. {"bracketleft", {0xf05b, 0x005b, 0x005b, 0x005b}},
  428. {"bracketright", {0xf05d, 0x005d, 0x005d, 0x005d}},
  429. {"breve", {0xf2d8, 0xffff, 0x00c6, 249 }},
  430. {"bullet", {0x2022, 0x0095, 0x00b7, 165 }},
  431. {"c", {0xf063, 0x0063, 0x0063, 0x0063}},
  432. {"caron", {0xf2c7, 0xffff, 0x00cf, 255 }},
  433. {"cedilla", {0xf0b8, 0x00b8, 0x00cb, 252 }},
  434. {"cent", {0xf0a2, 0x00a2, 0x00a2, 162 }},
  435. {"circumflex", {0xf2c6, 0x0088, 0x00c3, 246 }},
  436. {"colon", {0xf03a, 0x003a, 0x003a, 0x003a}},
  437. {"comma", {0xf02c, 0x002c, 0x002c, 0x002c}},
  438. {"currency", {0xf0a4, 0x00a4, 0x00a8, 219 }},
  439. {"d", {0xf064, 0x0064, 0x0064, 0x0064}},
  440. {"dagger", {0x2020, 0x0086, 0x00b2, 160 }},
  441. {"daggerdbl", {0x2021, 0x0087, 0x00b3, 224 }},
  442. {"dieresis", {0xf0a8, 0x00a8, 0x00c8, 172 }},
  443. {"dollar", {0xf024, 0x0024, 0x0024, 0x0024}},
  444. {"dotaccent", {0xf2d9, 0xffff, 0x00c7, 250 }},
  445. {"dotlessi", {0xf131, 0xffff, 0x00f5, 245 }},
  446. {"e", {0xf065, 0x0065, 0x0065, 0x0065}},
  447. {"eight", {0xf038, 0x0038, 0x0038, 0x0038}},
  448. {"ellipsis", {0x2026, 0x0085, 0x00bc, 201 }},
  449. {"emdash", {0x2014, 0x0097, 0x00d0, 209 }},
  450. {"endash", {0x2013, 0x0096, 0x00b1, 208 }},
  451. {"equal", {0xf03d, 0x003d, 0x003d, 0x003d}},
  452. {"exclam", {0xf021, 0x0021, 0x0021, 0x0021}},
  453. {"exclamdown", {0xf0a1, 0x00a1, 0x00a1, 193 }},
  454. {"f", {0xf066, 0x0066, 0x0066, 0x0066}},
  455. {"fi", {0xf001, 0xffff, 0x00ae, 222 }},
  456. {"five", {0xf035, 0x0035, 0x0035, 0x0035}},
  457. {"fl", {0xf002, 0xffff, 0x00af, 223 }},
  458. {"florin", {0xf192, 0x0083, 0x00a6, 196 }},
  459. {"four", {0xf034, 0x0034, 0x0034, 0x0034}},
  460. {"fraction", {0x2215, 0xffff, 0x00a4, 218 }},
  461. {"g", {0xf067, 0x0067, 0x0067, 0x0067}},
  462. {"germandbls", {0xf0df, 0x00df, 0x00fb, 167 }},
  463. {"grave", {0xf060, 0x0060, 0x00c1, 0x0060}},
  464. {"greater", {0xf03e, 0x003e, 0x003e, 0x003e}},
  465. {"guillemotleft", {0xf0ab, 0x00ab, 0x00ab, 199 }},
  466. {"guillemotright",{0xf0bb, 0x00bb, 0x00bb, 200 }},
  467. {"guilsinglleft", {0x2039, 0x008b, 0x00ac, 220 }},
  468. {"guilsinglright",{0x203a, 0x009b, 0x00ad, 221 }},
  469. {"h", {0xf068, 0x0068, 0x0068, 0x0068}},
  470. {"hungarumlaut", {0xf2dd, 0xffff, 0x00cd, 0xffff}},
  471. {"hyphen", {0xf02d, 0x002d, 0x002d, 0x002d}},
  472. {"i", {0xf069, 0x0069, 0x0069, 0x0069}},
  473. {"j", {0xf06a, 0x006a, 0x006a, 0x006a}},
  474. {"k", {0xf06b, 0x006b, 0x006b, 0x006b}},
  475. {"l", {0xf06c, 0x006c, 0x006c, 0x006c}},
  476. {"less", {0xf03c, 0x003c, 0x003c, 0x003c}},
  477. {"lslash", {0xf142, 0xffff, 0x00f8, 0xffff}},
  478. {"m", {0xf06d, 0x006d, 0x006d, 0x006d}},
  479. {"macron", {0xf0af, 0xffff, 0x00c5, 248 }},
  480. {"n", {0xf06e, 0x006e, 0x006e, 0x006e}},
  481. {"nine", {0xf039, 0x0039, 0x0039, 0x0039}},
  482. {"numbersign", {0xf023, 0x0023, 0x0023, 0x0023}},
  483. {"o", {0xf06f, 0x006f, 0x006f, 0x006f}},
  484. {"oe", {0xf153, 0x009c, 0x00fa, 207 }},
  485. {"ogonek", {0xf2db, 0xffff, 0x00ce, 254 }},
  486. {"one", {0xf031, 0x0031, 0x0031, 0x0031}},
  487. {"ordfeminine", {0xf0aa, 0x00aa, 0x00e3, 187 }},
  488. {"ordmasculine", {0xf0ba, 0x00ba, 0x00eb, 188 }},
  489. {"oslash", {0xf0f8, 0x00f8, 0x00f9, 191 }},
  490. {"p", {0xf070, 0x0070, 0x0070, 0x0070}},
  491. {"paragraph", {0xf0b6, 0x00b6, 0x00b6, 166 }},
  492. {"parenleft", {0xf028, 0x0028, 0x0028, 0x0028}},
  493. {"parenright", {0xf029, 0x0029, 0x0029, 0x0029}},
  494. {"percent", {0xf025, 0x0025, 0x0025, 0x0025}},
  495. {"period", {0xf02e, 0x002e, 0x002e, 0x002e}},
  496. {"periodcentered",{0x2219, 0xffff, 0x00b4, 225 }},
  497. {"perthousand", {0x2030, 0x0089, 0x00bd, 228 }},
  498. {"plus", {0xf02b, 0x002b, 0x002b, 0x002b}},
  499. {"q", {0xf071, 0x0071, 0x0071, 0x0071}},
  500. {"question", {0xf03f, 0x003f, 0x003f, 0x003f}},
  501. {"questiondown", {0xf0bf, 0x00bf, 0x00bf, 192 }},
  502. {"quotedbl", {0xf022, 0x0022, 0x0022, 0x0022}},
  503. {"quotedblbase", {0x201e, 0x0084, 0x00b9, 227 }},
  504. {"quotedblleft", {0x201c, 0x0093, 0x00aa, 210 }},
  505. {"quotedblright", {0x201d, 0x0094, 0x00ba, 211 }},
  506. {"quoteleft", {0x2018, 0x0091, 0x0060, 212 }},
  507. {"quoteright", {0x2019, 0x0092, 0x0027, 213 }},
  508. {"quotesinglbase",{0x201a, 0x0082, 0x00b8, 226 }},
  509. {"quotesingle", {0xf027, 0x0027, 0x00a9, 0x0027}},
  510. {"r", {0xf072, 0x0072, 0x0072, 0x0072}},
  511. {"ring", {0xf2da, 0xffff, 0x00ca, 251 }},
  512. {"s", {0xf073, 0x0073, 0x0073, 0x0073}},
  513. {"section", {0xf0a7, 0x00a7, 0x00a7, 164 }},
  514. {"semicolon", {0xf03b, 0x003b, 0x003b, 0x003b}},
  515. {"seven", {0xf037, 0x0037, 0x0037, 0x0037}},
  516. {"six", {0xf036, 0x0036, 0x0036, 0x0036}},
  517. {"slash", {0xf02f, 0x002f, 0x002f, 0x002f}},
  518. {"space", {0xf020, 0x0020, 0x0020, 0x0020}},
  519. {"sterling", {0xf0a3, 0x00a3, 0x00a3, 163 }},
  520. {"t", {0xf074, 0x0074, 0x0074, 0x0074}},
  521. {"three", {0xf033, 0x0033, 0x0033, 0x0033}},
  522. {"tilde", {0xf2dc, 0x0098, 0x00c4, 245 }},
  523. {"two", {0xf032, 0x0032, 0x0032, 0x0032}},
  524. {"u", {0xf075, 0x0075, 0x0075, 0x0075}},
  525. {"underscore", {0xf05f, 0x005f, 0x005f, 0x005f}},
  526. {"v", {0xf076, 0x0076, 0x0076, 0x0076}},
  527. {"w", {0xf077, 0x0077, 0x0077, 0x0077}},
  528. {"x", {0xf078, 0x0078, 0x0078, 0x0078}},
  529. {"y", {0xf079, 0x0079, 0x0079, 0x0079}},
  530. {"yen", {0xf0a5, 0x00a5, 0x00a5, 180 }},
  531. {"z", {0xf07a, 0x007a, 0x007a, 0x007a}},
  532. {"zero", {0xf030, 0x0030, 0x0030, 0x0030}},
  533. };
  534. /***** MACROS */
  535. /*-none-*/
  536. /***** STATIC FUNCTIONS */
  537. /*-none-*/
  538. /***** FUNCTIONS */
  539. /***
  540. ** Function: AllocEncodingTable
  541. **
  542. ** Description:
  543. ** Create a new encoding ADT.
  544. ***/
  545. struct encoding *AllocEncodingTable(const USHORT num)
  546. {
  547. struct encoding *enc;
  548. if ((enc = Malloc(sizeof(struct encoding)*num))!=NULL)
  549. memset(enc, NOTDEFINIT, sizeof(struct encoding)*num);
  550. return enc;
  551. }
  552. /***
  553. ** Function: RehashEncodingTable
  554. **
  555. ** Description:
  556. ** Prepare an encoding ADT so that entries can be
  557. ** located in it.
  558. ***/
  559. void RehashEncodingTable(struct encoding *Encoding, const USHORT num)
  560. {
  561. USHORT i;
  562. short j;
  563. struct encoding entry;
  564. for (i=1; i<num; i++) {
  565. j=(short)(i-1);
  566. entry = Encoding[i];
  567. while(j>=0 && strcmp(Encoding[j].name, entry.name)>0) {
  568. memcpy(&Encoding[j+1], &Encoding[j], sizeof(struct encoding));
  569. j--;
  570. }
  571. Encoding[j+1] = entry;
  572. }
  573. }
  574. /***
  575. ** Function: SetEncodingEntry
  576. **
  577. ** Description:
  578. ** Set the mapping from a glyph name to character
  579. ** codes for various platforms.
  580. ***/
  581. void SetEncodingEntry(struct encoding *Encoding,
  582. const USHORT entry,
  583. const char *name,
  584. const USHORT num,
  585. const USHORT *codes)
  586. {
  587. USHORT i;
  588. Encoding[entry].name = name;
  589. for (i=0; i<num; i++) {
  590. Encoding[entry].codes[i] = codes[i];
  591. }
  592. }
  593. static int CDECL compare(const void *arg1, const void *arg2)
  594. {
  595. return strcmp( *((const char **)arg1),
  596. ((const struct encoding *)arg2)->name );
  597. }
  598. /***
  599. ** Function: LookupPSName
  600. **
  601. ** Description:
  602. ** Do a binary search for a postscript name, and return
  603. ** a handle that can be used to look up a the character
  604. ** code for a specific encoding schema.
  605. **
  606. ** If a custom encoding array is used and a glyph is not
  607. ** encoded by that array, though it is recognized by the
  608. ** StandardEncoding array, then use the SeacEncoding.
  609. ** This is needed in order to support bogus "seac" calls.
  610. ***/
  611. struct encoding *LookupPSName(const struct encoding *Encoding,
  612. USHORT size,
  613. const char *name)
  614. {
  615. #ifndef BSEARCH
  616. struct encoding *result;
  617. #else
  618. USHORT low, mid, high;
  619. short diff;
  620. /* Initiate. */
  621. low = 0;
  622. high = size;
  623. #endif
  624. /* Use default encoding? */
  625. if (Encoding==NULL) {
  626. Encoding = StdEncoding;
  627. size = sizeof(StdEncoding)/sizeof(StdEncoding[0]);
  628. }
  629. #ifndef BSEARCH
  630. result = (struct encoding *)bsearch((char *)&name,
  631. (char *)Encoding, size,
  632. sizeof(struct encoding),
  633. compare);
  634. #else
  635. do {
  636. mid = (low+high)>>1;
  637. diff = (short)strcmp(Encoding[mid].name, name);
  638. if (diff>0) {
  639. high = (low+high)>>1;
  640. } else if (diff<0) {
  641. low = (short)((low+high+1)>>1);
  642. } else if (diff==0) {
  643. result = &Encoding[mid];
  644. }
  645. } while (low<high && result==NULL);
  646. #endif
  647. if ((result==NULL) &&
  648. (Encoding!=SeacEncoding) &&
  649. (Encoding!=StdEncoding))
  650. result = LookupPSName(SeacEncoding,
  651. sizeof(SeacEncoding)/sizeof(SeacEncoding[0]),
  652. name);
  653. return result;
  654. }
  655. /***
  656. ** Function: LookupCharCode
  657. **
  658. ** Description:
  659. ** look up a the character code for a
  660. ** specific encoding scheme.
  661. ***/
  662. USHORT LookupCharCode(const struct encoding *enc, const USHORT type)
  663. {
  664. USHORT code = 0;
  665. if (enc)
  666. code = enc->codes[type];
  667. return code;
  668. }
  669. /***
  670. ** Function: LookupCharName
  671. **
  672. ** Description:
  673. ** look up a the character name for a
  674. ** specific encoding scheme.
  675. ***/
  676. const char *LookupCharName(const struct encoding *enc)
  677. {
  678. return enc->name;
  679. }
  680. /***
  681. ** Function: LookupNotDef
  682. **
  683. ** Description:
  684. ** look up a the .notdef character
  685. ***/
  686. const struct encoding *LookupNotDef(void)
  687. {
  688. return &StdEncoding[0];
  689. }
  690. /***
  691. ** Function: DecodeChar
  692. **
  693. ** Description:
  694. ** look up an encoding record for a character code in some
  695. ** known encoding.
  696. ***/
  697. const struct encoding *DecodeChar(const struct encoding *Encoding,
  698. const USHORT max,
  699. const USHORT type,
  700. const USHORT code)
  701. {
  702. const struct encoding *enc = &StdEncoding[0];
  703. USHORT i, high;
  704. /* Use default encoding? */
  705. if (Encoding==NULL) {
  706. Encoding = StdEncoding;
  707. high = sizeof(StdEncoding)/sizeof(StdEncoding[0]);
  708. } else {
  709. high = max;
  710. }
  711. for (i=0; i<high; i++) {
  712. if (Encoding[i].codes[type]==code) {
  713. enc = &Encoding[i];
  714. break;
  715. }
  716. }
  717. return enc;
  718. }
  719. /***
  720. ** Function: FreeEncoding
  721. **
  722. ** Description:
  723. ** Deallocate memory associated to the encoding array.
  724. ***/
  725. void FreeEncoding(struct encoding *enc, const USHORT size)
  726. {
  727. USHORT i;
  728. if (enc) {
  729. for (i=0; i<size; i++) {
  730. if (enc[i].name)
  731. Free((char *)enc[i].name);
  732. }
  733. Free(enc);
  734. }
  735. }
  736. /***
  737. ** Function: LookupFirstEnc
  738. **
  739. ** Description:
  740. ** Locate the first encoding for a given glyph.
  741. ***/
  742. const struct encoding *LookupFirstEnc(
  743. const struct encoding *encRoot,
  744. const int encSize,
  745. const struct encoding *encItem
  746. )
  747. {
  748. /* Back up to the first item with the same glyph name. */
  749. while (encItem>encRoot && !strcmp(encItem[-1].name, encItem[0].name))
  750. encItem--;
  751. return encItem;
  752. }
  753. /***
  754. ** Function: LookupNextEnc
  755. **
  756. ** Description:
  757. ** Locate the first encoding for a given glyph.
  758. ***/
  759. const struct encoding *LookupNextEnc(
  760. const struct encoding *encRoot,
  761. const int encSize,
  762. const struct encoding *encItem
  763. )
  764. {
  765. /* Back up to the first item with the same glyph name. */
  766. if (encItem<(&encRoot[encSize-1]) &&
  767. !strcmp(encItem[0].name, encItem[1].name))
  768. return ++encItem;
  769. return NULL;
  770. }