diff options
author | Bertrand Delacretaz <bdelacretaz@apache.org> | 2006-10-10 13:00:05 +0000 |
---|---|---|
committer | Bertrand Delacretaz <bdelacretaz@apache.org> | 2006-10-10 13:00:05 +0000 |
commit | 2ba9df23cd7fb81ba970ca6c89af60ca5630d443 (patch) | |
tree | f92f39aaf63fe97e857f13e7903992e7ee8a0024 /src/java/org/apache/fop/pdf/PDFCMap.java | |
parent | 1a8a662bda6d5f9f08973074555dd0f10990e3ef (diff) | |
download | xmlgraphics-fop-2ba9df23cd7fb81ba970ca6c89af60ca5630d443.tar.gz xmlgraphics-fop-2ba9df23cd7fb81ba970ca6c89af60ca5630d443.zip |
Applied patch from bugzilla 5335, comment 10.
Generates a ToUnicode table for embedded CID fonts.
Patch provided by Adam Strzelecki, ono@java.pl.
The patch contains code for the FOray project, used with permission (bugzilla 5335 comment #13).
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@454725 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFCMap.java')
-rw-r--r-- | src/java/org/apache/fop/pdf/PDFCMap.java | 57 |
1 files changed, 51 insertions, 6 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFCMap.java b/src/java/org/apache/fop/pdf/PDFCMap.java index 84d9f8359..d62e45d85 100644 --- a/src/java/org/apache/fop/pdf/PDFCMap.java +++ b/src/java/org/apache/fop/pdf/PDFCMap.java @@ -19,6 +19,9 @@ package org.apache.fop.pdf; +import java.io.IOException; +import java.io.OutputStream; + /** * Class representing the CMap encodings. * @@ -424,53 +427,91 @@ public class PDFCMap extends PDFStream { * @param p the string buffer to add the pdf data to */ public void fillInPDF(StringBuffer p) { + writePreStream(p); + writeStreamComments(p); + writeCIDInit(p); + writeCIDSystemInfo(p); + writeVersionTypeName(p); + writeCodeSpaceRange(p); + writeCIDRange(p); + writeBFEntries(p); + writeWrapUp(p); + writeStreamAfterComments(p); + writeUseCMap(p); + add(p.toString()); + } + + protected void writePreStream(StringBuffer p) { // p.append("/Type /CMap\n"); // p.append(sysInfo.toPDFString()); - // p.append("/CMapName /" + name); - // p.append("\n"); + // p.append("/CMapName /" + name + EOL); + } + + protected void writeStreamComments(StringBuffer p) { p.append("%!PS-Adobe-3.0 Resource-CMap\n"); p.append("%%DocumentNeededResources: ProcSet (CIDInit)\n"); p.append("%%IncludeResource: ProcSet (CIDInit)\n"); p.append("%%BeginResource: CMap (" + name + ")\n"); p.append("%%EndComments\n"); + } + protected void writeCIDInit(StringBuffer p) { p.append("/CIDInit /ProcSet findresource begin\n"); p.append("12 dict begin\n"); p.append("begincmap\n"); + } + protected void writeCIDSystemInfo(StringBuffer p) { p.append("/CIDSystemInfo 3 dict dup begin\n"); p.append(" /Registry (Adobe) def\n"); p.append(" /Ordering (Identity) def\n"); p.append(" /Supplement 0 def\n"); p.append("end def\n"); + } + protected void writeVersionTypeName(StringBuffer p) { p.append("/CMapVersion 1 def\n"); p.append("/CMapType 1 def\n"); p.append("/CMapName /" + name + " def\n"); + } + protected void writeCodeSpaceRange(StringBuffer p) { p.append("1 begincodespacerange\n"); p.append("<0000> <FFFF>\n"); p.append("endcodespacerange\n"); + } + + protected void writeCIDRange(StringBuffer p) { p.append("1 begincidrange\n"); p.append("<0000> <FFFF> 0\n"); p.append("endcidrange\n"); + } + protected void writeBFEntries(StringBuffer p) { // p.append("1 beginbfrange\n"); // p.append("<0020> <0100> <0000>\n"); // p.append("endbfrange\n"); + } + protected void writeWrapUp(StringBuffer p) { p.append("endcmap\n"); p.append("CMapName currentdict /CMap defineresource pop\n"); p.append("end\n"); p.append("end\n"); + } + + protected void writeStreamAfterComments(StringBuffer p) { p.append("%%EndResource\n"); p.append("%%EOF\n"); + } + + protected void writeUseCMap(StringBuffer p) { /* - * p.append(" /Type /CMap\n/CMapName /" + name); - * p.append("\n"); - * p.append("\n/WMode "); p.append(wMode); + * p.append(" /Type /CMap"); + * p.append("/CMapName /" + name + EOL); + * p.append("/WMode " + wMode + EOL); * if (base != null) { - * p.append("\n/UseCMap "); + * p.append("/UseCMap "); * if (base instanceof String) { * p.append("/"+base); * } else {// base instanceof PDFStream @@ -480,4 +521,8 @@ public class PDFCMap extends PDFStream { */ } + protected int output(OutputStream stream) throws IOException { + fillInPDF(new StringBuffer()); + return super.output(stream); + } } |