From: Jeremias Maerki Date: Thu, 27 Mar 2003 11:00:34 +0000 (+0000) Subject: Adjust to the PDF Stream changes. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1708 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ee8e0333a8a4c781d30b78216b19d2e3c57e33fa;p=xmlgraphics-fop.git Adjust to the PDF Stream changes. TODO: This could still be optimized in a similar way as the PDFT1Stream (to avoid the additional buffer). git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196165 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/pdf/PDFTTFStream.java b/src/java/org/apache/fop/pdf/PDFTTFStream.java index dfab0facc..49c552653 100644 --- a/src/java/org/apache/fop/pdf/PDFTTFStream.java +++ b/src/java/org/apache/fop/pdf/PDFTTFStream.java @@ -61,11 +61,10 @@ public class PDFTTFStream extends PDFStream { /** * Main constructor - * @param num PDF object number * @param len original length */ - public PDFTTFStream(int num, int len) { - super(num); + public PDFTTFStream(int len) { + super(); origLength = len; } @@ -76,25 +75,26 @@ public class PDFTTFStream extends PDFStream { */ protected int output(java.io.OutputStream stream) throws java.io.IOException { - int length = 0; - String filterEntry = applyFilters(); - String preData = new String(this.number + " " + this.generation - + " obj\n<< /Length " - + (data.getSize() + 1) + " " + filterEntry - + " " + "/Length1 " + origLength - + " >>\n"); + getDocumentSafely().getLogger().debug("Writing " + + origLength + " bytes of TTF font data"); - byte[] p = preData.getBytes(); - stream.write(p); - length += p.length; - - length += outputStreamData(stream); - p = "endobj\n".getBytes(); - stream.write(p); - length += p.length; + int length = super.output(stream); + getDocumentSafely().getLogger().debug("Embedded TrueType/OpenType 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 " + origLength + + "\n" + filterEntry + + "\n>>\n"); + } + /** * Sets the TrueType font data. * @param data the font payload @@ -102,9 +102,7 @@ public class PDFTTFStream extends PDFStream { * @throws IOException in case of an I/O problem */ public void setData(byte[] data, int size) throws IOException { - this.data.reset(); - /**@todo Log using Logger */ - System.out.println("Writing " + size + " bytes of font data"); + this.data.clear(); this.data.getOutputStream().write(data, 0, size); }