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.

Merged revisions 638842-642143 via svnmerge from https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk ........ r640089 | clay | 2008-03-22 22:54:27 +0100 (Sa, 22 Mrz 2008) | 1 line updates to Forrest web site (expand menu structure). ........ r640242 | adelmelle | 2008-03-23 20:36:36 +0100 (So, 23 Mrz 2008) | 11 lines Cleanup and minor refactoring: * consolidate addId() in AbstractLayoutManager * replace getPSLM().addIdToPage(getXXX().getId()) in various LMs Smaller changes/cleanup in the affected LMs include: * removal of some redundant casts * simplified conditionals * avoid duplicating the reference to the FObj as much as possible: the reference is already stored in AbstractLM, yet every subclass seems to add another reference... ........ r641742 | jeremias | 2008-03-27 09:49:41 +0100 (Do, 27 Mrz 2008) | 6 lines Added support for addressing all glyphs available in a Type 1 font, not just the ones in the font's primary encoding. Typeface: getEncoding() changed to getEncodingName() to make clearer what is held here. Some cleanup in the font classes to put the various things in more appropriate places. Created a common base class for all Base 14 fonts (makes the hierarchy clearer). Made PDFTextUtil more universally useful and made use of it in PDFRenderer, too. Made PDFStream.add(String) more efficient. The encoding converter is not called for each invocation anymore as the whole thing get buffered by a BufferedWriter (as suggested by the javadoc of OutputStreamWriter). ........ r641764 | maxberger | 2008-03-27 11:02:25 +0100 (Do, 27 Mrz 2008) | 1 line Added my key ........ r641827 | jeremias | 2008-03-27 15:29:44 +0100 (Do, 27 Mrz 2008) | 2 lines When a JPEG image is embedded, an optionally embedded color profile is filtered out as it's already embedded separately in the PDF file. Worked around a problem (PDF renderer) with JPEG image containing RGB color profiles which are not sRGB. The images drifted into yellow. The color profile is simply disabled in this case. Please let us know if you know what the problem could be. ........ git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ProcessingFeedback@642155 13f79535-47bb-0310-9956-ffa450edef68
пре 16 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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.pdf;
  19. import java.io.IOException;
  20. import java.io.OutputStream;
  21. import java.io.Writer;
  22. /**
  23. * Class representing the CMap encodings.
  24. *
  25. * CMaps are defined in the "Predefined CJK CMap names" table.
  26. * In section 5.6.4 of PDF reference 1.4.
  27. */
  28. public class PDFCMap extends PDFStream {
  29. /*
  30. * Chinese (simplified)
  31. */
  32. /**
  33. * GB-EUC-H Microsoft Code Page 936 (lfCharSet 0x86), GB 2312-80
  34. * character set, EUC-CN encoding
  35. */
  36. public static final String ENC_GB_EUC_H = "GB-EUC-H";
  37. /**
  38. * GB-EUC-V Vertical version of GB-EUC-H
  39. */
  40. public static final String ENC_GB_EUC_V = "GB_EUC_V";
  41. /**
  42. * GBpc-EUC-H Mac OS, GB 2312-80 character set, EUC-CN encoding, Script Manager code 19
  43. */
  44. public static final String ENC_GBPC_EUC_H = "GBpc-EUC-H";
  45. /**
  46. * GBpc-EUC-V Vertical version of GBpc-EUC-H
  47. */
  48. public static final String ENC_GBPC_EUC_V = "GBpc-EUC-V";
  49. /**
  50. * GBK-EUC-H Microsoft Code Page 936 (lfCharSet 0x86), GBK character set, GBK encoding
  51. */
  52. public static final String ENC_GBK_EUC_H = "GBK-EUC-H";
  53. /**
  54. * GBK-EUC-V Vertical version of GBK-EUC-H
  55. */
  56. public static final String ENC_GBK_EUC_V = "GBK-EUC-V";
  57. /**
  58. * GBKp-EUC-H Same as GBK-EUC-H, but replaces half-width
  59. * Latin characters with proportional forms and maps character
  60. * code 0x24 to a dollar sign ($) instead of a yuan symbol
  61. */
  62. public static final String ENC_GBKP_EUC_H = "GBKp-EUC-H";
  63. /**
  64. * GBKp-EUC-V Vertical version of GBKp-EUC-H
  65. */
  66. public static final String ENC_GBKP_EUC_V = "GBKp-EUC-V";
  67. /**
  68. * GBK2K-H GB 18030-2000 character set, mixed 1-, 2-, and 4-byte encoding
  69. */
  70. public static final String ENC_GBK2K_H = "GBK2K-H";
  71. /**
  72. * GBK2K-V Vertical version of GBK2K-H
  73. */
  74. public static final String ENC_GBK2K_V = "GBK2K-V";
  75. /**
  76. * UniGB-UCS2-H Unicode (UCS-2) encoding for the Adobe-GB1 character collection
  77. */
  78. public static final String ENC_UNIGB_UCS2_H = "UniGB-UCS2-H";
  79. /**
  80. * UniGB-UCS2-V Vertical version of UniGB-UCS2-H
  81. */
  82. public static final String ENC_UNIGB_UCS2_V = "UniGB-UCS2-V";
  83. /*
  84. * Chinese (Traditional)
  85. */
  86. /**
  87. * B5pc-H Mac OS, Big Five character set, Big Five encoding, Script Manager code 2
  88. */
  89. public static final String ENC_B5PC_H = "B5pc-H";
  90. /**
  91. * B5pc-V Vertical version of B5pc-H
  92. */
  93. public static final String ENC_B5PC_V = "B5pc-V";
  94. /**
  95. * HKscs-B5-H Hong Kong SCS, an extension to the Big Five
  96. * character set and encoding
  97. */
  98. public static final String ENC_HKSCS_B5_H = "HKscs-B5-H";
  99. /**
  100. * HKscs-B5-V Vertical version of HKscs-B5-H
  101. */
  102. public static final String ENC_HKSCS_B5_V = "HKscs-B5-V";
  103. /**
  104. * ETen-B5-H Microsoft Code Page 950 (lfCharSet 0x88), Big Five
  105. * character set with ETen extensions
  106. */
  107. public static final String ENC_ETEN_B5_H = "ETen-B5-H";
  108. /**
  109. * ETen-B5-V Vertical version of ETen-B5-H
  110. */
  111. public static final String ENC_ETEN_B5_V = "ETen-B5-V";
  112. /**
  113. * ETenms-B5-H Same as ETen-B5-H, but replaces half-width
  114. * Latin characters with proportional forms
  115. */
  116. public static final String ENC_ETENMS_B5_H = "ETenms-B5-H";
  117. /**
  118. * ETenms-B5-V Vertical version of ETenms-B5-H
  119. */
  120. public static final String ENC_ETENMS_B5_V = "ETenms-B5-V";
  121. /**
  122. * CNS-EUC-H CNS 11643-1992 character set, EUC-TW encoding
  123. */
  124. public static final String ENC_CNS_EUC_H = "CNS-EUC-H";
  125. /**
  126. * CNS-EUC-V Vertical version of CNS-EUC-H
  127. */
  128. public static final String ENC_CNS_EUC_V = "CNS-EUC-V";
  129. /**
  130. * UniCNS-UCS2-H Unicode (UCS-2) encoding for the
  131. * Adobe-CNS1 character collection
  132. */
  133. public static final String ENC_UNICNS_UCS2_H = "UniCNS-UCS2-H";
  134. /**
  135. * UniCNS-UCS2-V Vertical version of UniCNS-UCS2-H
  136. */
  137. public static final String ENC_UNICNS_UCS2_V = "UniCNS-UCS2-V";
  138. /*
  139. * Japanese
  140. */
  141. /**
  142. * 83pv-RKSJ-H Mac OS, JIS X 0208 character set with KanjiTalk6
  143. * extensions, Shift-JIS encoding, Script Manager code 1
  144. */
  145. public static final String ENC_83PV_RKSJ_H = "83pv-RKSJ-H"; // no V version
  146. /**
  147. * 90ms-RKSJ-H Microsoft Code Page 932 (lfCharSet 0x80), JIS X 0208
  148. * character set with NEC and IBM extensions
  149. */
  150. public static final String ENC_90MS_RKSJ_H = "90ms-RKSJ-H";
  151. /**
  152. * 90ms-RKSJ-V Vertical version of 90ms-RKSJ-H
  153. */
  154. public static final String ENC_90MS_RKSJ_V = "90ms-RKSJ-V";
  155. /**
  156. * 90msp-RKSJ-H Same as 90ms-RKSJ-H, but replaces half-width Latin
  157. * characters with proportional forms
  158. */
  159. public static final String ENC_90MSP_RKSJ_H = "90msp-RKSJ-H";
  160. /**
  161. * 90msp-RKSJ-V Vertical version of 90msp-RKSJ-H
  162. */
  163. public static final String ENC_90MSP_RKSJ_V = "90msp-RKSJ-V";
  164. /**
  165. * 90pv-RKSJ-H Mac OS, JIS X 0208 character set with KanjiTalk7
  166. * extensions, Shift-JIS encoding, Script Manager code 1
  167. */
  168. public static final String ENC_90PV_RKSJ_H = "90pv-RKSJ-H"; // no V version
  169. /**
  170. * Add-RKSJ-H JIS X 0208 character set with Fujitsu FMR
  171. * extensions, Shift-JIS encoding
  172. */
  173. public static final String ENC_ADD_RKSJ_H = "Add-RKSJ-H";
  174. /**
  175. * Add-RKSJ-V Vertical version of Add-RKSJ-H
  176. */
  177. public static final String ENC_ADD_RKSJ_V = "Add-RKSJ-V";
  178. /**
  179. * EUC-H JIS X 0208 character set, EUC-JP encoding
  180. */
  181. public static final String ENC_EUC_H = "EUC-H";
  182. /**
  183. * EUC-V Vertical version of EUC-H
  184. */
  185. public static final String ENC_EUC_V = "EUC-V";
  186. /**
  187. * Ext-RKSJ-H JIS C 6226 (JIS78) character set with
  188. * NEC extensions, Shift-JIS encoding
  189. */
  190. public static final String ENC_EXT_RKSJ_H = "Ext-RKSJ-H";
  191. /**
  192. * Ext-RKSJ-V Vertical version of Ext-RKSJ-H
  193. */
  194. public static final String ENC_EXT_RKSJ_V = "Ext-RKSJ-V";
  195. /**
  196. * H JIS X 0208 character set, ISO-2022-JP encoding
  197. */
  198. public static final String ENC_H = "H";
  199. /**
  200. * V Vertical version of H
  201. */
  202. public static final String ENC_V = "V";
  203. /**
  204. * UniJIS-UCS2-H Unicode (UCS-2) encoding for the
  205. * Adobe-Japan1 character collection
  206. */
  207. public static final String ENC_UNIJIS_UCS2_H = "UniJIS-UCS2-H";
  208. /**
  209. * UniJIS-UCS2-V Vertical version of UniJIS-UCS2-H
  210. */
  211. public static final String ENC_UNIJIS_UCS2_V = "UniJIS-UCS2-V";
  212. /**
  213. * UniJIS-UCS2-HW-H Same as UniJIS-UCS2-H, but replaces proportional
  214. * Latin characters with half-width forms
  215. */
  216. public static final String ENC_UNIJIS_UCS2_HW_H = "UniJIS-UCS2-HW-H";
  217. /**
  218. * UniJIS-UCS2-HW-V Vertical version of UniJIS-UCS2-HW-H
  219. */
  220. public static final String ENC_UNIJIS_UCS2_HW_V = "UniJIS-UCS2-HW-V";
  221. /*
  222. * Korean
  223. */
  224. /**
  225. * KSC-EUC-H KS X 1001:1992 character set, EUC-KR encoding
  226. */
  227. public static final String ENC_KSC_EUC_H = "KSC-EUC-H";
  228. /**
  229. * KSC-EUC-V Vertical version of KSC-EUC-H
  230. */
  231. public static final String ENC_KSC_EUC_V = "KSC-EUC-V";
  232. /**
  233. * KSCms-UHC-H Microsoft Code Page 949 (lfCharSet 0x81), KS X 1001:1992
  234. * character set plus 8822 additional hangul,
  235. * Unified Hangul Code (UHC) encoding
  236. */
  237. public static final String ENC_KSCMS_UHC_H = "KSCms-UHC-H";
  238. /**
  239. * KSCms-UHC-V Vertical version of KSCms-UHC-H
  240. */
  241. public static final String ENC_KSCMS_UHC_V = "KSCms-UHC-V";
  242. /**
  243. * KSCms-UHC-HW-H Same as KSCms-UHC-H, but replaces proportional
  244. * Latin characters with half-width forms
  245. */
  246. public static final String ENC_KSCMS_UHC_HW_H = "KSCms-UHC-HW-H";
  247. /**
  248. * KSCms-UHC-HW-V Vertical version of KSCms-UHC-HW-H
  249. */
  250. public static final String ENC_KSCMS_UHC_HW_V = "KSCms-UHC-HW-V";
  251. /**
  252. * KSCpc-EUC-H Mac OS, KS X 1001:1992 character set with
  253. * Mac OS KH extensions, Script Manager Code 3
  254. */
  255. public static final String ENC_KSCPC_EUC_H = "KSCpc-EUC-H"; // no V version
  256. /**
  257. * UniKS-UCS2-H Unicode (UCS-2) encoding for the
  258. * Adobe-Korea1 character collection
  259. */
  260. public static final String ENC_UNIKSC_UCS2_H = "UniKSC-UCS2-H";
  261. /**
  262. * UniKS-UCS2-V Vertical version of UniKS-UCS2-H
  263. */
  264. public static final String ENC_UNIKSC_UCS2_V = "UniKSC-UCS2-V";
  265. /*
  266. * Generic
  267. */
  268. /**
  269. * Identity-H The horizontal identity mapping for 2-byte CIDs;
  270. * may be used with CIDFonts using any Registry, Ordering, and
  271. * Supplement values. It maps 2-byte character codes ranging from
  272. * 0 to 65,535 to the same 2-byte CID value, interpreted
  273. * high-order byte first.
  274. */
  275. public static final String ENC_IDENTITY_H = "Identity-H";
  276. /**
  277. * Identity-V Vertical version of Identity-H. The mapping
  278. * is the same as for Identity-H.
  279. */
  280. public static final String ENC_IDENTTITY_V = "Identity-V";
  281. /**
  282. * /CMapName attribute, one of the predefined constants
  283. */
  284. protected String name;
  285. /**
  286. * /CIDSystemInfo attribute
  287. */
  288. protected PDFCIDSystemInfo sysInfo;
  289. /**
  290. * horizontal writing direction
  291. */
  292. public static final byte WMODE_HORIZONTAL = 0;
  293. /**
  294. * vertical writing direction
  295. */
  296. public static final byte WMODE_VERTICAL = 1;
  297. /**
  298. * font's writing direction
  299. */
  300. protected byte wMode = WMODE_HORIZONTAL;
  301. /**
  302. * base CMap (String or PDFStream)
  303. */
  304. protected Object base;
  305. /**
  306. * create the /CMap object
  307. *
  308. * @param name one the registered names (see Table 7.20 on p 215)
  309. * @param sysInfo the attributes of the character collection of the CIDFont
  310. */
  311. public PDFCMap(String name, PDFCIDSystemInfo sysInfo) {
  312. super();
  313. this.name = name;
  314. this.sysInfo = sysInfo;
  315. this.base = null;
  316. }
  317. /**
  318. * set the writing direction
  319. *
  320. * @param mode is either <code>WMODE_HORIZONTAL</code>
  321. * or <code>WMODE_VERTICAL</code>
  322. */
  323. public void setWMode(byte mode) {
  324. this.wMode = mode;
  325. }
  326. /**
  327. * set the base CMap
  328. *
  329. * @param base the name of the base CMap
  330. */
  331. public void setUseCMap(String base) {
  332. this.base = base;
  333. }
  334. /**
  335. * set the base CMap
  336. *
  337. * @param base the stream to be used as base CMap
  338. */
  339. public void setUseCMap(PDFStream base) {
  340. this.base = base;
  341. }
  342. /**
  343. * Creates the CMapBuilder that will build the CMap's content.
  344. * @param writer a Writer to write the CMap's contents to
  345. * @return the newly created CMapBuilder
  346. */
  347. protected CMapBuilder createCMapBuilder(Writer writer) {
  348. return new CMapBuilder(writer, this.name);
  349. }
  350. /** {@inheritDoc} */
  351. protected int output(OutputStream stream) throws IOException {
  352. CMapBuilder builder = createCMapBuilder(getBufferWriter());
  353. builder.writeCMap();
  354. return super.output(stream);
  355. }
  356. }