]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Fix TrueType embedding. Width array did not reflect the subset. Was my bad.
authorJeremias Maerki <jeremias@apache.org>
Thu, 3 Apr 2003 12:53:44 +0000 (12:53 +0000)
committerJeremias Maerki <jeremias@apache.org>
Thu, 3 Apr 2003 12:53:44 +0000 (12:53 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196205 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/CIDFont.java
src/java/org/apache/fop/fonts/MultiByteFont.java
src/java/org/apache/fop/pdf/PDFFactory.java
src/java/org/apache/fop/render/pdf/FontReader.java

index 2697cda8edbaac05ed4b90ebb0fa9063188676c1..701b9be2f0c2992ae64b60758040de1533f8f945 100644 (file)
@@ -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
index 91694051ee4ae80b6bf5e1731110ede4c9c3fbf7..3195eb1dce578f1f5f4b6e4082d05e47c97beb14 100644 (file)
@@ -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);
-    }
+    }*/
 
 
     /**
index ceeba8915af60b1f3dd3e1bc7bdc311cc7b90805..ec5d772a687548e4da3e9efcc2d6704ad8c2afd8 100644 (file)
@@ -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);
 
index 08a55d4d4be849146135a08a844bad77286ab391..5a917b5743a863752000973a514ff20ceaa20d0c 100644 (file)
@@ -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)) {