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.

465 lines
26 KiB

11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Pdf
  17. * @subpackage Fonts
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /** Internally used classes */
  23. // require_once 'Zend/Pdf/Element/Name.php';
  24. /** Zend_Pdf_Resource_Font_Simple_Standard */
  25. // require_once 'Zend/Pdf/Resource/Font/Simple/Standard.php';
  26. /**
  27. * Implementation for the standard PDF font Symbol.
  28. *
  29. * This class was generated automatically using the font information and metric
  30. * data contained in the Adobe Font Metric (AFM) files, available here:
  31. * {@link http://partners.adobe.com/public/developer/en/pdf/Core14_AFMs.zip}
  32. *
  33. * The PHP script used to generate this class can be found in the /tools
  34. * directory of the framework distribution. If you need to make modifications to
  35. * this class, chances are the same modifications are needed for the rest of the
  36. * standard fonts. You should modify the script and regenerate the classes
  37. * instead of changing this class file by hand.
  38. *
  39. * @package Zend_Pdf
  40. * @subpackage Fonts
  41. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  42. * @license http://framework.zend.com/license/new-bsd New BSD License
  43. */
  44. class Zend_Pdf_Resource_Font_Simple_Standard_Symbol extends Zend_Pdf_Resource_Font_Simple_Standard
  45. {
  46. /**** Instance Variables ****/
  47. /**
  48. * Array for conversion from local encoding to special font encoding.
  49. * See {@link encodeString()}.
  50. * @var array
  51. */
  52. protected $_toFontEncoding = array(
  53. 0x20 => "\x20", 0x21 => "\x21", 0x2200 => "\x22", 0x23 => "\x23",
  54. 0x2203 => "\x24", 0x25 => "\x25", 0x26 => "\x26", 0x220b => "\x27",
  55. 0x28 => "\x28", 0x29 => "\x29", 0x2217 => "\x2a", 0x2b => "\x2b",
  56. 0x2c => "\x2c", 0x2212 => "\x2d", 0x2e => "\x2e", 0x2f => "\x2f",
  57. 0x30 => "\x30", 0x31 => "\x31", 0x32 => "\x32", 0x33 => "\x33",
  58. 0x34 => "\x34", 0x35 => "\x35", 0x36 => "\x36", 0x37 => "\x37",
  59. 0x38 => "\x38", 0x39 => "\x39", 0x3a => "\x3a", 0x3b => "\x3b",
  60. 0x3c => "\x3c", 0x3d => "\x3d", 0x3e => "\x3e", 0x3f => "\x3f",
  61. 0x2245 => "\x40", 0x0391 => "\x41", 0x0392 => "\x42", 0x03a7 => "\x43",
  62. 0x2206 => "\x44", 0x0395 => "\x45", 0x03a6 => "\x46", 0x0393 => "\x47",
  63. 0x0397 => "\x48", 0x0399 => "\x49", 0x03d1 => "\x4a", 0x039a => "\x4b",
  64. 0x039b => "\x4c", 0x039c => "\x4d", 0x039d => "\x4e", 0x039f => "\x4f",
  65. 0x03a0 => "\x50", 0x0398 => "\x51", 0x03a1 => "\x52", 0x03a3 => "\x53",
  66. 0x03a4 => "\x54", 0x03a5 => "\x55", 0x03c2 => "\x56", 0x2126 => "\x57",
  67. 0x039e => "\x58", 0x03a8 => "\x59", 0x0396 => "\x5a", 0x5b => "\x5b",
  68. 0x2234 => "\x5c", 0x5d => "\x5d", 0x22a5 => "\x5e", 0x5f => "\x5f",
  69. 0xf8e5 => "\x60", 0x03b1 => "\x61", 0x03b2 => "\x62", 0x03c7 => "\x63",
  70. 0x03b4 => "\x64", 0x03b5 => "\x65", 0x03c6 => "\x66", 0x03b3 => "\x67",
  71. 0x03b7 => "\x68", 0x03b9 => "\x69", 0x03d5 => "\x6a", 0x03ba => "\x6b",
  72. 0x03bb => "\x6c", 0xb5 => "\x6d", 0x03bd => "\x6e", 0x03bf => "\x6f",
  73. 0x03c0 => "\x70", 0x03b8 => "\x71", 0x03c1 => "\x72", 0x03c3 => "\x73",
  74. 0x03c4 => "\x74", 0x03c5 => "\x75", 0x03d6 => "\x76", 0x03c9 => "\x77",
  75. 0x03be => "\x78", 0x03c8 => "\x79", 0x03b6 => "\x7a", 0x7b => "\x7b",
  76. 0x7c => "\x7c", 0x7d => "\x7d", 0x223c => "\x7e", 0x20ac => "\xa0",
  77. 0x03d2 => "\xa1", 0x2032 => "\xa2", 0x2264 => "\xa3", 0x2044 => "\xa4",
  78. 0x221e => "\xa5", 0x0192 => "\xa6", 0x2663 => "\xa7", 0x2666 => "\xa8",
  79. 0x2665 => "\xa9", 0x2660 => "\xaa", 0x2194 => "\xab", 0x2190 => "\xac",
  80. 0x2191 => "\xad", 0x2192 => "\xae", 0x2193 => "\xaf", 0xb0 => "\xb0",
  81. 0xb1 => "\xb1", 0x2033 => "\xb2", 0x2265 => "\xb3", 0xd7 => "\xb4",
  82. 0x221d => "\xb5", 0x2202 => "\xb6", 0x2022 => "\xb7", 0xf7 => "\xb8",
  83. 0x2260 => "\xb9", 0x2261 => "\xba", 0x2248 => "\xbb", 0x2026 => "\xbc",
  84. 0xf8e6 => "\xbd", 0xf8e7 => "\xbe", 0x21b5 => "\xbf", 0x2135 => "\xc0",
  85. 0x2111 => "\xc1", 0x211c => "\xc2", 0x2118 => "\xc3", 0x2297 => "\xc4",
  86. 0x2295 => "\xc5", 0x2205 => "\xc6", 0x2229 => "\xc7", 0x222a => "\xc8",
  87. 0x2283 => "\xc9", 0x2287 => "\xca", 0x2284 => "\xcb", 0x2282 => "\xcc",
  88. 0x2286 => "\xcd", 0x2208 => "\xce", 0x2209 => "\xcf", 0x2220 => "\xd0",
  89. 0x2207 => "\xd1", 0xf6da => "\xd2", 0xf6d9 => "\xd3", 0xf6db => "\xd4",
  90. 0x220f => "\xd5", 0x221a => "\xd6", 0x22c5 => "\xd7", 0xac => "\xd8",
  91. 0x2227 => "\xd9", 0x2228 => "\xda", 0x21d4 => "\xdb", 0x21d0 => "\xdc",
  92. 0x21d1 => "\xdd", 0x21d2 => "\xde", 0x21d3 => "\xdf", 0x25ca => "\xe0",
  93. 0x2329 => "\xe1", 0xf8e8 => "\xe2", 0xf8e9 => "\xe3", 0xf8ea => "\xe4",
  94. 0x2211 => "\xe5", 0xf8eb => "\xe6", 0xf8ec => "\xe7", 0xf8ed => "\xe8",
  95. 0xf8ee => "\xe9", 0xf8ef => "\xea", 0xf8f0 => "\xeb", 0xf8f1 => "\xec",
  96. 0xf8f2 => "\xed", 0xf8f3 => "\xee", 0xf8f4 => "\xef", 0x232a => "\xf1",
  97. 0x222b => "\xf2", 0x2320 => "\xf3", 0xf8f5 => "\xf4", 0x2321 => "\xf5",
  98. 0xf8f6 => "\xf6", 0xf8f7 => "\xf7", 0xf8f8 => "\xf8", 0xf8f9 => "\xf9",
  99. 0xf8fa => "\xfa", 0xf8fb => "\xfb", 0xf8fc => "\xfc", 0xf8fd => "\xfd",
  100. 0xf8fe => "\xfe");
  101. /**
  102. * Array for conversion from special font encoding to local encoding.
  103. * See {@link decodeString()}.
  104. * @var array
  105. */
  106. protected $_fromFontEncoding = array(
  107. 0x20 => "\x00\x20", 0x21 => "\x00\x21", 0x22 => "\x22\x00",
  108. 0x23 => "\x00\x23", 0x24 => "\x22\x03", 0x25 => "\x00\x25",
  109. 0x26 => "\x00\x26", 0x27 => "\x22\x0b", 0x28 => "\x00\x28",
  110. 0x29 => "\x00\x29", 0x2a => "\x22\x17", 0x2b => "\x00\x2b",
  111. 0x2c => "\x00\x2c", 0x2d => "\x22\x12", 0x2e => "\x00\x2e",
  112. 0x2f => "\x00\x2f", 0x30 => "\x00\x30", 0x31 => "\x00\x31",
  113. 0x32 => "\x00\x32", 0x33 => "\x00\x33", 0x34 => "\x00\x34",
  114. 0x35 => "\x00\x35", 0x36 => "\x00\x36", 0x37 => "\x00\x37",
  115. 0x38 => "\x00\x38", 0x39 => "\x00\x39", 0x3a => "\x00\x3a",
  116. 0x3b => "\x00\x3b", 0x3c => "\x00\x3c", 0x3d => "\x00\x3d",
  117. 0x3e => "\x00\x3e", 0x3f => "\x00\x3f", 0x40 => "\x22\x45",
  118. 0x41 => "\x03\x91", 0x42 => "\x03\x92", 0x43 => "\x03\xa7",
  119. 0x44 => "\x22\x06", 0x45 => "\x03\x95", 0x46 => "\x03\xa6",
  120. 0x47 => "\x03\x93", 0x48 => "\x03\x97", 0x49 => "\x03\x99",
  121. 0x4a => "\x03\xd1", 0x4b => "\x03\x9a", 0x4c => "\x03\x9b",
  122. 0x4d => "\x03\x9c", 0x4e => "\x03\x9d", 0x4f => "\x03\x9f",
  123. 0x50 => "\x03\xa0", 0x51 => "\x03\x98", 0x52 => "\x03\xa1",
  124. 0x53 => "\x03\xa3", 0x54 => "\x03\xa4", 0x55 => "\x03\xa5",
  125. 0x56 => "\x03\xc2", 0x57 => "\x21\x26", 0x58 => "\x03\x9e",
  126. 0x59 => "\x03\xa8", 0x5a => "\x03\x96", 0x5b => "\x00\x5b",
  127. 0x5c => "\x22\x34", 0x5d => "\x00\x5d", 0x5e => "\x22\xa5",
  128. 0x5f => "\x00\x5f", 0x60 => "\xf8\xe5", 0x61 => "\x03\xb1",
  129. 0x62 => "\x03\xb2", 0x63 => "\x03\xc7", 0x64 => "\x03\xb4",
  130. 0x65 => "\x03\xb5", 0x66 => "\x03\xc6", 0x67 => "\x03\xb3",
  131. 0x68 => "\x03\xb7", 0x69 => "\x03\xb9", 0x6a => "\x03\xd5",
  132. 0x6b => "\x03\xba", 0x6c => "\x03\xbb", 0x6d => "\x00\xb5",
  133. 0x6e => "\x03\xbd", 0x6f => "\x03\xbf", 0x70 => "\x03\xc0",
  134. 0x71 => "\x03\xb8", 0x72 => "\x03\xc1", 0x73 => "\x03\xc3",
  135. 0x74 => "\x03\xc4", 0x75 => "\x03\xc5", 0x76 => "\x03\xd6",
  136. 0x77 => "\x03\xc9", 0x78 => "\x03\xbe", 0x79 => "\x03\xc8",
  137. 0x7a => "\x03\xb6", 0x7b => "\x00\x7b", 0x7c => "\x00\x7c",
  138. 0x7d => "\x00\x7d", 0x7e => "\x22\x3c", 0xa0 => "\x20\xac",
  139. 0xa1 => "\x03\xd2", 0xa2 => "\x20\x32", 0xa3 => "\x22\x64",
  140. 0xa4 => "\x20\x44", 0xa5 => "\x22\x1e", 0xa6 => "\x01\x92",
  141. 0xa7 => "\x26\x63", 0xa8 => "\x26\x66", 0xa9 => "\x26\x65",
  142. 0xaa => "\x26\x60", 0xab => "\x21\x94", 0xac => "\x21\x90",
  143. 0xad => "\x21\x91", 0xae => "\x21\x92", 0xaf => "\x21\x93",
  144. 0xb0 => "\x00\xb0", 0xb1 => "\x00\xb1", 0xb2 => "\x20\x33",
  145. 0xb3 => "\x22\x65", 0xb4 => "\x00\xd7", 0xb5 => "\x22\x1d",
  146. 0xb6 => "\x22\x02", 0xb7 => "\x20\x22", 0xb8 => "\x00\xf7",
  147. 0xb9 => "\x22\x60", 0xba => "\x22\x61", 0xbb => "\x22\x48",
  148. 0xbc => "\x20\x26", 0xbd => "\xf8\xe6", 0xbe => "\xf8\xe7",
  149. 0xbf => "\x21\xb5", 0xc0 => "\x21\x35", 0xc1 => "\x21\x11",
  150. 0xc2 => "\x21\x1c", 0xc3 => "\x21\x18", 0xc4 => "\x22\x97",
  151. 0xc5 => "\x22\x95", 0xc6 => "\x22\x05", 0xc7 => "\x22\x29",
  152. 0xc8 => "\x22\x2a", 0xc9 => "\x22\x83", 0xca => "\x22\x87",
  153. 0xcb => "\x22\x84", 0xcc => "\x22\x82", 0xcd => "\x22\x86",
  154. 0xce => "\x22\x08", 0xcf => "\x22\x09", 0xd0 => "\x22\x20",
  155. 0xd1 => "\x22\x07", 0xd2 => "\xf6\xda", 0xd3 => "\xf6\xd9",
  156. 0xd4 => "\xf6\xdb", 0xd5 => "\x22\x0f", 0xd6 => "\x22\x1a",
  157. 0xd7 => "\x22\xc5", 0xd8 => "\x00\xac", 0xd9 => "\x22\x27",
  158. 0xda => "\x22\x28", 0xdb => "\x21\xd4", 0xdc => "\x21\xd0",
  159. 0xdd => "\x21\xd1", 0xde => "\x21\xd2", 0xdf => "\x21\xd3",
  160. 0xe0 => "\x25\xca", 0xe1 => "\x23\x29", 0xe2 => "\xf8\xe8",
  161. 0xe3 => "\xf8\xe9", 0xe4 => "\xf8\xea", 0xe5 => "\x22\x11",
  162. 0xe6 => "\xf8\xeb", 0xe7 => "\xf8\xec", 0xe8 => "\xf8\xed",
  163. 0xe9 => "\xf8\xee", 0xea => "\xf8\xef", 0xeb => "\xf8\xf0",
  164. 0xec => "\xf8\xf1", 0xed => "\xf8\xf2", 0xee => "\xf8\xf3",
  165. 0xef => "\xf8\xf4", 0xf1 => "\x23\x2a", 0xf2 => "\x22\x2b",
  166. 0xf3 => "\x23\x20", 0xf4 => "\xf8\xf5", 0xf5 => "\x23\x21",
  167. 0xf6 => "\xf8\xf6", 0xf7 => "\xf8\xf7", 0xf8 => "\xf8\xf8",
  168. 0xf9 => "\xf8\xf9", 0xfa => "\xf8\xfa", 0xfb => "\xf8\xfb",
  169. 0xfc => "\xf8\xfc", 0xfd => "\xf8\xfd", 0xfe => "\xf8\xfe",
  170. );
  171. /**** Public Interface ****/
  172. /* Object Lifecycle */
  173. /**
  174. * Object constructor
  175. */
  176. public function __construct()
  177. {
  178. parent::__construct();
  179. /* Object properties */
  180. /* The font names are stored internally as Unicode UTF-16BE-encoded
  181. * strings. Since this information is static, save unnecessary trips
  182. * through iconv() and just use pre-encoded hexidecimal strings.
  183. */
  184. $this->_fontNames[Zend_Pdf_Font::NAME_COPYRIGHT]['en'] =
  185. "\x00\x43\x00\x6f\x00\x70\x00\x79\x00\x72\x00\x69\x00\x67\x00\x68\x00"
  186. . "\x74\x00\x20\x00\x28\x00\x63\x00\x29\x00\x20\x00\x31\x00\x39\x00"
  187. . "\x38\x00\x35\x00\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x37\x00"
  188. . "\x2c\x00\x20\x00\x31\x00\x39\x00\x38\x00\x39\x00\x2c\x00\x20\x00"
  189. . "\x31\x00\x39\x00\x39\x00\x30\x00\x2c\x00\x20\x00\x31\x00\x39\x00"
  190. . "\x39\x00\x37\x00\x20\x00\x41\x00\x64\x00\x6f\x00\x62\x00\x65\x00"
  191. . "\x20\x00\x53\x00\x79\x00\x73\x00\x74\x00\x65\x00\x6d\x00\x73\x00"
  192. . "\x20\x00\x49\x00\x6e\x00\x63\x00\x6f\x00\x72\x00\x70\x00\x6f\x00"
  193. . "\x72\x00\x61\x00\x74\x00\x65\x00\x64\x00\x2e\x00\x20\x00\x41\x00"
  194. . "\x6c\x00\x6c\x00\x20\x00\x72\x00\x69\x00\x67\x00\x68\x00\x74\x00"
  195. . "\x73\x00\x20\x00\x72\x00\x65\x00\x73\x00\x65\x00\x72\x00\x76\x00"
  196. . "\x65\x00\x64\x00\x2e";
  197. $this->_fontNames[Zend_Pdf_Font::NAME_FAMILY]['en'] =
  198. "\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c";
  199. $this->_fontNames[Zend_Pdf_Font::NAME_STYLE]['en'] =
  200. "\x00\x4d\x00\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
  201. $this->_fontNames[Zend_Pdf_Font::NAME_ID]['en'] =
  202. "\x00\x34\x00\x33\x00\x30\x00\x36\x00\x34";
  203. $this->_fontNames[Zend_Pdf_Font::NAME_FULL]['en'] =
  204. "\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c\x00\x20\x00\x4d\x00"
  205. . "\x65\x00\x64\x00\x69\x00\x75\x00\x6d";
  206. $this->_fontNames[Zend_Pdf_Font::NAME_VERSION]['en'] =
  207. "\x00\x30\x00\x30\x00\x31\x00\x2e\x00\x30\x00\x30\x00\x38";
  208. $this->_fontNames[Zend_Pdf_Font::NAME_POSTSCRIPT]['en'] =
  209. "\x00\x53\x00\x79\x00\x6d\x00\x62\x00\x6f\x00\x6c";
  210. $this->_isBold = false;
  211. $this->_isItalic = false;
  212. $this->_isMonospaced = false;
  213. $this->_underlinePosition = -100;
  214. $this->_underlineThickness = 50;
  215. $this->_strikePosition = 225;
  216. $this->_strikeThickness = 50;
  217. $this->_unitsPerEm = 1000;
  218. $this->_ascent = 1000;
  219. $this->_descent = 0;
  220. $this->_lineGap = 200;
  221. /* The glyph numbers assigned here are synthetic; they do not match the
  222. * actual glyph numbers used by the font. This is not a big deal though
  223. * since this data never makes it to the PDF file. It is only used
  224. * internally for layout calculations.
  225. */
  226. $this->_glyphWidths = array(
  227. 0x00 => 0x01f4, 0x01 => 0xfa, 0x02 => 0x014d, 0x03 => 0x02c9,
  228. 0x04 => 0x01f4, 0x05 => 0x0225, 0x06 => 0x0341, 0x07 => 0x030a,
  229. 0x08 => 0x01b7, 0x09 => 0x014d, 0x0a => 0x014d, 0x0b => 0x01f4,
  230. 0x0c => 0x0225, 0x0d => 0xfa, 0x0e => 0x0225, 0x0f => 0xfa,
  231. 0x10 => 0x0116, 0x11 => 0x01f4, 0x12 => 0x01f4, 0x13 => 0x01f4,
  232. 0x14 => 0x01f4, 0x15 => 0x01f4, 0x16 => 0x01f4, 0x17 => 0x01f4,
  233. 0x18 => 0x01f4, 0x19 => 0x01f4, 0x1a => 0x01f4, 0x1b => 0x0116,
  234. 0x1c => 0x0116, 0x1d => 0x0225, 0x1e => 0x0225, 0x1f => 0x0225,
  235. 0x20 => 0x01bc, 0x21 => 0x0225, 0x22 => 0x02d2, 0x23 => 0x029b,
  236. 0x24 => 0x02d2, 0x25 => 0x0264, 0x26 => 0x0263, 0x27 => 0x02fb,
  237. 0x28 => 0x025b, 0x29 => 0x02d2, 0x2a => 0x014d, 0x2b => 0x0277,
  238. 0x2c => 0x02d2, 0x2d => 0x02ae, 0x2e => 0x0379, 0x2f => 0x02d2,
  239. 0x30 => 0x02d2, 0x31 => 0x0300, 0x32 => 0x02e5, 0x33 => 0x022c,
  240. 0x34 => 0x0250, 0x35 => 0x0263, 0x36 => 0x02b2, 0x37 => 0x01b7,
  241. 0x38 => 0x0300, 0x39 => 0x0285, 0x3a => 0x031b, 0x3b => 0x0263,
  242. 0x3c => 0x014d, 0x3d => 0x035f, 0x3e => 0x014d, 0x3f => 0x0292,
  243. 0x40 => 0x01f4, 0x41 => 0x01f4, 0x42 => 0x0277, 0x43 => 0x0225,
  244. 0x44 => 0x0225, 0x45 => 0x01ee, 0x46 => 0x01b7, 0x47 => 0x0209,
  245. 0x48 => 0x019b, 0x49 => 0x025b, 0x4a => 0x0149, 0x4b => 0x025b,
  246. 0x4c => 0x0225, 0x4d => 0x0225, 0x4e => 0x0240, 0x4f => 0x0209,
  247. 0x50 => 0x0225, 0x51 => 0x0225, 0x52 => 0x0209, 0x53 => 0x0225,
  248. 0x54 => 0x025b, 0x55 => 0x01b7, 0x56 => 0x0240, 0x57 => 0x02c9,
  249. 0x58 => 0x02ae, 0x59 => 0x01ed, 0x5a => 0x02ae, 0x5b => 0x01ee,
  250. 0x5c => 0x01e0, 0x5d => 0xc8, 0x5e => 0x01e0, 0x5f => 0x0225,
  251. 0x60 => 0x02ee, 0x61 => 0x026c, 0x62 => 0xf7, 0x63 => 0x0225,
  252. 0x64 => 0xa7, 0x65 => 0x02c9, 0x66 => 0x01f4, 0x67 => 0x02f1,
  253. 0x68 => 0x02f1, 0x69 => 0x02f1, 0x6a => 0x02f1, 0x6b => 0x0412,
  254. 0x6c => 0x03db, 0x6d => 0x025b, 0x6e => 0x03db, 0x6f => 0x025b,
  255. 0x70 => 0x0190, 0x71 => 0x0225, 0x72 => 0x019b, 0x73 => 0x0225,
  256. 0x74 => 0x0225, 0x75 => 0x02c9, 0x76 => 0x01ee, 0x77 => 0x01cc,
  257. 0x78 => 0x0225, 0x79 => 0x0225, 0x7a => 0x0225, 0x7b => 0x0225,
  258. 0x7c => 0x03e8, 0x7d => 0x025b, 0x7e => 0x03e8, 0x7f => 0x0292,
  259. 0x80 => 0x0337, 0x81 => 0x02ae, 0x82 => 0x031b, 0x83 => 0x03db,
  260. 0x84 => 0x0300, 0x85 => 0x0300, 0x86 => 0x0337, 0x87 => 0x0300,
  261. 0x88 => 0x0300, 0x89 => 0x02c9, 0x8a => 0x02c9, 0x8b => 0x02c9,
  262. 0x8c => 0x02c9, 0x8d => 0x02c9, 0x8e => 0x02c9, 0x8f => 0x02c9,
  263. 0x90 => 0x0300, 0x91 => 0x02c9, 0x92 => 0x0316, 0x93 => 0x0316,
  264. 0x94 => 0x037a, 0x95 => 0x0337, 0x96 => 0x0225, 0x97 => 0xfa,
  265. 0x98 => 0x02c9, 0x99 => 0x025b, 0x9a => 0x025b, 0x9b => 0x0412,
  266. 0x9c => 0x03db, 0x9d => 0x025b, 0x9e => 0x03db, 0x9f => 0x025b,
  267. 0xa0 => 0x01ee, 0xa1 => 0x0149, 0xa2 => 0x0316, 0xa3 => 0x0316,
  268. 0xa4 => 0x0312, 0xa5 => 0x02c9, 0xa6 => 0x0180, 0xa7 => 0x0180,
  269. 0xa8 => 0x0180, 0xa9 => 0x0180, 0xaa => 0x0180, 0xab => 0x0180,
  270. 0xac => 0x01ee, 0xad => 0x01ee, 0xae => 0x01ee, 0xaf => 0x01ee,
  271. 0xb0 => 0x0149, 0xb1 => 0x0112, 0xb2 => 0x02ae, 0xb3 => 0x02ae,
  272. 0xb4 => 0x02ae, 0xb5 => 0x0180, 0xb6 => 0x0180, 0xb7 => 0x0180,
  273. 0xb8 => 0x0180, 0xb9 => 0x0180, 0xba => 0x0180, 0xbb => 0x01ee,
  274. 0xbc => 0x01ee, 0xbd => 0x01ee, 0xbe => 0x0316);
  275. /* The cmap table is similarly synthesized.
  276. */
  277. $cmapData = array(
  278. 0x20 => 0x01, 0x21 => 0x02, 0x2200 => 0x03, 0x23 => 0x04,
  279. 0x2203 => 0x05, 0x25 => 0x06, 0x26 => 0x07, 0x220b => 0x08,
  280. 0x28 => 0x09, 0x29 => 0x0a, 0x2217 => 0x0b, 0x2b => 0x0c,
  281. 0x2c => 0x0d, 0x2212 => 0x0e, 0x2e => 0x0f, 0x2f => 0x10,
  282. 0x30 => 0x11, 0x31 => 0x12, 0x32 => 0x13, 0x33 => 0x14,
  283. 0x34 => 0x15, 0x35 => 0x16, 0x36 => 0x17, 0x37 => 0x18,
  284. 0x38 => 0x19, 0x39 => 0x1a, 0x3a => 0x1b, 0x3b => 0x1c,
  285. 0x3c => 0x1d, 0x3d => 0x1e, 0x3e => 0x1f, 0x3f => 0x20,
  286. 0x2245 => 0x21, 0x0391 => 0x22, 0x0392 => 0x23, 0x03a7 => 0x24,
  287. 0x2206 => 0x25, 0x0395 => 0x26, 0x03a6 => 0x27, 0x0393 => 0x28,
  288. 0x0397 => 0x29, 0x0399 => 0x2a, 0x03d1 => 0x2b, 0x039a => 0x2c,
  289. 0x039b => 0x2d, 0x039c => 0x2e, 0x039d => 0x2f, 0x039f => 0x30,
  290. 0x03a0 => 0x31, 0x0398 => 0x32, 0x03a1 => 0x33, 0x03a3 => 0x34,
  291. 0x03a4 => 0x35, 0x03a5 => 0x36, 0x03c2 => 0x37, 0x2126 => 0x38,
  292. 0x039e => 0x39, 0x03a8 => 0x3a, 0x0396 => 0x3b, 0x5b => 0x3c,
  293. 0x2234 => 0x3d, 0x5d => 0x3e, 0x22a5 => 0x3f, 0x5f => 0x40,
  294. 0xf8e5 => 0x41, 0x03b1 => 0x42, 0x03b2 => 0x43, 0x03c7 => 0x44,
  295. 0x03b4 => 0x45, 0x03b5 => 0x46, 0x03c6 => 0x47, 0x03b3 => 0x48,
  296. 0x03b7 => 0x49, 0x03b9 => 0x4a, 0x03d5 => 0x4b, 0x03ba => 0x4c,
  297. 0x03bb => 0x4d, 0xb5 => 0x4e, 0x03bd => 0x4f, 0x03bf => 0x50,
  298. 0x03c0 => 0x51, 0x03b8 => 0x52, 0x03c1 => 0x53, 0x03c3 => 0x54,
  299. 0x03c4 => 0x55, 0x03c5 => 0x56, 0x03d6 => 0x57, 0x03c9 => 0x58,
  300. 0x03be => 0x59, 0x03c8 => 0x5a, 0x03b6 => 0x5b, 0x7b => 0x5c,
  301. 0x7c => 0x5d, 0x7d => 0x5e, 0x223c => 0x5f, 0x20ac => 0x60,
  302. 0x03d2 => 0x61, 0x2032 => 0x62, 0x2264 => 0x63, 0x2044 => 0x64,
  303. 0x221e => 0x65, 0x0192 => 0x66, 0x2663 => 0x67, 0x2666 => 0x68,
  304. 0x2665 => 0x69, 0x2660 => 0x6a, 0x2194 => 0x6b, 0x2190 => 0x6c,
  305. 0x2191 => 0x6d, 0x2192 => 0x6e, 0x2193 => 0x6f, 0xb0 => 0x70,
  306. 0xb1 => 0x71, 0x2033 => 0x72, 0x2265 => 0x73, 0xd7 => 0x74,
  307. 0x221d => 0x75, 0x2202 => 0x76, 0x2022 => 0x77, 0xf7 => 0x78,
  308. 0x2260 => 0x79, 0x2261 => 0x7a, 0x2248 => 0x7b, 0x2026 => 0x7c,
  309. 0xf8e6 => 0x7d, 0xf8e7 => 0x7e, 0x21b5 => 0x7f, 0x2135 => 0x80,
  310. 0x2111 => 0x81, 0x211c => 0x82, 0x2118 => 0x83, 0x2297 => 0x84,
  311. 0x2295 => 0x85, 0x2205 => 0x86, 0x2229 => 0x87, 0x222a => 0x88,
  312. 0x2283 => 0x89, 0x2287 => 0x8a, 0x2284 => 0x8b, 0x2282 => 0x8c,
  313. 0x2286 => 0x8d, 0x2208 => 0x8e, 0x2209 => 0x8f, 0x2220 => 0x90,
  314. 0x2207 => 0x91, 0xf6da => 0x92, 0xf6d9 => 0x93, 0xf6db => 0x94,
  315. 0x220f => 0x95, 0x221a => 0x96, 0x22c5 => 0x97, 0xac => 0x98,
  316. 0x2227 => 0x99, 0x2228 => 0x9a, 0x21d4 => 0x9b, 0x21d0 => 0x9c,
  317. 0x21d1 => 0x9d, 0x21d2 => 0x9e, 0x21d3 => 0x9f, 0x25ca => 0xa0,
  318. 0x2329 => 0xa1, 0xf8e8 => 0xa2, 0xf8e9 => 0xa3, 0xf8ea => 0xa4,
  319. 0x2211 => 0xa5, 0xf8eb => 0xa6, 0xf8ec => 0xa7, 0xf8ed => 0xa8,
  320. 0xf8ee => 0xa9, 0xf8ef => 0xaa, 0xf8f0 => 0xab, 0xf8f1 => 0xac,
  321. 0xf8f2 => 0xad, 0xf8f3 => 0xae, 0xf8f4 => 0xaf, 0x232a => 0xb0,
  322. 0x222b => 0xb1, 0x2320 => 0xb2, 0xf8f5 => 0xb3, 0x2321 => 0xb4,
  323. 0xf8f6 => 0xb5, 0xf8f7 => 0xb6, 0xf8f8 => 0xb7, 0xf8f9 => 0xb8,
  324. 0xf8fa => 0xb9, 0xf8fb => 0xba, 0xf8fc => 0xbb, 0xf8fd => 0xbc,
  325. 0xf8fe => 0xbd, 0xf8ff => 0xbe);
  326. // require_once 'Zend/Pdf/Cmap.php';
  327. $this->_cmap = Zend_Pdf_Cmap::cmapWithTypeData(
  328. Zend_Pdf_Cmap::TYPE_BYTE_ENCODING_STATIC, $cmapData);
  329. /* Resource dictionary */
  330. /* The resource dictionary for the standard fonts is sparse because PDF
  331. * viewers already have all of the metrics data. We only need to provide
  332. * the font name and encoding method.
  333. */
  334. $this->_resource->BaseFont = new Zend_Pdf_Element_Name('Symbol');
  335. /* This font has a built-in custom character encoding method. Don't
  336. * override with WinAnsi like the other built-in fonts or else it will
  337. * not work as expected.
  338. */
  339. $this->_resource->Encoding = null;
  340. }
  341. /* Information and Conversion Methods */
  342. /**
  343. * Convert string encoding from local encoding to font encoding. Overridden
  344. * to defeat the conversion behavior for this ornamental font.
  345. *
  346. * @param string $string
  347. * @param string $charEncoding Character encoding of source text.
  348. * @return string
  349. */
  350. public function encodeString($string, $charEncoding)
  351. {
  352. /* This isn't the optimal time to perform this conversion, but it must
  353. * live here until the remainder of the layout code is completed. This,
  354. * and the $charEncoding parameter, will go away soon...
  355. */
  356. if ($charEncoding != 'UTF-16BE') {
  357. $string = iconv($charEncoding, 'UTF-16BE', $string);
  358. }
  359. /**
  360. * @todo Properly handle characters encoded as surrogate pairs.
  361. */
  362. $encodedString = '';
  363. for ($i = 0; $i < strlen($string); $i++) {
  364. $characterCode = (ord($string[$i++]) << 8) | ord($string[$i]);
  365. if (isset($this->_toFontEncoding[$characterCode])) {
  366. $encodedString .= $this->_toFontEncoding[$characterCode];
  367. } else {
  368. /* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
  369. * where unknown characters are removed completely. This is not
  370. * perfect, but we should be consistent. In a future revision,
  371. * we will use the well-known substitution character 0x1a
  372. * (Control-Z).
  373. */
  374. }
  375. }
  376. return $encodedString;
  377. }
  378. /**
  379. * Convert string encoding from font encoding to local encoding. Overridden
  380. * to defeat the conversion behavior for this ornamental font.
  381. *
  382. * @param string $string
  383. * @param string $charEncoding Character encoding of resulting text.
  384. * @return string
  385. */
  386. public function decodeString($string, $charEncoding)
  387. {
  388. $decodedString = '';
  389. for ($i = 0; $i < strlen($string); $i++) {
  390. $characterCode = ord($string[$i]);
  391. if (isset($this->_fromFontEncoding[$characterCode])) {
  392. $decodedString .= $this->_fromFontEncoding[$characterCode];
  393. } else {
  394. /* For now, mimic the behavior in Zend_Pdf_Font::encodeString()
  395. * where unknown characters are removed completely. This is not
  396. * perfect, but we should be consistent. In a future revision,
  397. * we will use the Unicode substitution character (U+FFFD).
  398. */
  399. }
  400. }
  401. if ($charEncoding != 'UTF-16BE') {
  402. $decodedString = iconv('UTF-16BE', $charEncoding, $decodedString);
  403. }
  404. return $decodedString;
  405. }
  406. /**
  407. * Converts a Latin-encoded string that fakes the font's internal encoding
  408. * to the proper Unicode characters, in UTF-16BE encoding.
  409. *
  410. * Used to maintain backwards compatibility with the 20 year-old legacy
  411. * method of using this font, which is still employed by recent versions of
  412. * some popular word processors.
  413. *
  414. * Note that using this method adds overhead due to the additional
  415. * character conversion. Don't use this for new code; it is more efficient
  416. * to use the appropriate Unicode characters directly.
  417. *
  418. * @param string $string
  419. * @param string $charEncoding (optional) Character encoding of source
  420. * string. Defaults to current locale.
  421. * @return string
  422. */
  423. public function toUnicode($string, $charEncoding = '')
  424. {
  425. /* When using these faked strings, the closest match to the font's
  426. * internal encoding is ISO-8859-1.
  427. */
  428. if ($charEncoding != 'ISO-8859-1') {
  429. $string = iconv($charEncoding, 'ISO-8859-1', $string);
  430. }
  431. return $this->decodeString($string, 'UTF-16BE');
  432. }
  433. }