Author: jeremias
Date: Mon Feb  9 16:58:29 2009
New Revision: 742620

URL: http://svn.apache.org/viewvc?rev=742620&view=rev
Log:
Added code to detect when a Type 1 font is not configured to use its native 
encoding. In such a case it needs to be re-encoded in PostScript. That used to 
always happen in earlier FOP versions but since support was added for all 
glyphs in a font, this has become a problem. So this change restores the 
behaviour of before when XML font metrics files or just the PFM are used.

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=742620&r1=742619&r2=742620&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/SingleByteFont.java Mon 
Feb  9 16:58:29 2009
@@ -36,6 +36,7 @@
     private  static Log log = LogFactory.getLog(SingleByteFont.class);
 
     private SingleByteEncoding mapping;
+    private boolean useNativeEncoding = false;
 
     private int[] width = null;
 
@@ -43,6 +44,7 @@
     //Map<Character, UnencodedCharacter>
     private List additionalEncodings;
 
+
     /**
      * Main constructor.
      */
@@ -192,6 +194,24 @@
     }
 
     /**
+     * Controls whether the font is configured to use its native encoding or 
if it
+     * may need to be re-encoded for the target format.
+     * @param value true indicates that the configured encoding is the font's 
native encoding
+     */
+    public void setUseNativeEncoding(boolean value) {
+        this.useNativeEncoding = value;
+    }
+
+    /**
+     * Indicates whether this font is configured to use its native encoding. 
This
+     * method is used to determine whether the font needs to be re-encoded.
+     * @return true if the font uses its native encoding.
+     */
+    public boolean isUsingNativeEncoding() {
+        return this.useNativeEncoding;
+    }
+
+    /**
      * Sets a width for a character.
      * @param index index of the character
      * @param w the width of the character

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=742620&r1=742619&r2=742620&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java 
(original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java 
Mon Feb  9 16:58:29 2009
@@ -139,6 +139,7 @@
         //Encoding
         if (afm != null) {
             String encoding = afm.getEncodingScheme();
+            singleFont.setUseNativeEncoding(true);
             if ("AdobeStandardEncoding".equals(encoding)) {
                 singleFont.setEncoding(CodePointMapping.STANDARD_ENCODING);
             } else {

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=742620&r1=742619&r2=742620&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/render/ps/PSFontUtils.java 
Mon Feb  9 16:58:29 2009
@@ -160,6 +160,12 @@
                 if (tf instanceof Base14Font) {
                     //Our Base 14 fonts don't use the default encoding
                     redefineFontEncoding(gen, tf.getFontName(), 
tf.getEncodingName());
+                } else if (tf instanceof SingleByteFont) {
+                    SingleByteFont sbf = (SingleByteFont)tf;
+                    if (!sbf.isUsingNativeEncoding()) {
+                        //Font has been configured to use an encoding other 
than the default one
+                        redefineFontEncoding(gen, tf.getFontName(), 
tf.getEncodingName());
+                    }
                 }
             }
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to