aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/pdf/PDFT1Stream.java
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2003-03-27 10:59:05 +0000
committerJeremias Maerki <jeremias@apache.org>2003-03-27 10:59:05 +0000
commite71f657fa279852f046314e183ec816c03dbd0fa (patch)
treebe00922db7e8fc917c2bf66fff2d87be19bb20d1 /src/java/org/apache/fop/pdf/PDFT1Stream.java
parent5210ba0c1d489624cd4a2680a5fa93cbfa1fddbb (diff)
downloadxmlgraphics-fop-e71f657fa279852f046314e183ec816c03dbd0fa.tar.gz
xmlgraphics-fop-e71f657fa279852f046314e183ec816c03dbd0fa.zip
The Type1 font stream is now an AbstractPDFStream to bypass the need for an additional buffer.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196164 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/pdf/PDFT1Stream.java')
-rw-r--r--src/java/org/apache/fop/pdf/PDFT1Stream.java70
1 files changed, 34 insertions, 36 deletions
diff --git a/src/java/org/apache/fop/pdf/PDFT1Stream.java b/src/java/org/apache/fop/pdf/PDFT1Stream.java
index 47a594760..5d66ae8cd 100644
--- a/src/java/org/apache/fop/pdf/PDFT1Stream.java
+++ b/src/java/org/apache/fop/pdf/PDFT1Stream.java
@@ -52,7 +52,7 @@ package org.apache.fop.pdf;
// Java
import java.io.IOException;
-import java.io.UnsupportedEncodingException;
+import java.io.OutputStream;
// FOP
import org.apache.fop.fonts.type1.PFBData;
@@ -60,18 +60,21 @@ import org.apache.fop.fonts.type1.PFBData;
/**
* Special PDFStream for embedding Type 1 fonts.
*/
-public class PDFT1Stream extends PDFStream {
+public class PDFT1Stream extends AbstractPDFStream {
private PFBData pfb;
/**
- * @see org.apache.fop.pdf.PDFObject#PDFObject(int)
+ * @see org.apache.fop.pdf.AbstractPDFStream#getSizeHint()
*/
- public PDFT1Stream(int num) {
- super(num);
+ protected int getSizeHint() throws IOException {
+ if (this.pfb != null) {
+ return pfb.getLength();
+ } else {
+ return 0; //no hint available
+ }
}
-
/**
* Overload the base object method so we don't have to copy
* byte arrays around so much
@@ -82,48 +85,43 @@ public class PDFT1Stream extends PDFStream {
if (pfb == null) {
throw new IllegalStateException("pfb must not be null at this point");
}
- int length = 0;
- String filterEntry = applyFilters();
- String preData = this.number + " " + this.generation
- + " obj\n<< /Length " + pfb.getLength() + " "
- + filterEntry
- + " /Length1 " + pfb.getLength1()
- + " /Length2 " + pfb.getLength2()
- + " /Length3 " + pfb.getLength3() + " >>\n";
+ getDocumentSafely().getLogger().debug("Writing "
+ + pfb.getLength() + " bytes of Type 1 font data");
- byte[] p;
- try {
- p = preData.getBytes(PDFDocument.ENCODING);
- } catch (UnsupportedEncodingException ue) {
- p = preData.getBytes();
- }
-
- stream.write(p);
- length += p.length;
-
- length += outputStreamData(stream);
- try {
- p = "endobj\n".getBytes(PDFDocument.ENCODING);
- } catch (UnsupportedEncodingException ue) {
- p = "endobj\n".getBytes();
- }
- stream.write(p);
- length += p.length;
- //System.out.println("Embedded Type1 font");
+ int length = super.output(stream);
+ getDocumentSafely().getLogger().debug("Embedded Type1 font");
return length;
}
/**
+ * @see org.apache.fop.pdf.AbstractPDFStream#buildStreamDict(String)
+ */
+ protected String buildStreamDict(String lengthEntry) {
+ final String filterEntry = getFilterList().buildFilterDictEntries();
+ return (getObjectID()
+ + "<< /Length " + lengthEntry
+ + " /Length1 " + pfb.getLength1()
+ + " /Length2 " + pfb.getLength2()
+ + " /Length3 " + pfb.getLength3()
+ + "\n" + filterEntry
+ + "\n>>\n");
+ }
+
+ /**
+ * @see org.apache.fop.pdf.PDFStream#outputRawStreamData(OutputStream)
+ */
+ protected void outputRawStreamData(OutputStream out) throws IOException {
+ this.pfb.outputAllParts(out);
+ }
+
+ /**
* Used to set the PFBData object that represents the embeddable Type 1
* font.
* @param pfb The PFB file
* @throws IOException in case of an I/O problem
*/
public void setData(PFBData pfb) throws IOException {
- data.reset();
- // System.out.println("Writing " + size + " bytes of font data");
this.pfb = pfb;
- pfb.outputAllParts(data.getOutputStream());
}
}