From: Jeremias Maerki Date: Thu, 3 Apr 2003 12:53:44 +0000 (+0000) Subject: Fix TrueType embedding. Width array did not reflect the subset. Was my bad. X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1671 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6b9af7902e76938f4ec90003b2abba3d1c2ac629;p=xmlgraphics-fop.git Fix TrueType embedding. Width array did not reflect the subset. Was my bad. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196205 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fonts/CIDFont.java b/src/java/org/apache/fop/fonts/CIDFont.java index 2697cda8e..701b9be2f 100644 --- a/src/java/org/apache/fop/fonts/CIDFont.java +++ b/src/java/org/apache/fop/fonts/CIDFont.java @@ -50,6 +50,8 @@ */ package org.apache.fop.fonts; +import org.apache.fop.pdf.PDFWArray; + /** * Abstract base class for CID fonts. */ @@ -104,4 +106,12 @@ public abstract class CIDFont extends CustomFont { public boolean isMultiByte() { return true; } -} + + /** + * Returns a PDFWArray containing all the widths of the subset to be used. + * @return the character widths + * @todo Try to avoid dependency on PDF library + */ + public abstract PDFWArray getSubsetWidths(); + +} \ No newline at end of file diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index 91694051e..3195eb1dc 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -73,7 +73,7 @@ public class MultiByteFont extends CIDFont { private CIDFontType cidType = CIDFontType.CIDTYPE2; private String namePrefix = null; // Quasi unique prefix - private PDFWArray warray = new PDFWArray(); + //private PDFWArray warray = new PDFWArray(); private int width[] = null; private BFEntry[] bfentries = null; @@ -170,23 +170,6 @@ public class MultiByteFont extends CIDFont { } } -/* unused - public PDFWArray getWidthsAsPDFWArray() { - if (isEmbeddable()) { - // Create widths for reencoded chars - warray = new PDFWArray(); - int[] tmpWidth = new int[usedGlyphsCount]; - - for (int i = 0; i < usedGlyphsCount; i++) { - Integer nw = (Integer)usedGlyphsIndex.get(new Integer(i)); - int nwx = (nw == null) ? 0 : nw.intValue(); - tmpWidth[i] = width[nwx]; - } - warray.addEntry(0, tmpWidth); - } - return warray; - }*/ - /** * @see org.apache.fop.fonts.FontDescriptor#isEmbeddable() */ @@ -242,6 +225,23 @@ public class MultiByteFont extends CIDFont { return arr; } + /** + * @see org.apache.fop.fonts.CIDFont#getSubsetWidths() + */ + public PDFWArray getSubsetWidths() { + // Create widths for reencoded chars + PDFWArray warray = new PDFWArray(); + int[] tmpWidth = new int[usedGlyphsCount]; + + for (int i = 0; i < usedGlyphsCount; i++) { + Integer nw = (Integer)usedGlyphsIndex.get(new Integer(i)); + int nwx = (nw == null) ? 0 : nw.intValue(); + tmpWidth[i] = width[nwx]; + } + warray.addEntry(0, tmpWidth); + return warray; + } + /** * Remaps a codepoint based. * @param i codepoint to remap @@ -334,9 +334,10 @@ public class MultiByteFont extends CIDFont { * @param cidWidthIndex index * @param wds array of widths */ + /* public void addCIDWidthEntry(int cidWidthIndex, int[] wds) { this.warray.addEntry(cidWidthIndex, wds); - } + }*/ /** diff --git a/src/java/org/apache/fop/pdf/PDFFactory.java b/src/java/org/apache/fop/pdf/PDFFactory.java index ceeba8915..ec5d772a6 100644 --- a/src/java/org/apache/fop/pdf/PDFFactory.java +++ b/src/java/org/apache/fop/pdf/PDFFactory.java @@ -1023,7 +1023,7 @@ public class PDFFactory { new PDFCIDFont(basefont, cidMetrics.getCIDType(), cidMetrics.getDefaultWidth(), - cidMetrics.getWidths(), sysInfo, + cidMetrics.getSubsetWidths(), sysInfo, (PDFCIDFontDescriptor)pdfdesc); getDocument().registerObject(cidFont); diff --git a/src/java/org/apache/fop/render/pdf/FontReader.java b/src/java/org/apache/fop/render/pdf/FontReader.java index 08a55d4d4..5a917b574 100644 --- a/src/java/org/apache/fop/render/pdf/FontReader.java +++ b/src/java/org/apache/fop/render/pdf/FontReader.java @@ -304,7 +304,7 @@ public class FontReader extends DefaultHandler { wds[j++] = i.intValue(); } - multiFont.addCIDWidthEntry(cidWidthIndex, wds); + //multiFont.addCIDWidthEntry(cidWidthIndex, wds); multiFont.setWidthArray(wds); } else if ("bfranges".equals(localName)) {