xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r1309921 [18/42] - in /xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...
Date Thu, 05 Apr 2012 16:20:17 GMT
Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.java Thu Apr  5 16:19:19 2012
@@ -71,4 +71,19 @@ public interface FontEventProducer exten
      */
     void glyphNotAvailable(Object source, char ch, String fontName);
 
+    /**
+     * An error occurred trying to find the font directory specified in the config file.
+     * @param source the event source
+     * @param dir the directory in the config file
+     * @event.severity WARN
+     */
+    void fontDirectoryNotFound(Object source, String dir);
+
+    /**
+     * The SVG text will be stroked as shapes.
+     * @param source the event source
+     * @param fontFamily the family name of the font that is being stroked
+     * @event.severity WARN
+     */
+    void svgTextStrokedAsShapes(Object source, String fontFamily);
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.xml?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontEventProducer.xml Thu Apr  5 16:19:19 2012
@@ -20,4 +20,6 @@
   <message key="fontSubstituted">Font "{requested}" not found. Substituting with "{effective}".</message>
   <message key="fontLoadingErrorAtAutoDetection">Unable to load font file: {fontURL}.[ Reason: {e}]</message>
   <message key="glyphNotAvailable">Glyph "{ch}" (0x{ch,hex}[, {ch,glyph-name}]) not available in font "{fontName}".</message>
+  <message key="fontDirectoryNotFound">The font directory {dir} could not be found.</message>
+  <message key="svgTextStrokedAsShapes">The SVG text for font {fontFamily} will be stroked as shapes.</message>
 </catalogue>

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfo.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfo.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfo.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfo.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,8 @@ package org.apache.fop.fonts;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.SortedSet;
 import java.util.TreeSet;
 
@@ -59,12 +57,6 @@ public class FontInfo {
     /** look up a font-name to get a font (that implements FontMetrics at least) */
     private Map<String, Typeface> fonts = null; //(String = font key)
 
-    /**
-     *  a collection of missing fonts; used to make sure the user gets
-     *  a warning for a missing font only once (not every time the font is used)
-     */
-    private Set<FontTriplet> loggedFontKeys = null;
-
     /** Cache for Font instances. */
     private Map<FontTriplet, Map<Integer, Font>> fontInstanceCache = null;
 
@@ -152,7 +144,7 @@ public class FontInfo {
             }
         }
         this.triplets.put(triplet, internalFontKey);
-        this.tripletPriorities.put(triplet, new Integer(newPriority));
+        this.tripletPriorities.put(triplet, Integer.valueOf(newPriority));
     }
 
     /**
@@ -316,7 +308,7 @@ public class FontInfo {
             sizes = new HashMap<Integer, Font>();
             getFontInstanceCache().put(triplet, sizes);
         }
-        Integer size = new Integer(fontSize);
+        Integer size = Integer.valueOf(fontSize);
         Font font = sizes.get(size);
         if (font == null) {
             String fontKey = getInternalFontKey(triplet);
@@ -453,22 +445,19 @@ public class FontInfo {
         return fontTriplets;
     }
 
-    private Set<FontTriplet> getLoggedFontKeys() {
-        if (loggedFontKeys == null) {
-            loggedFontKeys = new HashSet<FontTriplet>();
+    private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) {
+        if (this.eventListener != null) {
+            this.eventListener.fontSubstituted(this, replacedKey, newKey);
         }
-        return loggedFontKeys;
     }
 
-    private void notifyFontReplacement(FontTriplet replacedKey, FontTriplet newKey) {
-        if (!getLoggedFontKeys().contains(replacedKey)) {
-            getLoggedFontKeys().add(replacedKey);
-            if (this.eventListener != null) {
-                this.eventListener.fontSubstituted(this, replacedKey, newKey);
-            } else {
-                log.warn("Font '" + replacedKey + "' not found. "
-                        + "Substituting with '" + newKey + "'.");
-            }
+    /**
+     * Notify listeners that the SVG text for the given font will be stroked as shapes.
+     * @param fontFamily a SVG font family
+     */
+    public void notifyStrokingSVGTextAsShapes(String fontFamily) {
+        if (this.eventListener != null) {
+            this.eventListener.svgTextStrokedAsShapes(this, fontFamily);
         }
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfoConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfoConfigurator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfoConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontInfoConfigurator.java Thu Apr  5 16:19:19 2012
@@ -33,6 +33,7 @@ import org.apache.avalon.framework.confi
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.autodetect.FontFileFinder;
 import org.apache.fop.fonts.autodetect.FontInfoFinder;
@@ -88,7 +89,8 @@ public class FontInfoConfigurator {
             // native o/s search (autodetect) configuration
             boolean autodetectFonts = (fontsCfg.getChild("auto-detect", false) != null);
             if (autodetectFonts) {
-                FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict);
+                FontDetector fontDetector = new FontDetector(fontManager, fontAdder, strict,
+                        listener);
                 fontDetector.detect(fontInfoList);
             }
 
@@ -139,7 +141,7 @@ public class FontInfoConfigurator {
             }
 
             // add fonts found in directory
-            FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1);
+            FontFileFinder fontFileFinder = new FontFileFinder(recursive ? -1 : 1, listener);
             List<URL> fontURLList;
             try {
                 fontURLList = fontFileFinder.find(directory);
@@ -251,24 +253,30 @@ public class FontInfoConfigurator {
         }
 
         boolean useKerning = fontCfg.getAttributeAsBoolean("kerning", true);
+        boolean useAdvanced = fontCfg.getAttributeAsBoolean("advanced", true);
         EncodingMode encodingMode = EncodingMode.getValue(
                 fontCfg.getAttribute("encoding-mode", EncodingMode.AUTO.getName()));
         EmbeddingMode embeddingMode = EmbeddingMode.getValue(
                 fontCfg.getAttribute("embedding-mode", EmbeddingMode.AUTO.toString()));
         EmbedFontInfo embedFontInfo
-                = new EmbedFontInfo(metricsUrl, useKerning, tripletList, embedUrl, subFont);
+            = new EmbedFontInfo(metricsUrl, useKerning, useAdvanced, tripletList, embedUrl,
+                                subFont);
         embedFontInfo.setEncodingMode(encodingMode);
         embedFontInfo.setEmbeddingMode(embeddingMode);
 
+        boolean skipCachedFont = false;
         if (fontCache != null) {
             if (!fontCache.containsFont(embedFontInfo)) {
                 fontCache.addFont(embedFontInfo);
+            } else {
+                skipCachedFont = true;
             }
         }
 
         if (log.isDebugEnabled()) {
             String embedFile = embedFontInfo.getEmbedFile();
-            log.debug("Adding font " + (embedFile != null ? embedFile + ", " : "")
+            log.debug( ( skipCachedFont ? "Skipping (cached) font " : "Adding font " )
+                    + (embedFile != null ? embedFile + ", " : "")
                     + "metric file " + embedFontInfo.getMetricsFile());
             for (int j = 0; j < tripletList.size(); ++j) {
                 FontTriplet triplet = tripletList.get(j);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontLoader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontLoader.java Thu Apr  5 16:19:19 2012
@@ -42,31 +42,36 @@ public abstract class FontLoader {
     protected static final Log log = LogFactory.getLog(FontLoader.class);
 
     /** URI representing the font file */
-    protected String fontFileURI = null;
+    protected String fontFileURI;
     /** the FontResolver to use for font URI resolution */
-    protected FontResolver resolver = null;
+    protected FontResolver resolver;
     /** the loaded font */
-    protected CustomFont returnFont = null;
+    protected CustomFont returnFont;
 
     /** true if the font has been loaded */
-    protected boolean loaded = false;
+    protected boolean loaded;
     /** true if the font will be embedded, false if it will be referenced only. */
-    protected boolean embedded = true;
-    /** true if kerning information shall be loaded if available. */
-    protected boolean useKerning = true;
+    protected boolean embedded;
+    /** true if kerning information false be loaded if available. */
+    protected boolean useKerning;
+    /** true if advanced typographic information shall be loaded if available. */
+    protected boolean useAdvanced;
 
     /**
      * Default constructor.
      * @param fontFileURI the URI to the PFB file of a Type 1 font
      * @param embedded indicates whether the font is embedded or referenced
      * @param useKerning indicates whether kerning information shall be loaded if available
+     * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+     * available
      * @param resolver the font resolver used to resolve URIs
      */
     public FontLoader(String fontFileURI, boolean embedded, boolean useKerning,
-            FontResolver resolver) {
+            boolean useAdvanced, FontResolver resolver) {
         this.fontFileURI = fontFileURI;
         this.embedded = embedded;
         this.useKerning = useKerning;
+        this.useAdvanced = useAdvanced;
         this.resolver = resolver;
     }
 
@@ -107,7 +112,7 @@ public abstract class FontLoader {
             boolean embedded, EmbeddingMode embeddingMode, EncodingMode encodingMode,
             FontResolver resolver) throws IOException {
         return loadFont(fontUrl.toExternalForm(), subFontName,
-                embedded, embeddingMode, encodingMode, true,
+                embedded, embeddingMode, encodingMode, true, true,
                 resolver);
     }
 
@@ -119,13 +124,15 @@ public abstract class FontLoader {
      * @param embeddingMode the embedding mode of the font
      * @param encodingMode the requested encoding mode
      * @param useKerning indicates whether kerning information should be loaded if available
+     * @param useAdvanced indicates whether advanced typographic information shall be loaded if
+     * available
      * @param resolver the font resolver to use when resolving URIs
      * @return the newly loaded font
      * @throws IOException In case of an I/O error
      */
     public static CustomFont loadFont(String fontFileURI, String subFontName,
             boolean embedded, EmbeddingMode embeddingMode, EncodingMode encodingMode,
-            boolean useKerning, FontResolver resolver) throws IOException {
+            boolean useKerning, boolean useAdvanced, FontResolver resolver) throws IOException {
         fontFileURI = fontFileURI.trim();
         boolean type1 = isType1(fontFileURI);
         FontLoader loader;
@@ -141,7 +148,7 @@ public abstract class FontLoader {
             loader = new Type1FontLoader(fontFileURI, embedded, useKerning, resolver);
         } else {
             loader = new TTFFontLoader(fontFileURI, subFontName,
-                    embedded, embeddingMode, encodingMode, useKerning, resolver);
+                    embedded, embeddingMode, encodingMode, useKerning, useAdvanced, resolver);
         }
         return loader.getFont();
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManager.java Thu Apr  5 16:19:19 2012
@@ -224,16 +224,32 @@ public class FontManager {
         getFontSubstitutions().adjustFontInfo(fontInfo);
     }
 
-    /** @return a new FontResolver to be used by the font subsystem */
-    public static FontResolver createMinimalFontResolver() {
-        return new FontResolver() {
-
-            /** {@inheritDoc} */
-            public Source resolve(String href) {
-                //Minimal functionality here
-                return new StreamSource(href);
-            }
-        };
+    /**
+     * Minimum implemenation of FontResolver.
+     */
+    public static class MinimalFontResolver implements FontResolver {
+        private boolean useComplexScriptFeatures;
+        MinimalFontResolver(boolean useComplexScriptFeatures) {
+            this.useComplexScriptFeatures = useComplexScriptFeatures;
+        }
+        /** {@inheritDoc} */
+        public Source resolve(String href) {
+            //Minimal functionality here
+            return new StreamSource(href);
+        }
+        /** {@inheritDoc} */
+        public boolean isComplexScriptFeaturesEnabled() {
+            return useComplexScriptFeatures;
+        }
+    }
+
+    /**
+     * Create minimal font resolver.
+     * @param useComplexScriptFeatures true if complex script features enabled
+     * @return a new FontResolver to be used by the font subsystem
+     */
+    public static FontResolver createMinimalFontResolver(boolean useComplexScriptFeatures) {
+        return new MinimalFontResolver ( useComplexScriptFeatures );
     }
 
     /**

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManagerConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManagerConfigurator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManagerConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontManagerConfigurator.java Thu Apr  5 16:19:19 2012
@@ -21,6 +21,7 @@ package org.apache.fop.fonts;
 
 import java.io.File;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -28,6 +29,7 @@ import org.apache.avalon.framework.confi
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fonts.substitute.FontSubstitutions;
 import org.apache.fop.fonts.substitute.FontSubstitutionsConfigurator;
@@ -43,6 +45,8 @@ public class FontManagerConfigurator {
 
     private final Configuration cfg;
 
+    private URI baseURI = null;
+
     /**
      * Main constructor
      * @param cfg the font manager configuration object
@@ -52,6 +56,16 @@ public class FontManagerConfigurator {
     }
 
     /**
+     * Main constructor
+     * @param cfg the font manager configuration object
+     * @param baseURI the base URI of the configuration
+     */
+    public FontManagerConfigurator(Configuration cfg, URI baseURI) {
+        this.cfg = cfg;
+        this.baseURI = baseURI;
+    }
+
+    /**
      * Initializes font settings from the user configuration
      * @param fontManager a font manager
      * @param strict true if strict checking of the configuration is enabled
@@ -74,13 +88,29 @@ public class FontManagerConfigurator {
             }
         }
         if (cfg.getChild("font-base", false) != null) {
+            String path = cfg.getChild("font-base").getValue(null);
+            if (baseURI != null) {
+                path = baseURI.resolve(path).normalize().toString();
+            }
             try {
-                fontManager.setFontBaseURL(cfg.getChild("font-base").getValue(null));
+                fontManager.setFontBaseURL(path);
             } catch (MalformedURLException mfue) {
                 LogUtil.handleException(log, mfue, true);
             }
         }
 
+        // [GA] permit configuration control over base14 kerning; without this,
+        // there is no way for a user to enable base14 kerning other than by
+        // programmatic API;
+        if (cfg.getChild("base14-kerning", false) != null) {
+            try {
+                fontManager
+                    .setBase14KerningEnabled(cfg.getChild("base14-kerning").getValueAsBoolean());
+            } catch (ConfigurationException e) {
+                LogUtil.handleException(log, e, true);
+            }
+        }
+
         // global font configuration
         Configuration fontsCfg = cfg.getChild("fonts", false);
         if (fontsCfg != null) {

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontReader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontReader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontReader.java Thu Apr  5 16:19:19 2012
@@ -52,7 +52,7 @@ import org.apache.fop.fonts.apps.TTFRead
  */
 public class FontReader extends DefaultHandler {
 
-    private Locator locator = null;
+    // private Locator locator = null; // not used at present
     private boolean isCID = false;
     private CustomFont returnFont = null;
     private MultiByteFont multiFont = null;
@@ -117,6 +117,14 @@ public class FontReader extends DefaultH
     }
 
     /**
+     * Enable/disable use of advanced typographic features for the font
+     * @param enabled true to enable, false to disable
+     */
+    public void setAdvancedEnabled(boolean enabled) {
+        returnFont.setAdvancedEnabled(enabled);
+    }
+
+    /**
      * Sets the font resolver. Needed for URI resolution.
      * @param resolver the font resolver
      */
@@ -155,7 +163,7 @@ public class FontReader extends DefaultH
      */
     @Override
     public void setDocumentLocator(Locator locator) {
-        this.locator = locator;
+        // this.locator = locator; // not used at present
     }
 
     /**
@@ -215,6 +223,7 @@ public class FontReader extends DefaultH
             currentKerning.put(new Integer(attributes.getValue("kpx2")),
                                new Integer(attributes.getValue("kern")));
         }
+
     }
 
     private int getInt(String str) throws SAXException {
@@ -310,6 +319,5 @@ public class FontReader extends DefaultH
     public void characters(char[] ch, int start, int length) {
         text.append(ch, start, length);
     }
-}
-
 
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontResolver.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontResolver.java Thu Apr  5 16:19:19 2012
@@ -36,4 +36,10 @@ public interface FontResolver {
      */
     Source resolve(String href);
 
+    /**
+     * Check whether complex script features are enabled.
+     * @return true if FOP is to use complex script features
+     */
+    boolean isComplexScriptFeaturesEnabled();
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontSetup.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/FontSetup.java Thu Apr  5 16:19:19 2012
@@ -57,9 +57,10 @@ public final class FontSetup {
     /**
      * Sets up a font info
      * @param fontInfo font info
+     * @param base14Kerning true if base14 kerning applies
      */
-    public static void setup(FontInfo fontInfo) {
-        setup(fontInfo, null, null);
+    public static void setup(FontInfo fontInfo, boolean base14Kerning) {
+        setup(fontInfo, null, null, base14Kerning);
     }
 
     /**
@@ -71,10 +72,10 @@ public final class FontSetup {
      * @param fontInfo the font info object to set up
      * @param embedFontInfoList a list of EmbedFontInfo objects
      * @param resolver the font resolver
+     * @param base14Kerning true if base14 kerning applies
      */
     public static void setup(FontInfo fontInfo, List<EmbedFontInfo> embedFontInfoList,
-            FontResolver resolver) {
-        final boolean base14Kerning = false;
+                             FontResolver resolver, boolean base14Kerning) {
         fontInfo.addMetrics("F1", new Helvetica(base14Kerning));
         fontInfo.addMetrics("F2", new HelveticaOblique(base14Kerning));
         fontInfo.addMetrics("F3", new HelveticaBold(base14Kerning));
@@ -180,7 +181,7 @@ public final class FontSetup {
         final int startNum = 15;
 
         /* Add configured fonts */
-        addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver);
+        addConfiguredFonts(fontInfo, embedFontInfoList, startNum, resolver, base14Kerning);
     }
 
     /**
@@ -191,14 +192,17 @@ public final class FontSetup {
      * @param resolver the font resolver
      */
     private static void addConfiguredFonts(FontInfo fontInfo,
-            List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver) {
+            List<EmbedFontInfo> embedFontInfoList, int num, FontResolver resolver,
+            boolean base14Kerning) {
         if (embedFontInfoList == null) {
             return; //No fonts to process
         }
 
         if (resolver == null) {
             //Ensure that we have minimal font resolution capabilities
-            resolver = createMinimalFontResolver();
+            //None of the built-in base14 fonts have advanced typographic data
+            boolean useAdvanced = false;
+            resolver = createMinimalFontResolver(useAdvanced);
         }
 
         String internalName = null;
@@ -218,15 +222,31 @@ public final class FontSetup {
         }
     }
 
-    /** @return a new FontResolver to be used by the font subsystem */
-    public static FontResolver createMinimalFontResolver() {
-        return new FontResolver() {
-
-            /** {@inheritDoc} */
-            public Source resolve(String href) {
-                //Minimal functionality here
-                return new StreamSource(href);
-            }
-        };
+    /**
+     * Minimum implemenation of FontResolver.
+     */
+    public static class MinimalFontResolver implements FontResolver {
+        private boolean useComplexScriptFeatures;
+        MinimalFontResolver(boolean useComplexScriptFeatures) {
+            this.useComplexScriptFeatures = useComplexScriptFeatures;
+        }
+        /** {@inheritDoc} */
+        public Source resolve(String href) {
+            //Minimal functionality here
+            return new StreamSource(href);
+        }
+        /** {@inheritDoc} */
+        public boolean isComplexScriptFeaturesEnabled() {
+            return useComplexScriptFeatures;
+        }
+    }
+
+    /**
+     * Create minimal font resolver.
+     * @param useComplexScriptFeatures true if complex script features enabled
+     * @return a new FontResolver to be used by the font subsystem
+     */
+    public static FontResolver createMinimalFontResolver(boolean useComplexScriptFeatures) {
+        return new MinimalFontResolver ( useComplexScriptFeatures );
     }
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/LazyFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/LazyFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/LazyFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/LazyFont.java Thu Apr  5 16:19:19 2012
@@ -31,27 +31,31 @@ import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.fop.apps.FOPException;
 import org.xml.sax.InputSource;
+import org.apache.fop.complexscripts.fonts.Positionable;
+import org.apache.fop.complexscripts.fonts.Substitutable;
+
 
 /**
  * This class is used to defer the loading of a font until it is really used.
  */
-public class LazyFont extends Typeface implements FontDescriptor {
+public class LazyFont extends Typeface implements FontDescriptor, Substitutable, Positionable {
 
     private static Log log = LogFactory.getLog(LazyFont.class);
 
-    private String metricsFileName = null;
-    private String fontEmbedPath = null;
-    private boolean useKerning = false;
+    private String metricsFileName;
+    private String fontEmbedPath;
+    private boolean useKerning;
+    private boolean useAdvanced;
     private EncodingMode encodingMode = EncodingMode.AUTO;
     private EmbeddingMode embeddingMode = EmbeddingMode.AUTO;
     private boolean embedded = true;
-    private String subFontName = null;
+    private String subFontName;
 
-    private boolean isMetricsLoaded = false;
-    private Typeface realFont = null;
-    private FontDescriptor realFontDescriptor = null;
+    private boolean isMetricsLoaded;
+    private Typeface realFont;
+    private FontDescriptor realFontDescriptor;
 
-    private FontResolver resolver = null;
+    private FontResolver resolver;
 
     /**
      * Main constructor
@@ -63,6 +67,11 @@ public class LazyFont extends Typeface i
         this.metricsFileName = fontInfo.getMetricsFile();
         this.fontEmbedPath = fontInfo.getEmbedFile();
         this.useKerning = fontInfo.getKerning();
+        if ( resolver != null ) {
+            this.useAdvanced = resolver.isComplexScriptFeaturesEnabled();
+        } else {
+            this.useAdvanced = fontInfo.getAdvanced();
+        }
         this.encodingMode = fontInfo.getEncodingMode();
         this.embeddingMode = fontInfo.getEmbeddingMode();
         this.subFontName = fontInfo.getSubFontName();
@@ -72,8 +81,14 @@ public class LazyFont extends Typeface i
 
     /** {@inheritDoc} */
     public String toString() {
-        return ( "metrics-url=" + metricsFileName + ", embed-url=" + fontEmbedPath
-                + ", kerning=" + useKerning );
+        StringBuffer sbuf = new StringBuffer(super.toString());
+        sbuf.append('{');
+        sbuf.append("metrics-url=" + metricsFileName);
+        sbuf.append(",embed-url=" + fontEmbedPath);
+        sbuf.append(",kerning=" + useKerning);
+        sbuf.append(",advanced=" + useAdvanced);
+        sbuf.append('}');
+        return sbuf.toString();
     }
 
     private void load(boolean fail) {
@@ -122,6 +137,7 @@ public class LazyFont extends Typeface i
                                     new URL(metricsFileName).openStream()));
                     }
                     reader.setKerningEnabled(useKerning);
+                    reader.setAdvancedEnabled(useAdvanced);
                     if (this.embedded) {
                         reader.setFontEmbedPath(fontEmbedPath);
                     }
@@ -133,7 +149,7 @@ public class LazyFont extends Typeface i
                     }
                     realFont = FontLoader.loadFont(fontEmbedPath, subFontName,
                             embedded, embeddingMode, encodingMode,
-                            useKerning, resolver);
+                            useKerning, useAdvanced, resolver);
                 }
                 if (realFont instanceof FontDescriptor) {
                     realFontDescriptor = (FontDescriptor) realFont;
@@ -376,5 +392,91 @@ public class LazyFont extends Typeface i
         return realFontDescriptor.isEmbeddable();
     }
 
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performsSubstitution() {
+        load(true);
+        if ( realFontDescriptor instanceof Substitutable ) {
+            return ((Substitutable)realFontDescriptor).performsSubstitution();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public CharSequence performSubstitution ( CharSequence cs, String script, String language ) {
+        load(true);
+        if ( realFontDescriptor instanceof Substitutable ) {
+            return ((Substitutable)realFontDescriptor).performSubstitution(cs, script, language);
+        } else {
+            return cs;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public CharSequence reorderCombiningMarks
+        ( CharSequence cs, int[][] gpa, String script, String language ) {
+        load(true);
+        if ( realFontDescriptor instanceof Substitutable ) {
+            return ((Substitutable)realFontDescriptor)
+                .reorderCombiningMarks(cs, gpa, script, language);
+        } else {
+            return cs;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean performsPositioning() {
+        load(true);
+        if ( realFontDescriptor instanceof Positionable ) {
+            return ((Positionable)realFontDescriptor).performsPositioning();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int[][]
+        performPositioning ( CharSequence cs, String script, String language, int fontSize ) {
+        load(true);
+        if ( realFontDescriptor instanceof Positionable ) {
+            return ((Positionable)realFontDescriptor)
+                .performPositioning(cs, script, language, fontSize);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public int[][]
+        performPositioning ( CharSequence cs, String script, String language ) {
+        load(true);
+        if ( realFontDescriptor instanceof Positionable ) {
+            return ((Positionable)realFontDescriptor)
+                .performPositioning(cs, script, language);
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    public boolean isSubsetEmbedded() {
+        load(true);
+        return realFont.isMultiByte();
+    }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MultiByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MultiByteFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MultiByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MultiByteFont.java Thu Apr  5 16:19:19 2012
@@ -19,17 +19,29 @@
 
 package org.apache.fop.fonts;
 
-//Java
-import java.text.DecimalFormat;
+import java.nio.CharBuffer;
+import java.nio.IntBuffer;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.fop.complexscripts.fonts.GlyphDefinitionTable;
+import org.apache.fop.complexscripts.fonts.GlyphPositioningTable;
+import org.apache.fop.complexscripts.fonts.GlyphSubstitutionTable;
+import org.apache.fop.complexscripts.fonts.Positionable;
+import org.apache.fop.complexscripts.fonts.Substitutable;
+import org.apache.fop.complexscripts.util.GlyphSequence;
+import org.apache.fop.util.CharUtilities;
 
 /**
  * Generic MultiByte (CID) font
  */
-public class MultiByteFont extends CIDFont {
+public class MultiByteFont extends CIDFont implements Substitutable, Positionable {
 
-    private static int uniqueCounter = -1;
+    /** logging instance */
+    private static final Log log // CSOK: ConstantNameCheck
+        = LogFactory.getLog(MultiByteFont.class);
 
     private String ttcName = null;
     private String encoding = "Identity-H";
@@ -37,36 +49,27 @@ public class MultiByteFont extends CIDFo
     private int defaultWidth = 0;
     private CIDFontType cidType = CIDFontType.CIDTYPE2;
 
-    private String namePrefix = null;    // Quasi unique prefix
-
     private CIDSubset subset = new CIDSubset();
 
+    /* advanced typographic support */
+    private GlyphDefinitionTable gdef;
+    private GlyphSubstitutionTable gsub;
+    private GlyphPositioningTable gpos;
+
+    /* dynamic private use (character) mappings */
+    private int numMapped;
+    private int numUnmapped;
+    private int nextPrivateUse = 0xE000;
+    private int firstPrivate;
+    private int lastPrivate;
+    private int firstUnmapped;
+    private int lastUnmapped;
+
     /**
      * Default constructor
      */
     public MultiByteFont() {
-        // Make sure that the 3 first glyphs are included
-        subset.setupFirstThreeGlyphs();
-
-        // Create a quasiunique prefix for fontname
-        synchronized (this.getClass()) {
-            uniqueCounter++;
-            if (uniqueCounter > 99999 || uniqueCounter < 0) {
-                uniqueCounter = 0; //We need maximum 5 character then we start again
-            }
-        }
-        DecimalFormat counterFormat = new DecimalFormat("00000");
-        String cntString = counterFormat.format(uniqueCounter);
-
-        //Subset prefix as described in chapter 5.5.3 of PDF 1.4
-        StringBuffer sb = new StringBuffer("E");
-        for (int i = 0, c = cntString.length(); i < c; i++) {
-            //translate numbers to uppercase characters
-            sb.append((char)(cntString.charAt(i) + (65 - 48)));
-        }
-        sb.append("+");
-        namePrefix = sb.toString();
-
+        subset.setupFirstGlyph();
         setFontType(FontType.TYPE0);
     }
 
@@ -108,15 +111,11 @@ public class MultiByteFont extends CIDFo
         this.cidType = cidType;
     }
 
-    private String getPrefixedFontName() {
-        return namePrefix + FontUtil.stripWhiteSpace(super.getFontName());
-    }
-
     /** {@inheritDoc} */
     @Override
     public String getEmbedFontName() {
         if (isEmbeddable()) {
-            return getPrefixedFontName();
+            return FontUtil.stripWhiteSpace(super.getFontName());
         } else {
             return super.getFontName();
         }
@@ -127,6 +126,10 @@ public class MultiByteFont extends CIDFo
         return !(getEmbedFileName() == null && getEmbedResourceName() == null);
     }
 
+    public boolean isSubsetEmbedded() {
+        return true;
+    }
+
     /** {@inheritDoc} */
     @Override
     public CIDSubset getCIDSubset() {
@@ -162,7 +165,8 @@ public class MultiByteFont extends CIDFo
      * @param c the Unicode character index
      * @return the glyph index (or 0 if the glyph is not available)
      */
-    private int findGlyphIndex(char c) {
+    // [TBD] - needs optimization, i.e., change from linear search to binary search
+    private int findGlyphIndex(int c) {
         int idx = c;
         int retIdx = SingleByteEncoding.NOT_FOUND_CODE_POINT;
 
@@ -178,6 +182,95 @@ public class MultiByteFont extends CIDFo
         return retIdx;
     }
 
+    /**
+     * Add a private use mapping {PU,GI} to the existing BFENTRIES map.
+     * N.B. Does not insert in order, merely appends to end of existing map.
+     */
+    private synchronized void addPrivateUseMapping ( int pu, int gi ) {
+        assert findGlyphIndex ( pu ) == SingleByteEncoding.NOT_FOUND_CODE_POINT;
+        BFEntry[] bfeOld = cmap;
+        int       bfeCnt = bfeOld.length;
+        BFEntry[] bfeNew = new BFEntry [ bfeCnt + 1 ];
+        System.arraycopy ( bfeOld, 0, bfeNew, 0, bfeCnt );
+        bfeNew [ bfeCnt ] = new BFEntry ( pu, pu, gi );
+        cmap = bfeNew;
+    }
+
+    /**
+     * Given a glyph index, create a new private use mapping, augmenting the bfentries
+     * table. This is needed to accommodate the presence of an (output) glyph index in a
+     * complex script glyph substitution that does not correspond to a character in the
+     * font's CMAP.  The creation of such private use mappings is deferred until an
+     * attempt is actually made to perform the reverse lookup from the glyph index. This
+     * is necessary in order to avoid exhausting the private use space on fonts containing
+     * many such non-mapped glyph indices, if these mappings had been created statically
+     * at font load time.
+     * @param gi glyph index
+     * @returns unicode scalar value
+     */
+    private int createPrivateUseMapping ( int gi ) {
+        while ( ( nextPrivateUse < 0xF900 )
+                && ( findGlyphIndex(nextPrivateUse) != SingleByteEncoding.NOT_FOUND_CODE_POINT ) ) {
+            nextPrivateUse++;
+        }
+        if ( nextPrivateUse < 0xF900 ) {
+            int pu = nextPrivateUse;
+            addPrivateUseMapping ( pu, gi );
+            if ( firstPrivate == 0 ) {
+                firstPrivate = pu;
+            }
+            lastPrivate = pu;
+            numMapped++;
+            if (log.isDebugEnabled()) {
+                log.debug ( "Create private use mapping from "
+                            + CharUtilities.format ( pu )
+                            + " to glyph index " + gi
+                            + " in font '" + getFullName() + "'" );
+            }
+            return pu;
+        } else {
+            if ( firstUnmapped == 0 ) {
+                firstUnmapped = gi;
+            }
+            lastUnmapped = gi;
+            numUnmapped++;
+            log.warn ( "Exhausted private use area: unable to map "
+                       + numUnmapped + " glyphs in glyph index range ["
+                       + firstUnmapped + "," + lastUnmapped
+                       + "] (inclusive) of font '" + getFullName() + "'" );
+            return 0;
+        }
+    }
+
+    /**
+     * Returns the Unicode scalar value that corresponds to the glyph index. If more than
+     * one correspondence exists, then the first one is returned (ordered by bfentries[]).
+     * @param gi glyph index
+     * @returns unicode scalar value
+     */
+    // [TBD] - needs optimization, i.e., change from linear search to binary search
+    private int findCharacterFromGlyphIndex ( int gi, boolean augment ) {
+        int cc = 0;
+        for ( int i = 0, n = cmap.length; i < n; i++ ) {
+            BFEntry be = cmap [ i ];
+            int s = be.getGlyphStartIndex();
+            int e = s + ( be.getUnicodeEnd() - be.getUnicodeStart() );
+            if ( ( gi >= s ) && ( gi <= e ) ) {
+                cc = be.getUnicodeStart() + ( gi - s );
+                break;
+            }
+        }
+        if ( ( cc == 0 ) && augment ) {
+            cc = createPrivateUseMapping ( gi );
+        }
+        return cc;
+    }
+
+    private int findCharacterFromGlyphIndex ( int gi ) {
+        return findCharacterFromGlyphIndex ( gi, true );
+    }
+
+
     /** {@inheritDoc} */
     @Override
     public char mapChar(char c) {
@@ -257,5 +350,222 @@ public class MultiByteFont extends CIDFo
         }
         return subset.getSubsetChars();
     }
+
+    /**
+     * Establishes the glyph definition table.
+     * @param gdef the glyph definition table to be used by this font
+     */
+    public void setGDEF ( GlyphDefinitionTable gdef ) {
+        if ( ( this.gdef == null ) || ( gdef == null ) ) {
+            this.gdef = gdef;
+        } else {
+            throw new IllegalStateException ( "font already associated with GDEF table" );
+        }
+    }
+
+    /**
+     * Obtain glyph definition table.
+     * @return glyph definition table or null if none is associated with font
+     */
+    public GlyphDefinitionTable getGDEF() {
+        return gdef;
+    }
+
+    /**
+     * Establishes the glyph substitution table.
+     * @param gsub the glyph substitution table to be used by this font
+     */
+    public void setGSUB ( GlyphSubstitutionTable gsub ) {
+        if ( ( this.gsub == null ) || ( gsub == null ) ) {
+            this.gsub = gsub;
+        } else {
+            throw new IllegalStateException ( "font already associated with GSUB table" );
+        }
+    }
+
+    /**
+     * Obtain glyph substitution table.
+     * @return glyph substitution table or null if none is associated with font
+     */
+    public GlyphSubstitutionTable getGSUB() {
+        return gsub;
+    }
+
+    /**
+     * Establishes the glyph positioning table.
+     * @param gpos the glyph positioning table to be used by this font
+     */
+    public void setGPOS ( GlyphPositioningTable gpos ) {
+        if ( ( this.gpos == null ) || ( gpos == null ) ) {
+            this.gpos = gpos;
+        } else {
+            throw new IllegalStateException ( "font already associated with GPOS table" );
+        }
+    }
+
+    /**
+     * Obtain glyph positioning table.
+     * @return glyph positioning table or null if none is associated with font
+     */
+    public GlyphPositioningTable getGPOS() {
+        return gpos;
+    }
+
+    /** {@inheritDoc} */
+    public boolean performsSubstitution() {
+        return gsub != null;
+    }
+
+    /** {@inheritDoc} */
+    public CharSequence performSubstitution ( CharSequence cs, String script, String language ) {
+        if ( gsub != null ) {
+            GlyphSequence igs = mapCharsToGlyphs ( cs );
+            GlyphSequence ogs = gsub.substitute ( igs, script, language );
+            CharSequence ocs = mapGlyphsToChars ( ogs );
+            return ocs;
+        } else {
+            return cs;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public CharSequence reorderCombiningMarks
+        ( CharSequence cs, int[][] gpa, String script, String language ) {
+        if ( gdef != null ) {
+            GlyphSequence igs = mapCharsToGlyphs ( cs );
+            GlyphSequence ogs = gdef.reorderCombiningMarks ( igs, gpa, script, language );
+            CharSequence ocs = mapGlyphsToChars ( ogs );
+            return ocs;
+        } else {
+            return cs;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public boolean performsPositioning() {
+        return gpos != null;
+    }
+
+    /** {@inheritDoc} */
+    public int[][]
+        performPositioning ( CharSequence cs, String script, String language, int fontSize ) {
+        if ( gpos != null ) {
+            GlyphSequence gs = mapCharsToGlyphs ( cs );
+            int[][] adjustments = new int [ gs.getGlyphCount() ] [ 4 ];
+            if ( gpos.position ( gs, script, language, fontSize, this.width, adjustments ) ) {
+                return scaleAdjustments ( adjustments, fontSize );
+            } else {
+                return null;
+            }
+        } else {
+            return null;
+        }
+    }
+
+    /** {@inheritDoc} */
+    public int[][] performPositioning ( CharSequence cs, String script, String language ) {
+        throw new UnsupportedOperationException();
+    }
+
+
+    private int[][] scaleAdjustments ( int[][] adjustments, int fontSize ) {
+        if ( adjustments != null ) {
+            for ( int i = 0, n = adjustments.length; i < n; i++ ) {
+                int[] gpa = adjustments [ i ];
+                for ( int k = 0; k < 4; k++ ) {
+                    gpa [ k ] = ( gpa [ k ] * fontSize ) / 1000;
+                }
+            }
+            return adjustments;
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Map sequence CS, comprising a sequence of UTF-16 encoded Unicode Code Points, to
+     * an output character sequence GS, comprising a sequence of Glyph Indices. N.B. Unlike
+     * mapChar(), this method does not make use of embedded subset encodings.
+     * @param cs a CharSequence containing UTF-16 encoded Unicode characters
+     * @returns a CharSequence containing glyph indices
+     */
+    private GlyphSequence mapCharsToGlyphs ( CharSequence cs ) {
+        IntBuffer cb = IntBuffer.allocate ( cs.length() );
+        IntBuffer gb = IntBuffer.allocate ( cs.length() );
+        int gi;
+        int giMissing = findGlyphIndex ( Typeface.NOT_FOUND );
+        for ( int i = 0, n = cs.length(); i < n; i++ ) {
+            int cc = cs.charAt ( i );
+            if ( ( cc >= 0xD800 ) && ( cc < 0xDC00 ) ) {
+                if ( ( i + 1 ) < n ) {
+                    int sh = cc;
+                    int sl = cs.charAt ( ++i );
+                    if ( ( sl >= 0xDC00 ) && ( sl < 0xE000 ) ) {
+                        cc = 0x10000 + ( ( sh - 0xD800 ) << 10 ) + ( ( sl - 0xDC00 ) << 0 );
+                    } else {
+                        throw new IllegalArgumentException
+                            (  "ill-formed UTF-16 sequence, "
+                               + "contains isolated high surrogate at index " + i );
+                    }
+                } else {
+                    throw new IllegalArgumentException
+                        ( "ill-formed UTF-16 sequence, "
+                          + "contains isolated high surrogate at end of sequence" );
+                }
+            } else if ( ( cc >= 0xDC00 ) && ( cc < 0xE000 ) ) {
+                throw new IllegalArgumentException
+                    ( "ill-formed UTF-16 sequence, "
+                      + "contains isolated low surrogate at index " + i );
+            }
+            notifyMapOperation();
+            gi = findGlyphIndex ( cc );
+            if ( gi == SingleByteEncoding.NOT_FOUND_CODE_POINT ) {
+                warnMissingGlyph ( (char) cc );
+                gi = giMissing;
+            }
+            cb.put ( cc );
+            gb.put ( gi );
+        }
+        cb.flip();
+        gb.flip();
+        return new GlyphSequence ( cb, gb, null );
+    }
+
+    /**
+     * Map sequence GS, comprising a sequence of Glyph Indices, to output sequence CS,
+     * comprising a sequence of UTF-16 encoded Unicode Code Points.
+     * @param gs a GlyphSequence containing glyph indices
+     * @returns a CharSequence containing UTF-16 encoded Unicode characters
+     */
+    private CharSequence mapGlyphsToChars ( GlyphSequence gs ) {
+        int ng = gs.getGlyphCount();
+        CharBuffer cb = CharBuffer.allocate ( ng );
+        int ccMissing = Typeface.NOT_FOUND;
+        for ( int i = 0, n = ng; i < n; i++ ) {
+            int gi = gs.getGlyph ( i );
+            int cc = findCharacterFromGlyphIndex ( gi );
+            if ( ( cc == 0 ) || ( cc > 0x10FFFF ) ) {
+                cc = ccMissing;
+                log.warn("Unable to map glyph index " + gi
+                         + " to Unicode scalar in font '"
+                         + getFullName() + "', substituting missing character '"
+                         + (char) cc + "'");
+            }
+            if ( cc > 0x00FFFF ) {
+                int sh;
+                int sl;
+                cc -= 0x10000;
+                sh = ( ( cc >> 10 ) & 0x3FF ) + 0xD800;
+                sl = ( ( cc >>  0 ) & 0x3FF ) + 0xDC00;
+                cb.put ( (char) sh );
+                cb.put ( (char) sl );
+            } else {
+                cb.put ( (char) cc );
+            }
+        }
+        cb.flip();
+        return (CharSequence) cb;
+    }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MutableFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MutableFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MutableFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/MutableFont.java Thu Apr  5 16:19:19 2012
@@ -139,6 +139,12 @@ public interface MutableFont {
     void setKerningEnabled(boolean enabled);
 
     /**
+     * Enables/disabled advanced typographic features.
+     * @param enabled true if advanced typographic features should be enabled if available
+     */
+    void setAdvancedEnabled(boolean enabled);
+
+    /**
      * Adds an entry to the kerning table.
      * @param key Kerning key
      * @param value Kerning value

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/NamedCharacter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/NamedCharacter.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/NamedCharacter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/NamedCharacter.java Thu Apr  5 16:19:19 2012
@@ -139,4 +139,4 @@ public class NamedCharacter {
         sb.append(getName()).append(')');
         return sb.toString();
     }
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SimpleSingleByteEncoding.java Thu Apr  5 16:19:19 2012
@@ -25,9 +25,10 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
-import org.apache.fop.util.CharUtilities;
 import org.apache.xmlgraphics.fonts.Glyphs;
 
+import org.apache.fop.util.CharUtilities;
+
 /**
  * A simple implementation of the OneByteEncoding mostly used for encodings that are constructed
  * on-the-fly.
@@ -53,7 +54,7 @@ public class SimpleSingleByteEncoding im
 
     /** {@inheritDoc} */
     public char mapChar(char c) {
-        Character nc = charMap.get(new Character(c));
+        Character nc = charMap.get(Character.valueOf(c));
         if (nc != null) {
             return nc.charValue();
         }
@@ -118,7 +119,7 @@ public class SimpleSingleByteEncoding im
         }
         char newSlot = (char)(getLastChar() + 1);
         this.mapping.add(ch);
-        this.charMap.put(new Character(ch.getSingleUnicodeValue()), new Character(newSlot));
+        this.charMap.put(Character.valueOf(ch.getSingleUnicodeValue()), Character.valueOf(newSlot));
         return newSlot;
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SingleByteFont.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SingleByteFont.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SingleByteFont.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/SingleByteFont.java Thu Apr  5 16:19:19 2012
@@ -29,6 +29,8 @@ import java.util.TreeSet;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.xmlgraphics.fonts.Glyphs;
+
 import org.apache.fop.fonts.truetype.TTFFile.PostScriptVersion;
 
 /**
@@ -46,6 +48,7 @@ public class SingleByteFont extends Cust
 
     private Map<Character, UnencodedCharacter> unencodedCharacters;
     private List<SimpleSingleByteEncoding> additionalEncodings;
+    private Map<Character, Character> alternativeCodes;
 
     private PostScriptVersion ttPostScriptVersion;
 
@@ -63,7 +66,11 @@ public class SingleByteFont extends Cust
     }
 
     /** {@inheritDoc} */
-    @Override
+    public boolean isSubsetEmbedded() {
+        return false;
+    }
+
+    /** {@inheritDoc} */
     public String getEncodingName() {
         return this.mapping.getName();
     }
@@ -81,7 +88,7 @@ public class SingleByteFont extends Cust
         if (i < 256) {
             int idx = i - getFirstChar();
             if (idx >= 0 && idx < width.length) {
-                return size * width[i - getFirstChar()];
+                return size * width[idx];
             }
         } else if (this.additionalEncodings != null) {
             int encodingIndex = (i / 256) - 1;
@@ -89,7 +96,7 @@ public class SingleByteFont extends Cust
             int codePoint = i % 256;
             NamedCharacter nc = encoding.getCharacterForIndex(codePoint);
             UnencodedCharacter uc
-                = this.unencodedCharacters.get(new Character(nc.getSingleUnicodeValue()));
+                = this.unencodedCharacters.get(Character.valueOf(nc.getSingleUnicodeValue()));
             return size * uc.getWidth();
         }
         return 0;
@@ -102,19 +109,69 @@ public class SingleByteFont extends Cust
         return arr;
     }
 
-    /** {@inheritDoc} */
-    @Override
-    public char mapChar(char c) {
-        notifyMapOperation();
+    /**
+     * Lookup a character using its alternative names. If found, cache it so we
+     * can speed up lookups.
+     * @param c the character
+     * @return the suggested alternative character present in the font
+     */
+    private char findAlternative(char c) {
+        char d;
+        if (alternativeCodes == null) {
+            alternativeCodes = new java.util.HashMap<Character, Character>();
+        } else {
+            Character alternative = alternativeCodes.get(c);
+            if (alternative != null) {
+                return alternative;
+            }
+        }
+        String charName = Glyphs.charToGlyphName(c);
+        String[] charNameAlternatives = Glyphs.getCharNameAlternativesFor(charName);
+        if (charNameAlternatives != null && charNameAlternatives.length > 0) {
+            for (int i = 0; i < charNameAlternatives.length; i++) {
+                if (log.isDebugEnabled()) {
+                    log.debug("Checking alternative for char " + c + " (charname="
+                            + charName + "): " + charNameAlternatives[i]);
+                }
+                String s = Glyphs.getUnicodeSequenceForGlyphName(charNameAlternatives[i]);
+                if (s != null) {
+                    d = lookupChar(s.charAt(0));
+                    if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+                        alternativeCodes.put(c, d);
+                        return d;
+                    }
+                }
+            }
+        }
+
+        return SingleByteEncoding.NOT_FOUND_CODE_POINT;
+    }
+
+    private char lookupChar(char c) {
         char d = mapping.mapChar(c);
         if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
             return d;
         }
 
-        //Check unencoded characters which are available in the font by character name
+        // Check unencoded characters which are available in the font by
+        // character name
         d = mapUnencodedChar(c);
+        return d;
+    }
+
+    /** {@inheritDoc} */
+    @Override
+    public char mapChar(char c) {
+        notifyMapOperation();
+        char d = lookupChar(c);
         if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
             return d;
+        } else {
+            // Check for alternative
+            d = findAlternative(c);
+            if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+                return d;
+            }
         }
         this.warnMissingGlyph(c);
         return Typeface.NOT_FOUND;
@@ -122,7 +179,7 @@ public class SingleByteFont extends Cust
 
     private char mapUnencodedChar(char ch) {
         if (this.unencodedCharacters != null) {
-            UnencodedCharacter unencoded = this.unencodedCharacters.get(new Character(ch));
+            UnencodedCharacter unencoded = this.unencodedCharacters.get(Character.valueOf(ch));
             if (unencoded != null) {
                 if (this.additionalEncodings == null) {
                     this.additionalEncodings = new ArrayList<SimpleSingleByteEncoding>();
@@ -165,6 +222,11 @@ public class SingleByteFont extends Cust
         if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
             return true;
         }
+        // Check if an alternative exists
+        d = findAlternative(c);
+        if (d != SingleByteEncoding.NOT_FOUND_CODE_POINT) {
+            return true;
+        }
         return false;
     }
 
@@ -239,7 +301,7 @@ public class SingleByteFont extends Cust
         }
         if (ch.hasSingleUnicodeValue()) {
             UnencodedCharacter uc = new UnencodedCharacter(ch, width);
-            this.unencodedCharacters.put(new Character(ch.getSingleUnicodeValue()), uc);
+            this.unencodedCharacters.put(Character.valueOf(ch.getSingleUnicodeValue()), uc);
         } else {
             //Cannot deal with unicode sequences, so ignore this character
         }
@@ -307,7 +369,7 @@ public class SingleByteFont extends Cust
         for (int i = 0, c = arr.length; i < c; i++) {
             NamedCharacter nc = enc.getCharacterForIndex(enc.getFirstChar() + i);
             UnencodedCharacter uc = this.unencodedCharacters.get(
-                    new Character(nc.getSingleUnicodeValue()));
+                    Character.valueOf(nc.getSingleUnicodeValue()));
             arr[i] = uc.getWidth();
         }
         return arr;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/Typeface.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/Typeface.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/Typeface.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/Typeface.java Thu Apr  5 16:19:19 2012
@@ -24,6 +24,7 @@ import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.xmlgraphics.fonts.Glyphs;
 
 /**
@@ -143,6 +144,10 @@ public abstract class Typeface implement
 
     /** {@inheritDoc} */
     public String toString() {
-        return getFullName();
+        StringBuffer sbuf = new StringBuffer(super.toString());
+        sbuf.append('{');
+        sbuf.append(getFullName());
+        sbuf.append('}');
+        return sbuf.toString();
     }
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/AbstractFontReader.java Thu Apr  5 16:19:19 2012
@@ -31,6 +31,7 @@ import javax.xml.transform.TransformerFa
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.util.CommandLineLogger;
 
 /**
@@ -67,7 +68,7 @@ public abstract class AbstractFontReader
         List arguments = new java.util.ArrayList();
         for (int i = 0; i < args.length; i++) {
             if (args[i].startsWith("-")) {
-                if ("-d".equals(args[i]) || "-q".equals(args[i])) {
+                if ("-t".equals(args[i]) || "-d".equals(args[i]) || "-q".equals(args[i])) {
                     options.put(args[i], "");
                 } else if ((i + 1) < args.length && !args[i + 1].startsWith("-")) {
                     options.put(args[i], args[i + 1]);
@@ -101,7 +102,9 @@ public abstract class AbstractFontReader
      */
     protected static void determineLogLevel(Map options) {
         //Determine log level
-        if (options.get("-d") != null) {
+        if (options.get("-t") != null) {
+            setLogLevel("trace");
+        } else if (options.get("-d") != null) {
             setLogLevel("debug");
         } else if (options.get("-q") != null) {
             setLogLevel("error");

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/TTFReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/TTFReader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/TTFReader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/apps/TTFReader.java Thu Apr  5 16:19:19 2012
@@ -25,17 +25,22 @@ import java.util.Set;
 
 import javax.xml.parsers.DocumentBuilderFactory;
 
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.Version;
 import org.apache.fop.fonts.BFEntry;
 import org.apache.fop.fonts.FontUtil;
 import org.apache.fop.fonts.truetype.FontFileReader;
 import org.apache.fop.fonts.truetype.TTFFile;
 import org.apache.fop.util.CommandLineLogger;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
+
+// CSOFF: InnerAssignmentCheck
+// CSOFF: LineLengthCheck
 
 /**
  * A tool which reads TTF files and generates
@@ -60,6 +65,7 @@ public class TTFReader extends AbstractF
                 "java " + TTFReader.class.getName() + " [options] fontfile.ttf xmlfile.xml");
         System.out.println();
         System.out.println("where options can be:");
+        System.out.println("-t  Trace mode");
         System.out.println("-d  Debug mode");
         System.out.println("-q  Quiet mode");
         System.out.println("-enc ansi");
@@ -101,6 +107,8 @@ public class TTFReader extends AbstractF
      * you can also include the fontfile in the fop.jar file when building fop.
      * You can use both -ef and -er. The file specified in -ef will be searched first,
      * then the -er file.
+     * -nocs
+     * if complex script features are disabled
      */
     public static void main(String[] args) {
         String embFile = null;
@@ -154,13 +162,19 @@ public class TTFReader extends AbstractF
             className = (String)options.get("-cn");
         }
 
+        boolean useKerning = true;
+        boolean useAdvanced = true;
+        if (options.get("-nocs") != null) {
+            useAdvanced = false;
+        }
+
         if (arguments.length != 2 || options.get("-h") != null
             || options.get("-help") != null || options.get("--help") != null) {
             displayUsage();
         } else {
             try {
                 log.info("Parsing font...");
-                TTFFile ttf = app.loadTTF(arguments[0], ttcName);
+                TTFFile ttf = app.loadTTF(arguments[0], ttcName, useKerning, useAdvanced);
                 if (ttf != null) {
                     org.w3c.dom.Document doc = app.constructFontXML(ttf,
                             fontName, className, embResource, embFile, isCid,
@@ -197,11 +211,13 @@ public class TTFReader extends AbstractF
      *
      * @param  fileName The filename of the TTF file.
      * @param  fontName The name of the font
+     * @param  useKerning true if should load kerning data
+     * @param  useAdvanced true if should load advanced typographic table data
      * @return The TTF as an object, null if the font is incompatible.
      * @throws IOException In case of an I/O problem
      */
-    public TTFFile loadTTF(String fileName, String fontName) throws IOException {
-        TTFFile ttfFile = new TTFFile();
+    public TTFFile loadTTF(String fileName, String fontName, boolean useKerning, boolean useAdvanced) throws IOException {
+        TTFFile ttfFile = new TTFFile(useKerning, useAdvanced);
         log.info("Reading " + fileName + "...");
 
         FontFileReader reader = new FontFileReader(fileName);
@@ -457,7 +473,6 @@ public class TTFReader extends AbstractF
         }
     }
 
-
     /**
      * Bugzilla 40739, check that attr has a metrics-version attribute
      * compatible with ours.
@@ -476,8 +491,7 @@ public class TTFReader extends AbstractF
                 if (version < METRICS_VERSION) {
                     err = "Incompatible " + METRICS_VERSION_ATTR
                         + " value (" + version + ", should be " + METRICS_VERSION
-                        + ")"
-                     ;
+                        + ")";
                 }
             } catch (NumberFormatException e) {
                 err = "Invalid " + METRICS_VERSION_ATTR

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontFileFinder.java Thu Apr  5 16:19:19 2012
@@ -34,6 +34,8 @@ import org.apache.commons.io.filefilter.
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.fop.fonts.FontEventListener;
+
 /**
  * Helps to autodetect/locate available operating system fonts.
  */
@@ -44,20 +46,24 @@ public class FontFileFinder extends Dire
 
     /** default depth limit of recursion when searching for font files **/
     public static final int DEFAULT_DEPTH_LIMIT = -1;
+    private final FontEventListener eventListener;
 
     /**
      * Default constructor
+     * @param listener for throwing font related events
      */
-    public FontFileFinder() {
-        super(getDirectoryFilter(), getFileFilter(), DEFAULT_DEPTH_LIMIT);
+    public FontFileFinder(FontEventListener listener) {
+        this(DEFAULT_DEPTH_LIMIT, listener);
     }
 
     /**
      * Constructor
      * @param depthLimit recursion depth limit
+     * @param listener for throwing font related events
      */
-    public FontFileFinder(int depthLimit) {
+    public FontFileFinder(int depthLimit, FontEventListener listener) {
         super(getDirectoryFilter(), getFileFilter(), depthLimit);
+        eventListener = listener;
     }
 
     /**
@@ -163,6 +169,12 @@ public class FontFileFinder extends Dire
     public List<URL> find(String dir) throws IOException {
         List<URL> results = new java.util.ArrayList<URL>();
         super.walk(new File(dir), results);
+        File directory = new File(dir);
+        if (!directory.isDirectory()) {
+            eventListener.fontDirectoryNotFound(this, dir);
+        } else {
+            super.walk(directory, results);
+        }
         return results;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/FontInfoFinder.java Thu Apr  5 16:19:19 2012
@@ -29,6 +29,7 @@ import java.util.regex.Pattern;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.CustomFont;
 import org.apache.fop.fonts.EmbedFontInfo;
 import org.apache.fop.fonts.EmbeddingMode;
@@ -149,7 +150,7 @@ public class FontInfoFinder {
             subFontName = ((MultiByteFont)customFont).getTTCName();
         }
         EmbedFontInfo fontInfo = new EmbedFontInfo(null, customFont.isKerningEnabled(),
-                fontTripletList, embedUrl, subFontName);
+                customFont.isAdvancedEnabled(), fontTripletList, embedUrl, subFontName);
         fontInfo.setPostScriptName(customFont.getFontName());
         if (fontCache != null) {
             fontCache.addFont(fontInfo);
@@ -169,6 +170,9 @@ public class FontInfoFinder {
     public EmbedFontInfo[] find(URL fontURL, FontResolver resolver, FontCache fontCache) {
         String embedURL = null;
         embedURL = fontURL.toExternalForm();
+        boolean useKerning = true;
+        boolean useAdvanced = ( resolver != null )
+            ? resolver.isComplexScriptFeaturesEnabled() : true;
 
         long fileLastModified = -1;
         if (fontCache != null) {
@@ -191,14 +195,14 @@ public class FontInfoFinder {
 
         // try to determine triplet information from font file
         CustomFont customFont = null;
-        if (fontURL.toExternalForm().endsWith(".ttc")) {
+        if (fontURL.toExternalForm().toLowerCase().endsWith(".ttc")) {
             // Get a list of the TTC Font names
             List<String> ttcNames = null;
             String fontFileURL = fontURL.toExternalForm().trim();
             InputStream in = null;
             try {
                 in = FontLoader.openFontUri(resolver, fontFileURL);
-                TTFFile ttf = new TTFFile();
+                TTFFile ttf = new TTFFile(false, false);
                 FontFileReader reader = new FontFileReader(in);
                 ttcNames = ttf.getTTCnames(reader);
             } catch (Exception e) {
@@ -220,7 +224,7 @@ public class FontInfoFinder {
                 try {
                     TTFFontLoader ttfLoader = new TTFFontLoader(
                             fontFileURL, fontName, true, EmbeddingMode.AUTO, EncodingMode.AUTO,
-                            true, resolver);
+                            useKerning, useAdvanced, resolver);
                     customFont = ttfLoader.getFont();
                     if (this.eventListener != null) {
                         customFont.setEventListener(this.eventListener);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/WindowsFontDirFinder.java Thu Apr  5 16:19:19 2012
@@ -67,7 +67,8 @@ public class WindowsFontDirFinder implem
                 // should continue if this fails
             }
         }
-        File osFontsDir = null, psFontsDir = null;
+        File osFontsDir = null;
+        File psFontsDir = null;
         if (windir != null) {
             // remove any trailing '/'
             if (windir.endsWith("/")) {

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontQualifier.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontQualifier.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontQualifier.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontQualifier.java Thu Apr  5 16:19:19 2012
@@ -26,6 +26,7 @@ import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutions.java Thu Apr  5 16:19:19 2012
@@ -24,6 +24,7 @@ import java.util.List;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/substitute/FontSubstitutionsConfigurator.java Thu Apr  5 16:19:19 2012
@@ -20,6 +20,7 @@
 package org.apache.fop.fonts.substitute;
 
 import org.apache.avalon.framework.configuration.Configuration;
+
 import org.apache.fop.apps.FOPException;
 
 /**

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/FontFileReader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/FontFileReader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/FontFileReader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/FontFileReader.java Thu Apr  5 16:19:19 2012
@@ -188,14 +188,15 @@ public class FontFileReader {
      * @param val The value to write
      * @throws IOException If EOF is reached
      */
-    public final void writeTTFUShort(int pos, int val) throws IOException {
+    public final void writeTTFUShort(long pos, int val) throws IOException {
         if ((pos + 2) > fsize) {
             throw new java.io.EOFException("Reached EOF");
         }
         final byte b1 = (byte)((val >> 8) & 0xff);
         final byte b2 = (byte)(val & 0xff);
-        file[pos] = b1;
-        file[pos + 1] = b2;
+        final int fileIndex = (int) pos;
+        file[fileIndex] = b1;
+        file[fileIndex + 1] = b2;
     }
 
     /**
@@ -349,4 +350,4 @@ public class FontFileReader {
     public byte[] getAllBytes() {
         return file;
     }
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFDirTabEntry.java Thu Apr  5 16:19:19 2012
@@ -26,7 +26,7 @@ import java.io.UnsupportedEncodingExcept
 /**
  * This class represents an entry to a TrueType font's Dir Tab.
  */
-class TTFDirTabEntry {
+public class TTFDirTabEntry {
 
     private byte[] tag = new byte[4];
     private int checksum;
@@ -42,7 +42,10 @@ class TTFDirTabEntry {
     }
 
     /**
-     * Read Dir Tab, return tag name
+     * Read Dir Tab.
+     * @param in font file reader
+     * @return tag name
+     * @throws IOException upon I/O exception
      */
     public String read(FontFileReader in) throws IOException {
         tag[0] = in.readTTFByte();
@@ -60,6 +63,7 @@ class TTFDirTabEntry {
     }
 
 
+    @Override
     public String toString() {
         return "Read dir tab ["
             + tag[0] + " " + tag[1] + " " + tag[2] + " " + tag[3] + "]"



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org


Mime
View raw message