您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

AdobeStandardEncoding.java 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410
  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. /* $Id$ */
  18. package org.apache.fop.fonts.type1;
  19. import java.util.HashMap;
  20. import java.util.Map;
  21. /**
  22. * Enumerates the {@linkplain http://unicode.org/Public/MAPPINGS/VENDORS/ADOBE/stdenc.txt} for
  23. * characters found in a Type1 font.
  24. */
  25. enum AdobeStandardEncoding {
  26. /** space character */
  27. space(0x0020, 0x20, "SPACE", "space"),
  28. /** space character */
  29. space_nobreak(0x00A0, 0x20, "NO-BREAK SPACE", "space"),
  30. /** exclamation mark */
  31. exclam(0x0021, 0x21, "EXCLAMATION MARK", "exclam"),
  32. /** quotation mark */
  33. quotedbl(0x0022, 0x22, "QUOTATION MARK", "quotedbl"),
  34. /** number sign */
  35. numersign(0x0023, 0x23, "NUMBER SIGN", "numbersign"),
  36. /** dollar character */
  37. dollar(0x0024, 0x24, "DOLLAR SIGN", "dollar"),
  38. /** percent character */
  39. percent(0x0025, 0x25, "PERCENT SIGN", "percent"),
  40. /** ampersand character */
  41. ampersand(0x0026, 0x26, "AMPERSAND", "ampersand"),
  42. /** right single quotation mark */
  43. quoteright(0x2019, 0x27, "RIGHT SINGLE QUOTATION MARK", "quoteright"),
  44. /** left parenthesis character */
  45. parenleft(0x0028, 0x28, "LEFT PARENTHESIS", "parenleft"),
  46. /** right parenthesis character */
  47. parenright(0x0029, 0x29, "RIGHT PARENTHESIS", "parenright"),
  48. /** asterisk character */
  49. asterisk(0x002A, 0x2A, "ASTERISK", "asterisk"),
  50. /** plus sign */
  51. plus(0x002B, 0x2B, "PLUS SIGN", "plus"),
  52. /** comma character */
  53. comma(0x002C, 0x2C, "COMMA", "comma"),
  54. /** hyphen-minus character */
  55. hyphen(0x002D, 0x2D, "HYPHEN-MINUS", "hyphen"),
  56. /** soft-hyphen character */
  57. hyphen_soft(0x00AD, 0x2D, "SOFT HYPHEN", "hyphen"),
  58. /** period character */
  59. period(0x002E, 0x2E, "FULL STOP", "period"),
  60. /** slash character */
  61. slash(0x002F, 0x2F, "SOLIDUS", "slash"),
  62. /** zero character */
  63. zero(0x0030, 0x30, "DIGIT ZERO", "zero"),
  64. /** one character */
  65. one(0x0031, 0x31, "DIGIT ONE", "one"),
  66. /** two character */
  67. two(0x0032, 0x32, "DIGIT TWO", "two"),
  68. /** three character */
  69. three(0x0033, 0x33, "DIGIT THREE", "three"),
  70. /** four character */
  71. four(0x0034, 0x34, "DIGIT FOUR", "four"),
  72. /** five character */
  73. five(0x0035, 0x35, "DIGIT FIVE", "five"),
  74. /** six character */
  75. six(0x0036, 0x36, "DIGIT SIX", "six"),
  76. /** seven character */
  77. seven(0x0037, 0x37, "DIGIT SEVEN", "seven"),
  78. /** eight character */
  79. eight(0x0038, 0x38, "DIGIT EIGHT", "eight"),
  80. /** nine character */
  81. nine(0x0039, 0x39, "DIGIT NINE", "nine"),
  82. /** colon character */
  83. colon(0x003A, 0x3A, "COLON", "colon"),
  84. /** semi-colon character */
  85. semicolon(0x003B, 0x3B, "SEMICOLON", "semicolon"),
  86. /** less character */
  87. less(0x003C, 0x3C, "LESS-THAN SIGN", "less"),
  88. /** equal character */
  89. equal(0x003D, 0x3D, "EQUALS SIGN", "equal"),
  90. /** greater character */
  91. greater(0x003E, 0x3E, "GREATER-THAN SIGN", "greater"),
  92. /** question character */
  93. question(0x003F, 0x3F, "QUESTION MARK", "question"),
  94. /** at character */
  95. at(0x0040, 0x40, "COMMERCIAL AT", "at"),
  96. /** A character */
  97. A(0x0041, 0x41, "LATIN CAPITAL LETTER A", "A"),
  98. /** B character */
  99. B(0x0042, 0x42, "LATIN CAPITAL LETTER B", "B"),
  100. /** C character */
  101. C(0x0043, 0x43, "LATIN CAPITAL LETTER C", "C"),
  102. /** D character */
  103. D(0x0044, 0x44, "LATIN CAPITAL LETTER D", "D"),
  104. /** E character */
  105. E(0x0045, 0x45, "LATIN CAPITAL LETTER E", "E"),
  106. /** F character */
  107. F(0x0046, 0x46, "LATIN CAPITAL LETTER F", "F"),
  108. /** G character */
  109. G(0x0047, 0x47, "LATIN CAPITAL LETTER G", "G"),
  110. /** H character */
  111. H(0x0048, 0x48, "LATIN CAPITAL LETTER H", "H"),
  112. /** I character */
  113. I(0x0049, 0x49, "LATIN CAPITAL LETTER I", "I"),
  114. /** J character */
  115. J(0x004A, 0x4A, "LATIN CAPITAL LETTER J", "J"),
  116. /** K character */
  117. K(0x004B, 0x4B, "LATIN CAPITAL LETTER K", "K"),
  118. /** L character */
  119. L(0x004C, 0x4C, "LATIN CAPITAL LETTER L", "L"),
  120. /** M character */
  121. M(0x004D, 0x4D, "LATIN CAPITAL LETTER M", "M"),
  122. /** N character */
  123. N(0x004E, 0x4E, "LATIN CAPITAL LETTER N", "N"),
  124. /** O character */
  125. O(0x004F, 0x4F, "LATIN CAPITAL LETTER O", "O"),
  126. /** P character */
  127. P(0x0050, 0x50, "LATIN CAPITAL LETTER P", "P"),
  128. /** Q character */
  129. Q(0x0051, 0x51, "LATIN CAPITAL LETTER Q", "Q"),
  130. /** R character */
  131. R(0x0052, 0x52, "LATIN CAPITAL LETTER R", "R"),
  132. /** S character */
  133. S(0x0053, 0x53, "LATIN CAPITAL LETTER S", "S"),
  134. /** T character */
  135. T(0x0054, 0x54, "LATIN CAPITAL LETTER T", "T"),
  136. /** U character */
  137. U(0x0055, 0x55, "LATIN CAPITAL LETTER U", "U"),
  138. /** V character */
  139. V(0x0056, 0x56, "LATIN CAPITAL LETTER V", "V"),
  140. /** W character */
  141. W(0x0057, 0x57, "LATIN CAPITAL LETTER W", "W"),
  142. /** X character */
  143. X(0x0058, 0x58, "LATIN CAPITAL LETTER X", "X"),
  144. /** Y character */
  145. Y(0x0059, 0x59, "LATIN CAPITAL LETTER Y", "Y"),
  146. /** Z character */
  147. Z(0x005A, 0x5A, "LATIN CAPITAL LETTER Z", "Z"),
  148. /** left bracket character */
  149. bracketleft(0x005B, 0x5B, "LEFT SQUARE BRACKET", "bracketleft"),
  150. /** back slash character */
  151. backslash(0x005C, 0x5C, "REVERSE SOLIDUS", "backslash"),
  152. /** bracket right character */
  153. bracketright(0x005D, 0x5D, "RIGHT SQUARE BRACKET", "bracketright"),
  154. /** circumflex character */
  155. asciicircum(0x005E, 0x5E, "CIRCUMFLEX ACCENT", "asciicircum"),
  156. /** under score character */
  157. underscore(0x005F, 0x5F, "LOW LINE", "underscore"),
  158. /** left single quotation character */
  159. quoteleft(0x2018, 0x60, "LEFT SINGLE QUOTATION MARK", "quoteleft"),
  160. /** a character */
  161. a(0x0061, 0x61, "LATIN SMALL LETTER A", "a"),
  162. /** b character */
  163. b(0x0062, 0x62, "LATIN SMALL LETTER B", "b"),
  164. /** c character */
  165. c(0x0063, 0x63, "LATIN SMALL LETTER C", "c"),
  166. /** d character */
  167. d(0x0064, 0x64, "LATIN SMALL LETTER D", "d"),
  168. /** e character */
  169. e(0x0065, 0x65, "LATIN SMALL LETTER E", "e"),
  170. /** f character */
  171. f(0x0066, 0x66, "LATIN SMALL LETTER F", "f"),
  172. /** g character */
  173. g(0x0067, 0x67, "LATIN SMALL LETTER G", "g"),
  174. /** h character */
  175. h(0x0068, 0x68, "LATIN SMALL LETTER H", "h"),
  176. /** i character */
  177. i(0x0069, 0x69, "LATIN SMALL LETTER I", "i"),
  178. /** j character */
  179. j(0x006A, 0x6A, "LATIN SMALL LETTER J", "j"),
  180. /** k character */
  181. k(0x006B, 0x6B, "LATIN SMALL LETTER K", "k"),
  182. /** l character */
  183. l(0x006C, 0x6C, "LATIN SMALL LETTER L", "l"),
  184. /** m character */
  185. m(0x006D, 0x6D, "LATIN SMALL LETTER M", "m"),
  186. /** n character */
  187. n(0x006E, 0x6E, "LATIN SMALL LETTER N", "n"),
  188. /** o character */
  189. o(0x006F, 0x6F, "LATIN SMALL LETTER O", "o"),
  190. /** p character */
  191. p(0x0070, 0x70, "LATIN SMALL LETTER P", "p"),
  192. /** q character */
  193. q(0x0071, 0x71, "LATIN SMALL LETTER Q", "q"),
  194. /** r character */
  195. r(0x0072, 0x72, "LATIN SMALL LETTER R", "r"),
  196. /** s character */
  197. s(0x0073, 0x73, "LATIN SMALL LETTER S", "s"),
  198. /** t character */
  199. t(0x0074, 0x74, "LATIN SMALL LETTER T", "t"),
  200. /** u character */
  201. u(0x0075, 0x75, "LATIN SMALL LETTER U", "u"),
  202. /** v character */
  203. v(0x0076, 0x76, "LATIN SMALL LETTER V", "v"),
  204. /** w character */
  205. w(0x0077, 0x77, "LATIN SMALL LETTER W", "w"),
  206. /** x character */
  207. x(0x0078, 0x78, "LATIN SMALL LETTER X", "x"),
  208. /** y character */
  209. y(0x0079, 0x79, "LATIN SMALL LETTER Y", "y"),
  210. /** z character */
  211. z(0x007A, 0x7A, "LATIN SMALL LETTER Z", "z"),
  212. /** left curly bracket character */
  213. braceleft(0x007B, 0x7B, "LEFT CURLY BRACKET", "braceleft"),
  214. /** vertical line character */
  215. bar(0x007C, 0x7C, "VERTICAL LINE", "bar"),
  216. /** right curly bracket character */
  217. braceright(0x007D, 0x7D, "RIGHT CURLY BRACKET", "braceright"),
  218. /** tilde character */
  219. asciitilde(0x007E, 0x7E, "TILDE", "asciitilde"),
  220. /** inverted exclamation mark */
  221. exclamdown(0x00A1, 0xA1, "INVERTED EXCLAMATION MARK", "exclamdown"),
  222. /** cent character */
  223. cent(0x00A2, 0xA2, "CENT SIGN", "cent"),
  224. /** sterling character */
  225. sterling(0x00A3, 0xA3, "POUND SIGN", "sterling"),
  226. /** fraction slash character */
  227. fraction(0x2044, 0xA4, "FRACTION SLASH", "fraction"),
  228. /** division slash character */
  229. fraction_division_slash(0x2215, 0xA4, "DIVISION SLASH", "fraction"),
  230. /** yen character */
  231. yen(0x00A5, 0xA5, "YEN SIGN", "yen"),
  232. /** florin character */
  233. florin(0x0192, 0xA6, "LATIN SMALL LETTER F WITH HOOK", "florin"),
  234. /** section sign character */
  235. section(0x00A7, 0xA7, "SECTION SIGN", "section"),
  236. /** currency sign character */
  237. currency(0x00A4, 0xA8, "CURRENCY SIGN", "currency"),
  238. /** apostrophe character */
  239. quotesingle(0x0027, 0xA9, "APOSTROPHE", "quotesingle"),
  240. /** double left quotation mark */
  241. quotedblleft(0x201C, 0xAA, "LEFT DOUBLE QUOTATION MARK", "quotedblleft"),
  242. /** left-pointing double angle quotation mark */
  243. guillemotleft(0x00AB, 0xAB, "LEFT-POINTING DOUBLE ANGLE QUOTATION MARK", "guillemotleft"),
  244. /** left-pointing single quotation mark */
  245. guilsinglleft(0x2039, 0xAC, "SINGLE LEFT-POINTING ANGLE QUOTATION MARK", "guilsinglleft"),
  246. /** right-pointing single quotation mark */
  247. guilsinglright(0x203A, 0xAD, "SINGLE RIGHT-POINTING ANGLE QUOTATION MARK", "guilsinglright"),
  248. /** fi ligature */
  249. fi(0xFB01, 0xAE, "LATIN SMALL LIGATURE FI", "fi"),
  250. /** fl ligature */
  251. fl(0xFB02, 0xAF, "LATIN SMALL LIGATURE FL", "fl"),
  252. /** en-dash character */
  253. endash(0x2013, 0xB1, "EN DASH", "endash"),
  254. /** dagger character */
  255. dagger(0x2020, 0xB2, "DAGGER", "dagger"),
  256. /** double dagger character */
  257. daggerdbl(0x2021, 0xB3, "DOUBLE DAGGER", "daggerdbl"),
  258. /** centered period character */
  259. periodcentered(0x00B7, 0xB4, "MIDDLE DOT", "periodcentered"),
  260. /** centered period character */
  261. periodcentered_bullet_operator(0x2219, 0xB4, "BULLET OPERATOR", "periodcentered"),
  262. /** paragraph character */
  263. paragraph(0x00B6, 0xB6, "PILCROW SIGN", "paragraph"),
  264. /** bullet character */
  265. bullet(0x2022, 0xB7, "BULLET", "bullet"),
  266. /** single low-9 quotation mark */
  267. quotesinglbase(0x201A, 0xB8, "SINGLE LOW-9 QUOTATION MARK", "quotesinglbase"),
  268. /** double low-9 quotation mark */
  269. quotedblbase(0x201E, 0xB9, "DOUBLE LOW-9 QUOTATION MARK", "quotedblbase"),
  270. /** right double quotation mark */
  271. quotedblright(0x201D, 0xBA, "RIGHT DOUBLE QUOTATION MARK", "quotedblright"),
  272. /** right-pointing double angle quotation mark */
  273. guillemotright(0x00BB, 0xBB, "RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK", "guillemotright"),
  274. /** horizontal ellipsis character */
  275. ellipsis(0x2026, 0xBC, "HORIZONTAL ELLIPSIS", "ellipsis"),
  276. /** per-mille character */
  277. perthousand(0x2030, 0xBD, "PER MILLE SIGN", "perthousand"),
  278. /** inverted question mark */
  279. questiondown(0x00BF, 0xBF, "INVERTED QUESTION MARK", "questiondown"),
  280. /** grave accent character */
  281. grave(0x0060, 0xC1, "GRAVE ACCENT", "grave"),
  282. /** acute accent character */
  283. acute(0x00B4, 0xC2, "ACUTE ACCENT", "acute"),
  284. /** modifier letter circumflex accent character */
  285. circumflex(0x02C6, 0xC3, "MODIFIER LETTER CIRCUMFLEX ACCENT", "circumflex"),
  286. /** small tilde character */
  287. tilde(0x02DC, 0xC4, "SMALL TILDE", "tilde"),
  288. /** macron character */
  289. macron(0x00AF, 0xC5, "MACRON", "macron"),
  290. /** modifier letter macron character */
  291. macron_modifier_letter(0x02C9, 0xC5, "MODIFIER LETTER MACRON", "macron"),
  292. /** breve character */
  293. breve(0x02D8, 0xC6, "BREVE", "breve"),
  294. /** dot above character */
  295. dotaccent(0x02D9, 0xC7, "DOT ABOVE", "dotaccent"),
  296. /** diaeresis character */
  297. dieresis(0x00A8, 0xC8, "DIAERESIS", "dieresis"),
  298. /** ring above character */
  299. ring(0x02DA, 0xCA, "RING ABOVE", "ring"),
  300. /** cedilla character */
  301. cedilla(0x00B8, 0xCB, "CEDILLA", "cedilla"),
  302. /** double acute accent character */
  303. hungarumlaut(0x02DD, 0xCD, "DOUBLE ACUTE ACCENT", "hungarumlaut"),
  304. /** agonek character */
  305. ogonek(0x02DB, 0xCE, "OGONEK", "ogonek"),
  306. /** caron character */
  307. caron(0x02C7, 0xCF, "CARON", "caron"),
  308. /** emdash character */
  309. emdash(0x2014, 0xD0, "EM DASH", "emdash"),
  310. /** AE (capitalised) character */
  311. AE(0x00C6, 0xE1, "LATIN CAPITAL LETTER AE", "AE"),
  312. /** femenine ordinal indicator character */
  313. ordfeminine(0x00AA, 0xE3, "FEMININE ORDINAL INDICATOR", "ordfeminine"),
  314. /** capital letter L with stroke character */
  315. Lslash(0x0141, 0xE8, "LATIN CAPITAL LETTER L WITH STROKE", "Lslash"),
  316. /** capital letter O with stroke character */
  317. Oslash(0x00D8, 0xE9, "LATIN CAPITAL LETTER O WITH STROKE", "Oslash"),
  318. /** OE (capitalised) character */
  319. OE(0x0152, 0xEA, "LATIN CAPITAL LIGATURE OE", "OE"),
  320. /** masculine ordinal indicator character */
  321. ordmasculine(0x00BA, 0xEB, "MASCULINE ORDINAL INDICATOR", "ordmasculine"),
  322. /** ae (small) character */
  323. ae(0x00E6, 0xF1, "LATIN SMALL LETTER AE", "ae"),
  324. /** dotless i character */
  325. dotlessi(0x0131, 0xF5, "LATIN SMALL LETTER DOTLESS I", "dotlessi"),
  326. /** small letter l with stroke character */
  327. lslash(0x0142, 0xF8, "LATIN SMALL LETTER L WITH STROKE", "lslash"),
  328. /** small letter o with stroke character */
  329. oslash(0x00F8, 0xF9, "LATIN SMALL LETTER O WITH STROKE", "oslash"),
  330. /** oe (small) character */
  331. oe(0x0153, 0xFA, "LATIN SMALL LIGATURE OE", "oe"),
  332. /** small letter sharp s character */
  333. germandbls(0x00DF, 0xFB, "LATIN SMALL LETTER SHARP S", "germandbls");
  334. private final int unicodeIndex;
  335. private final int adobeCodePoint;
  336. private final String unicodeName;
  337. private final String adobeName;
  338. /** The name of the Adobe Standard Encoding as seen in an AFM file. */
  339. public static final String NAME = "AdobeStandardEncoding";
  340. private static final Map<String, AdobeStandardEncoding> CACHE
  341. = new HashMap<String, AdobeStandardEncoding>();
  342. static {
  343. for (AdobeStandardEncoding encoding : AdobeStandardEncoding.values()) {
  344. CACHE.put(encoding.getAdobeName(), encoding);
  345. }
  346. }
  347. private AdobeStandardEncoding(int unicodeIndex, int adobeCodePoint, String unicodeName,
  348. String adobeName) {
  349. this.unicodeIndex = unicodeIndex;
  350. this.adobeCodePoint = adobeCodePoint;
  351. this.unicodeName = unicodeName;
  352. this.adobeName = adobeName;
  353. }
  354. /**
  355. * The Unicode index of this character.
  356. *
  357. * @return the Unicode index
  358. */
  359. int getUnicodeIndex() {
  360. return unicodeIndex;
  361. }
  362. /**
  363. * The Adobe code point of this character.
  364. *
  365. * @return the Adobe code point
  366. */
  367. int getAdobeCodePoint() {
  368. return adobeCodePoint;
  369. }
  370. /**
  371. * The Unicode name for this character.
  372. *
  373. * @return the Unicode name
  374. */
  375. String getUnicodeName() {
  376. return unicodeName;
  377. }
  378. /**
  379. * The Adobe name for this character.
  380. *
  381. * @return the Adobe name
  382. */
  383. String getAdobeName() {
  384. return adobeName;
  385. }
  386. /**
  387. * Returns the code point of a Adobe standard encoded character given its name. If the name
  388. * cannot be found, -1 is returned.
  389. *
  390. * @param adobeName the name of the character
  391. * @return the Adobe code point
  392. */
  393. public static int getAdobeCodePoint(String adobeName) {
  394. AdobeStandardEncoding encoding = CACHE.get(adobeName);
  395. return encoding != null ? encoding.getAdobeCodePoint() : -1;
  396. }
  397. }