]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Applied [PATCH] 43143 - ExpertEncoding and ExpertSubsetEncoding not detected for...
authorAdrian Cumiskey <acumiskey@apache.org>
Fri, 26 Oct 2007 19:20:02 +0000 (19:20 +0000)
committerAdrian Cumiskey <acumiskey@apache.org>
Fri, 26 Oct 2007 19:20:02 +0000 (19:20 +0000)
Many thanks to William (wliem AT allette DOT com DOT au) for reporting the problem.
NOTE: More work needs to be done to provide support for ExpertEncoding
(this is documented in src/codegen/fonts/encodings.xml within this patch).

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@588755 13f79535-47bb-0310-9956-ffa450edef68

src/codegen/fonts/code-point-mapping.xsl
src/codegen/fonts/encodings.xml
src/java/org/apache/fop/fonts/FontLoader.java
src/java/org/apache/fop/fonts/SingleByteFont.java
src/java/org/apache/fop/fonts/type1/PFMFile.java

index 7d0d6cd719a875e5d0a5918007e90206ae02d4f8..53636505d2232c822382ae63fa752278920cd6e7 100644 (file)
   <xsl:variable name='glyphlists'
                 select="document('glyphlist.xml')/glyphlist-set"/>
 
-  <xsl:template match="encoding-set">
+  <xsl:template match="encoding-set"> /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 package org.apache.fop.fonts;
 
 import java.util.Map;
@@ -31,26 +47,28 @@ public class CodePointMapping {
     private char[] latin1Map;
     private char[] characters;
     private char[] codepoints;
+
     private CodePointMapping(int [] table) {
         int nonLatin1 = 0;
         latin1Map = new char[256];
-        for(int i = 0; i &lt; table.length; i += 2) {
-           if(table[i+1] &lt; 256)
-               latin1Map[table[i+1]] = (char) table[i];
-           else
+        for (int i = 0; i &lt; table.length; i += 2) {
+           if (table[i + 1] &lt; 256) {
+               latin1Map[table[i + 1]] = (char) table[i];
+           } else {
                ++nonLatin1;
+           }
         }
         characters = new char[nonLatin1];
         codepoints = new char[nonLatin1];
         int top = 0;
-        for(int i = 0; i &lt; table.length; i += 2) {
-            char c = (char) table[i+1];
-            if(c >= 256) {
+        for (int i = 0; i &lt; table.length; i += 2) {
+            char c = (char) table[i + 1];
+            if (c >= 256) {
                ++top;
-               for(int j = top - 1; j >= 0; --j) {
-                   if(j > 0 &amp;&amp; characters[j-1] >= c) {
-                       characters[j] = characters[j-1];
-                       codepoints[j] = codepoints[j-1];
+               for (int j = top - 1; j >= 0; --j) {
+                   if (j > 0 &amp;&amp; characters[j - 1] >= c) {
+                       characters[j] = characters[j - 1];
+                       codepoints[j] = codepoints[j - 1];
                    } else {
                        characters[j] = c;
                        codepoints[j] = (char) table[i];
@@ -60,21 +78,23 @@ public class CodePointMapping {
             }
         }
     }
+
     public final char mapChar(char c) {
-        if(c &lt; 256) {
+        if (c &lt; 256) {
             return latin1Map[c];
         } else {
             int bot = 0, top = characters.length - 1;
-            while(top >= bot) {
+            while (top >= bot) {
                 int mid = (bot + top) / 2;
                 char mc = characters[mid];
 
-                if(c == mc)
+                if (c == mc) {
                     return codepoints[mid];
-                else if(c &lt; mc)
+                } else if (c &lt; mc) {
                     top = mid - 1;
-                else
+                } else {
                     bot = mid + 1;
+                }
             }
             return 0;
         }
@@ -86,19 +106,21 @@ public class CodePointMapping {
     }
     public static CodePointMapping getMapping(String encoding) {
         CodePointMapping mapping = (CodePointMapping) mappings.get(encoding);
-        if(mapping != null) {
+        if (mapping != null) {
             return mapping;
         } <xsl:apply-templates mode="get"/>
-        else {
-            return null;
+        //TODO: Implement support for Expert and ExpertSubset encoding
+        else if (encoding.startsWith("Expert")) {
+            throw new UnsupportedOperationException(encoding + " not implemented yet");
         }
+        throw new UnsupportedOperationException("Unknown encoding: " + encoding);
     }
 <xsl:apply-templates mode="table"/>
 }
   </xsl:template>
 
   <xsl:template match="encoding" mode="get">
-        else if(encoding.equals("<xsl:value-of select="@id"/>")) {
+        else if (encoding.equals("<xsl:value-of select="@id"/>")) {
             mapping = new CodePointMapping(enc<xsl:value-of select="@id"/>);
             mappings.put("<xsl:value-of select="@id"/>", mapping);
             return mapping;
index 85aabb21f6e8eee6f004ea2abbc76a619335dcc3..1f8497ee37a322e9c682fc049a4755836c95a673 100644 (file)
     <glyph codepoint='FD' name='a190'/>
     <glyph codepoint='FE' name='a191'/>
   </encoding>
+  <!-- 
+    TODO: Provide data for ExpertEncoding and ExpertSubsetEncoding
+    see http://www.adobe.com/devnet/font/pdfs/5176.CFF.pdf for details.
+  -->
 </encoding-set>
index 5dcb910899822614a1911f7117e1c71d78555933..f0246370ed77e31a2591215b0fd158c3c5455b2d 100644 (file)
@@ -94,11 +94,10 @@ public abstract class FontLoader {
     public static CustomFont loadFont(String fontFileURI, FontResolver resolver)\r
                 throws IOException {\r
         fontFileURI = fontFileURI.trim();\r
-        String name = fontFileURI.toLowerCase();\r
         String effURI;\r
         boolean type1 = isType1(fontFileURI);\r
         if (type1) {\r
-            effURI = name.substring(0, fontFileURI.length() - 4) + ".pfm";\r
+            effURI = fontFileURI.substring(0, fontFileURI.length() - 4) + ".pfm";
         } else {\r
             effURI = fontFileURI;\r
         }\r
index 248526c823436bcf1139bf8ae7c44823a4c5cdf1..402a630e817f3b0879adcc568ef4d2b3bbe47ab9 100644 (file)
@@ -47,7 +47,11 @@ public class SingleByteFont extends CustomFont {
      * Updates the mapping variable based on the encoding.
      */
     protected void updateMapping() {
-        mapping = CodePointMapping.getMapping(getEncoding()); 
+        try {
+            mapping = CodePointMapping.getMapping(getEncoding());
+        } catch (UnsupportedOperationException e) {
+            log.error("Font '" + super.getFontName() + "': " + e.getMessage());
+        }
     }
     
     /**
index f5225c97144ec3061a0d72b012a38137986d1cf6..8818f1a73e159ae8cf3f45d00b05652169303065 100644 (file)
@@ -302,7 +302,11 @@ public class PFMFile {
     public String getCharSetName() {
         switch (dfCharSet) {
         case 0:
-            return "WinAnsi";
+            return "WinAnsi"; // AKA ISOAdobe
+        case 1:
+            return "Expert";
+        case 2:
+            return "ExpertSubset";
         case 128:
             return "Shift-JIS (Japanese)";
         default: