You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by vh...@apache.org on 2012/04/05 18:20:17 UTC

svn commit: r1309921 [19/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...

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFile.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFile.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFile.java Thu Apr  5 16:19:19 2012
@@ -35,9 +35,16 @@ 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.complexscripts.fonts.AdvancedTypographicTableFormatException;
+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.OTFAdvancedTypographicTableReader;
 import org.apache.fop.fonts.BFEntry;
 import org.apache.fop.fonts.FontUtil;
-import org.apache.xmlgraphics.fonts.Glyphs;
 
 /**
  * Reads a TrueType file or a TrueType Collection.
@@ -143,6 +150,9 @@ public class TTFFile {
     private final String encoding = "WinAnsiEncoding";    // Default encoding
 
     private final short firstChar = 0;
+
+    private boolean useKerning = false;
+
     private boolean isEmbeddable = true;
     private boolean hasSerifs = true;
     /**
@@ -152,7 +162,7 @@ public class TTFFile {
     private Map<Integer, Map<Integer, Integer>> kerningTab; // for CIDs
     private Map<Integer, Map<Integer, Integer>> ansiKerningTab; // For winAnsiEncoding
     private List<BFEntry> cmaps;
-    private List<UnicodeMapping> unicodeMapping;
+    private Set<UnicodeMapping> unicodeMappings;
 
     private int upem;                                // unitsPerEm from "head" table
     private int nhmtx;                               // Number of horizontal metrics
@@ -212,15 +222,33 @@ public class TTFFile {
 
     private boolean isCFF;
 
+    // advanced typographic table support
+    private boolean useAdvanced = false;
+    private OTFAdvancedTypographicTableReader advancedTableReader;
+
     /**
      * logging instance
      */
     protected Log log = LogFactory.getLog(TTFFile.class);
 
+    public TTFFile() {
+        this(true, false);
+    }
+
+    /**
+     * Constructor
+     * @param useKerning true if kerning data should be loaded
+     * @param useAdvanced true if advanced typographic tables should be loaded
+     */
+    public TTFFile ( boolean useKerning, boolean useAdvanced ) {
+        this.useKerning = useKerning;
+        this.useAdvanced = useAdvanced;
+    }
+
     /**
      * Key-value helper class (immutable)
      */
-    final class UnicodeMapping {
+    final class UnicodeMapping implements Comparable {
 
         private final int unicodeIndex;
         private final int glyphIndex;
@@ -247,6 +275,44 @@ public class TTFFile {
         public int getUnicodeIndex() {
             return unicodeIndex;
         }
+
+
+        /** {@inheritDoc} */
+        public int hashCode() {
+            int hc = unicodeIndex;
+            hc = 19 * hc + ( hc ^ glyphIndex );
+            return hc;
+        }
+
+        /** {@inheritDoc} */
+        public boolean equals ( Object o ) {
+            if ( o instanceof UnicodeMapping ) {
+                UnicodeMapping m = (UnicodeMapping) o;
+                if ( unicodeIndex != m.unicodeIndex ) {
+                    return false;
+                } else {
+                    return ( glyphIndex == m.glyphIndex );
+                }
+            } else {
+                return false;
+            }
+        }
+
+        /** {@inheritDoc} */
+        public int compareTo ( Object o ) {
+            if ( o instanceof UnicodeMapping ) {
+                UnicodeMapping m = (UnicodeMapping) o;
+                if ( unicodeIndex > m.unicodeIndex ) {
+                    return 1;
+                } else if ( unicodeIndex < m.unicodeIndex ) {
+                    return -1;
+                } else {
+                    return 0;
+                }
+            } else {
+                return -1;
+            }
+        }
     }
 
     /**
@@ -264,10 +330,24 @@ public class TTFFile {
     }
 
     /**
+     * Obtain directory table entry.
+     * @param name (tag) of entry
+     * @return a directory table entry or null if none found
+     */
+    public TTFDirTabEntry getDirectoryEntry(TTFTableName name) {
+        return dirTabs.get(name);
+    }
+
+    /**
      * Position inputstream to position indicated
      * in the dirtab offset + offset
+     * @param in font file reader
+     * @param name (tag) of table
+     * @param offset from start of table
+     * @return true if seek succeeded
+     * @throws IOException if I/O exception occurs during seek
      */
-    boolean seekTab(FontFileReader in, TTFTableName tableName,
+    public boolean seekTab(FontFileReader in, TTFTableName tableName,
                   long offset) throws IOException {
         TTFDirTabEntry dt = dirTabs.get(tableName);
         if (dt == null) {
@@ -309,7 +389,7 @@ public class TTFFile {
      */
     private boolean readCMAP() throws IOException {
 
-        unicodeMapping = new ArrayList<UnicodeMapping>();
+        unicodeMappings = new java.util.TreeSet();
 
         seekTab(fontFile, TTFTableName.CMAP, 2);
         int numCMap = fontFile.readTTFUShort();    // Number of cmap subtables
@@ -450,7 +530,7 @@ public class TTFFile {
                             glyphIdx = (fontFile.readTTFUShort() + cmapDeltas[i])
                                        & 0xffff;
 
-                            unicodeMapping.add(new UnicodeMapping(glyphIdx, j));
+                            unicodeMappings.add(new UnicodeMapping(glyphIdx, j));
                             mtxTab[glyphIdx].getUnicodeIndex().add(new Integer(j));
 
                             if (encodingID == 0 && j >= 0xF020 && j <= 0xF0FF) {
@@ -460,7 +540,7 @@ public class TTFFile {
                                 int mapped = j - 0xF000;
                                 if (!eightBitGlyphs.get(mapped)) {
                                     //Only map if Unicode code point hasn't been mapped before
-                                    unicodeMapping.add(new UnicodeMapping(glyphIdx, mapped));
+                                    unicodeMappings.add(new UnicodeMapping(glyphIdx, mapped));
                                     mtxTab[glyphIdx].getUnicodeIndex().add(new Integer(mapped));
                                 }
                             }
@@ -499,7 +579,7 @@ public class TTFFile {
                                                    + mtxTab.length);
                             }
 
-                            unicodeMapping.add(new UnicodeMapping(glyphIdx, j));
+                            unicodeMappings.add(new UnicodeMapping(glyphIdx, j));
                             if (glyphIdx < mtxTab.length) {
                                 mtxTab[glyphIdx].getUnicodeIndex().add(new Integer(j));
                             } else {
@@ -656,9 +736,27 @@ public class TTFFile {
         }
         // Create cmaps for bfentries
         createCMaps();
-        // print_max_min();
 
-        readKerning();
+        if ( useKerning ) {
+            readKerning();
+        }
+
+        // Read advanced typographic tables.
+        if ( useAdvanced ) {
+            try {
+                OTFAdvancedTypographicTableReader atr
+                    = new OTFAdvancedTypographicTableReader ( this, in );
+                atr.readAll();
+                this.advancedTableReader = atr;
+            } catch ( AdvancedTypographicTableFormatException e ) {
+                log.warn (
+                    "Encountered format constraint violation in advanced (typographic) table (AT) "
+                    + "in font '" + getFullName() + "', ignoring AT data: "
+                    + e.getMessage()
+                );
+            }
+        }
+
         guessVerticalMetricsFromGlyphBBox();
         return true;
     }
@@ -683,7 +781,7 @@ public class TTFFile {
         int glyphStart;
         int unicodeEnd;
 
-        Iterator<UnicodeMapping> e = unicodeMapping.listIterator();
+        Iterator<UnicodeMapping> e = unicodeMappings.iterator();
         UnicodeMapping um = e.next();
         UnicodeMapping lastMapping = um;
 
@@ -1056,8 +1154,8 @@ public class TTFFile {
         int mtxSize = Math.max(numberOfGlyphs, nhmtx);
         mtxTab = new TTFMtxEntry[mtxSize];
 
-        if (TRACE_ENABLED) {
-            log.debug("*** Widths array: \n");
+        if (log.isTraceEnabled()) {
+            log.trace("*** Widths array: \n");
         }
         for (int i = 0; i < mtxSize; i++) {
             mtxTab[i] = new TTFMtxEntry();
@@ -1066,11 +1164,9 @@ public class TTFFile {
             mtxTab[i].setWx(fontFile.readTTFUShort());
             mtxTab[i].setLsb(fontFile.readTTFUShort());
 
-            if (TRACE_ENABLED) {
-                if (log.isDebugEnabled()) {
-                    log.debug("   width[" + i + "] = "
-                        + convertTTFUnit2PDFUnit(mtxTab[i].getWx()) + ";");
-                }
+            if (log.isTraceEnabled()) {
+                log.trace("   width[" + i + "] = "
+                          + convertTTFUnit2PDFUnit(mtxTab[i].getWx()) + ";");
             }
         }
 
@@ -1509,7 +1605,7 @@ public class TTFFile {
                 capHeight = os2CapHeight;
             }
             if (capHeight == 0) {
-                log.warn("capHeight value could not be determined."
+                log.debug("capHeight value could not be determined."
                         + " The font may not work as expected.");
             }
         }
@@ -1519,7 +1615,7 @@ public class TTFFile {
                 xHeight = os2xHeight;
             }
             if (xHeight == 0) {
-                log.warn("xHeight value could not be determined."
+                log.debug("xHeight value could not be determined."
                         + " The font may not work as expected.");
             }
         }
@@ -1766,11 +1862,9 @@ public class TTFFile {
                 dirOffsets[i] = in.readTTFULong();
             }
 
-            if (log.isDebugEnabled()) {
-                log.debug("This is a TrueType collection file with "
-                        + numDirectories + " fonts");
-                log.debug("Containing the following fonts: ");
-            }
+            log.info("This is a TrueType collection file with "
+                      + numDirectories + " fonts");
+            log.info("Containing the following fonts: ");
 
             for (int i = 0; (i < numDirectories); i++) {
                 in.seekSet(dirOffsets[i]);
@@ -1778,7 +1872,7 @@ public class TTFFile {
 
                 readName();
 
-                log.debug(fullName);
+                log.info(fullName);
                 fontNames.add(fullName);
 
                 // Reset names
@@ -1849,9 +1943,8 @@ public class TTFFile {
      *
      * @param glyphIndex
      * @return unicode code point
-     * @throws IOException if glyphIndex not found
      */
-    private Integer glyphToUnicode(int glyphIndex) throws IOException {
+    private Integer glyphToUnicode(int glyphIndex) {
         return glyphToUnicodeMap.get(new Integer(glyphIndex));
     }
 
@@ -1860,7 +1953,6 @@ public class TTFFile {
      *
      * @param unicodeIndex unicode code point
      * @return glyph index
-     * @throws IOException if unicodeIndex not found
      */
     private Integer unicodeToGlyph(int unicodeIndex) throws IOException {
         final Integer result
@@ -1877,12 +1969,62 @@ public class TTFFile {
     }
 
     /**
+     * Determine if advanced (typographic) table is present.
+     * @return true if advanced (typographic) table is present
+     */
+    public boolean hasAdvancedTable() {
+        if (  advancedTableReader != null ) {
+            return  advancedTableReader.hasAdvancedTable();
+        } else {
+            return false;
+        }
+    }
+
+    /**
+     * Returns the GDEF table or null if none present.
+     * @return the GDEF table
+     */
+    public GlyphDefinitionTable getGDEF() {
+        if (  advancedTableReader != null ) {
+            return  advancedTableReader.getGDEF();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the GSUB table or null if none present.
+     * @return the GSUB table
+     */
+    public GlyphSubstitutionTable getGSUB() {
+        if (  advancedTableReader != null ) {
+            return  advancedTableReader.getGSUB();
+        } else {
+            return null;
+        }
+    }
+
+    /**
+     * Returns the GPOS table or null if none present.
+     * @return the GPOS table
+     */
+    public GlyphPositioningTable getGPOS() {
+        if (  advancedTableReader != null ) {
+            return  advancedTableReader.getGPOS();
+        } else {
+            return null;
+        }
+    }
+
+    /**
      * Static main method to get info about a TrueType font.
      * @param args The command line arguments
      */
     public static void main(String[] args) {
         try {
-            TTFFile ttfFile = new TTFFile();
+            boolean useKerning = true;
+            boolean useAdvanced = true;
+            TTFFile ttfFile = new TTFFile(useKerning, useAdvanced);
 
             FontFileReader reader = new FontFileReader(args[0]);
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFFontLoader.java Thu Apr  5 16:19:19 2012
@@ -25,6 +25,7 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
+
 import org.apache.fop.fonts.BFEntry;
 import org.apache.fop.fonts.CIDFontType;
 import org.apache.fop.fonts.EmbeddingMode;
@@ -55,7 +56,7 @@ public class TTFFontLoader extends FontL
      * @param resolver the FontResolver for font URI resolution
      */
     public TTFFontLoader(String fontFileURI, FontResolver resolver) {
-        this(fontFileURI, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, true, resolver);
+        this(fontFileURI, null, true, EmbeddingMode.AUTO, EncodingMode.AUTO, true, true, resolver);
     }
 
     /**
@@ -67,12 +68,13 @@ public class TTFFontLoader extends FontL
      * @param embeddingMode the embedding mode of the font
      * @param encodingMode the requested encoding mode
      * @param useKerning true to enable loading kerning info if available, false to disable
+     * @param useAdvanced true to enable loading advanced info if available, false to disable
      * @param resolver the FontResolver for font URI resolution
      */
     public TTFFontLoader(String fontFileURI, String subFontName,
                 boolean embedded, EmbeddingMode embeddingMode, EncodingMode encodingMode,
-                boolean useKerning, FontResolver resolver) {
-        super(fontFileURI, embedded, true, resolver);
+                boolean useKerning, boolean useAdvanced, FontResolver resolver) {
+        super(fontFileURI, embedded, useKerning, useAdvanced, resolver);
         this.subFontName = subFontName;
         this.encodingMode = encodingMode;
         this.embeddingMode = embeddingMode;
@@ -98,7 +100,7 @@ public class TTFFontLoader extends FontL
     private void read(String ttcFontName) throws IOException {
         InputStream in = openFontUri(resolver, this.fontFileURI);
         try {
-            TTFFile ttf = new TTFFile();
+            TTFFile ttf = new TTFFile(useKerning, useAdvanced);
             FontFileReader reader = new FontFileReader(in);
             boolean supported = ttf.readFont(reader, ttcFontName);
             if (!supported) {
@@ -165,8 +167,17 @@ public class TTFFontLoader extends FontL
         if (useKerning) {
             copyKerning(ttf, isCid);
         }
-        if (this.embedded && ttf.isEmbeddable()) {
-            returnFont.setEmbedFileName(this.fontFileURI);
+        if (useAdvanced) {
+            copyAdvanced(ttf);
+        }
+        if (this.embedded) {
+            if (ttf.isEmbeddable()) {
+                returnFont.setEmbedFileName(this.fontFileURI);
+            } else {
+                String msg = "The font " + this.fontFileURI + " is not embeddable due to a"
+                        + " licensing restriction.";
+                throw new RuntimeException(msg);
+            }
         }
     }
 
@@ -225,4 +236,17 @@ public class TTFFontLoader extends FontL
             returnFont.putKerningEntry(kpx1, h2);
         }
     }
+
+    /**
+     * Copy advanced typographic information.
+     */
+    private void copyAdvanced ( TTFFile ttf ) {
+        if ( returnFont instanceof MultiByteFont ) {
+            MultiByteFont mbf = (MultiByteFont) returnFont;
+            mbf.setGDEF ( ttf.getGDEF() );
+            mbf.setGSUB ( ttf.getGSUB() );
+            mbf.setGPOS ( ttf.getGPOS() );
+        }
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFSubSetFile.java Thu Apr  5 16:19:19 2012
@@ -52,6 +52,30 @@ public class TTFSubSetFile extends TTFFi
     /** Stores the glyph offsets so that we can end strings at glyph boundaries */
     private int[] glyphOffsets;
 
+    /**
+     * Default Constructor
+     */
+    public TTFSubSetFile() {
+    }
+
+    /**
+     * Constructor
+     * @param useKerning true if kerning data should be loaded
+     * @param useAdvanced true if advanced typographic tables should be loaded
+     */
+    public TTFSubSetFile ( boolean useKerning, boolean useAdvanced ) {
+        super(useKerning, useAdvanced);
+    }
+
+    /**
+     * Initalize the output array
+     */
+    private void init(int size) {
+        output = new byte[size];
+        realSize = 0;
+        currentPos = 0;
+    }
+
     /** The dir tab entries in the new subset font. */
     private Map<TTFTableName, TTFDirTabEntry> newDirTabs
                         = new HashMap<TTFTableName, TTFDirTabEntry>();
@@ -542,64 +566,6 @@ public class TTFSubSetFile extends TTFFi
 
 
     /**
-     * Scan all the original glyphs for composite glyphs and add those glyphs
-     * to the glyphmapping also rewrite the composite glyph pointers to the new
-     * mapping
-     */
-    private void scanGlyphs(FontFileReader in,
-                            Map<Integer, Integer> glyphs) throws IOException {
-        TTFDirTabEntry entry = dirTabs.get(TTFTableName.GLYF);
-        Map<Integer, Integer> newComposites = null;
-        Map<Integer, Integer> allComposites = new HashMap<Integer, Integer>();
-
-        int newIndex = glyphs.size();
-
-        if (entry != null) {
-            while (newComposites == null || newComposites.size() > 0) {
-                // Inefficient to iterate through all glyphs
-                newComposites = new HashMap<Integer, Integer>();
-
-                for (Map.Entry<Integer, Integer> glyph : glyphs.entrySet()) {
-                    int origIndex = glyph.getKey();
-                    if (in.readTTFShort(entry.getOffset()
-                                        + mtxTab[origIndex].getOffset()) < 0) {
-                        // origIndex is a composite glyph
-                        allComposites.put(origIndex, glyph.getValue());
-                        List<Integer> composites
-                            = getIncludedGlyphs(in, (int)entry.getOffset(),
-                                              origIndex);
-
-                        // Iterate through all composites pointed to
-                        // by this composite and check if they exists
-                        // in the glyphs map, add them if not.
-                        for (Integer cIdx : composites) {
-                            if (glyphs.get(cIdx) == null
-                                    && newComposites.get(cIdx) == null) {
-                                newComposites.put(cIdx, newIndex);
-                                newIndex++;
-                            }
-                        }
-                    }
-                }
-
-                // Add composites to glyphs
-                for (Map.Entry<Integer, Integer> im : newComposites.entrySet()) {
-                    glyphs.put(im.getKey(), im.getValue());
-                }
-            }
-
-            // Iterate through all composites to remap their composite index
-            for (Integer idx : allComposites.keySet()) {
-                remapComposite(in, glyphs, (int)entry.getOffset(),
-                               idx);
-            }
-
-        } else {
-            throw new IOException("Can't find glyf table");
-        }
-    }
-
-    /**
      * Reads a font and creates a subset of the font.
      *
      * @param in FontFileReader to read from
@@ -711,6 +677,17 @@ public class TTFSubSetFile extends TTFFi
         ttfOut.endFontStream();
     }
 
+    private void scanGlyphs(FontFileReader in, Map<Integer, Integer> subsetGlyphs)
+            throws IOException {
+        TTFDirTabEntry glyfTableInfo = dirTabs.get(TTFTableName.GLYF);
+        if (glyfTableInfo == null) {
+            throw new IOException("Glyf table could not be found");
+        }
+
+        GlyfTable glyfTable = new GlyfTable(in, mtxTab, glyfTableInfo, subsetGlyphs);
+        glyfTable.populateGlyphsWithComposites();
+    }
+
     /**
      * writes a ISO-8859-1 string at the currentPosition
      * updates currentPosition but not realSize
@@ -777,6 +754,32 @@ public class TTFSubSetFile extends TTFFi
     }
 
     /**
+     * Read a signed short value at given position
+     */
+    private short readShort(int pos) {
+        int ret = readUShort(pos);
+        return (short)ret;
+    }
+
+    /**
+     * Read a unsigned short value at given position
+     */
+    private int readUShort(int pos) {
+        int ret = output[pos];
+        if (ret < 0) {
+            ret += 256;
+        }
+        ret = ret << 8;
+        if (output[pos + 1] < 0) {
+            ret |= output[pos + 1] + 256;
+        } else {
+            ret |= output[pos + 1];
+        }
+
+        return ret;
+    }
+
+    /**
      * Create a padding in the fontfile to align
      * on a 4-byte boundary
      */
@@ -802,6 +805,9 @@ public class TTFSubSetFile extends TTFFi
         return (i - 1);
     }
 
+    private int log2(int num) {
+        return (int)(Math.log(num) / Math.log(2));
+    }
 
     private void updateCheckSum(int tableStart, int tableSize, TTFTableName tableName) {
         int checksum = getCheckSum(output, tableStart, tableSize);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFTableName.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFTableName.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFTableName.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/truetype/TTFTableName.java Thu Apr  5 16:19:19 2012
@@ -155,4 +155,9 @@ public final class TTFTableName {
         return this.name.equals(to.getName());
     }
 
+    @Override
+    public String toString() {
+        return name;
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMFile.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMFile.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMFile.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMFile.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,12 @@ package org.apache.fop.fonts.type1;
 import java.awt.geom.Dimension2D;
 import java.awt.geom.RectangularShape;
 import java.util.Collections;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.xmlgraphics.java2d.Dimension2DDouble;
 
 import org.apache.fop.fonts.NamedCharacter;
@@ -36,6 +38,9 @@ import org.apache.fop.fonts.SingleByteEn
  */
 public class AFMFile {
 
+    /** logging instance */
+    private static final Log LOG = LogFactory.getLog(AFMFile.class);
+
     private String fontName;
     private String fullName;
     private String familyName;
@@ -56,15 +61,13 @@ public class AFMFile {
     private AFMWritingDirectionMetrics[] writingDirectionMetrics
         = new AFMWritingDirectionMetrics[3];
 
-    private List charMetrics = new java.util.ArrayList();
-    //List<AFMCharMetrics>
-    private Map charNameToMetrics = new java.util.HashMap();
-    //Map<String, AFMCharMetrics>
+    private List<AFMCharMetrics> charMetrics = new java.util.ArrayList<AFMCharMetrics>();
+    private Map<String, AFMCharMetrics> charNameToMetrics
+                = new java.util.HashMap<String, AFMCharMetrics>();
     private int firstChar = -1;
     private int lastChar = -1;
 
-    private Map kerningMap;
-    //Map<String, Map<String, Dimension2D>>
+    private Map<String, Map<String, Dimension2D>> kerningMap;
 
     /**
      * Default constructor.
@@ -365,14 +368,14 @@ public class AFMFile {
      * @return the character metrics or null if there's no such character
      */
     public AFMCharMetrics getChar(String name) {
-        return (AFMCharMetrics)this.charNameToMetrics.get(name);
+        return this.charNameToMetrics.get(name);
     }
 
     /**
      * Returns the list of AFMCharMetrics instances representing all the available characters.
      * @return a List of AFMCharMetrics instances
      */
-    public List getCharMetrics() {
+    public List<AFMCharMetrics> getCharMetrics() {
         return Collections.unmodifiableList(this.charMetrics);
     }
 
@@ -384,11 +387,11 @@ public class AFMFile {
      */
     public void addXKerning(String name1, String name2, double kx) {
         if (this.kerningMap == null) {
-            this.kerningMap = new java.util.HashMap();
+            this.kerningMap = new java.util.HashMap<String, Map<String, Dimension2D>>();
         }
-        Map entries = (Map)this.kerningMap.get(name1);
+        Map<String, Dimension2D> entries = this.kerningMap.get(name1);
         if (entries == null) {
-            entries = new java.util.HashMap();
+            entries = new java.util.HashMap<String, Dimension2D>();
             this.kerningMap.put(name1, entries);
         }
         entries.put(name2, new Dimension2DDouble(kx, 0));
@@ -406,40 +409,37 @@ public class AFMFile {
      * Creates and returns a kerning map for writing mode 0 (ltr) with character codes.
      * @return the kerning map or null if there is no kerning information.
      */
-    public Map createXKerningMapEncoded() {
+    public Map<Integer, Map<Integer, Integer>> createXKerningMapEncoded() {
         if (!hasKerning()) {
             return null;
         }
-        Map m = new java.util.HashMap();
-        Iterator iterFrom = this.kerningMap.entrySet().iterator();
-        while (iterFrom.hasNext()) {
-            Map.Entry entryFrom = (Map.Entry)iterFrom.next();
-            String name1 = (String)entryFrom.getKey();
+        Map<Integer, Map<Integer, Integer>> m
+                    = new java.util.HashMap<Integer, Map<Integer, Integer>>();
+        for (Map.Entry<String, Map<String, Dimension2D>> entryFrom : this.kerningMap.entrySet()) {
+            String name1 = entryFrom.getKey();
             AFMCharMetrics chm1 = getChar(name1);
             if (chm1 == null || !chm1.hasCharCode()) {
                 continue;
             }
-            Map container = null;
-            Map entriesTo = (Map)entryFrom.getValue();
-            Iterator iterTo = entriesTo.entrySet().iterator();
-            while (iterTo.hasNext()) {
-                Map.Entry entryTo = (Map.Entry)iterTo.next();
-                String name2 = (String)entryTo.getKey();
+            Map<Integer, Integer> container = null;
+            Map<String, Dimension2D> entriesTo = entryFrom.getValue();
+            for (Map.Entry<String, Dimension2D> entryTo : entriesTo.entrySet()) {
+                String name2 = entryTo.getKey();
                 AFMCharMetrics chm2 = getChar(name2);
                 if (chm2 == null || !chm2.hasCharCode()) {
                     continue;
                 }
                 if (container == null) {
-                    Integer k1 = new Integer(chm1.getCharCode());
-                    container = (Map)m.get(k1);
+                    Integer k1 = Integer.valueOf(chm1.getCharCode());
+                    container = m.get(k1);
                     if (container == null) {
-                        container = new java.util.HashMap();
+                        container = new java.util.HashMap<Integer, Integer>();
                         m.put(k1, container);
                     }
                 }
-                Dimension2D dim = (Dimension2D)entryTo.getValue();
-                container.put(new Integer(chm2.getCharCode()),
-                        new Integer((int)Math.round(dim.getWidth())));
+                Dimension2D dim = entryTo.getValue();
+                container.put(Integer.valueOf(chm2.getCharCode()),
+                        Integer.valueOf((int)Math.round(dim.getWidth())));
             }
         }
         return m;
@@ -451,14 +451,41 @@ public class AFMFile {
      * @param encoding the encoding to replace the one given in the AFM
      */
     public void overridePrimaryEncoding(SingleByteEncoding encoding) {
-        Iterator iter = this.charMetrics.iterator();
-        while (iter.hasNext()) {
-            AFMCharMetrics cm = (AFMCharMetrics)iter.next();
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("Overriding primary encoding of " + getFontName() + " with: " + encoding);
+        }
+        AFMCharMetrics[] mapped = new AFMCharMetrics[256];
+        for (AFMCharMetrics cm : this.charMetrics) {
             NamedCharacter nc = cm.getCharacter();
             if (nc.hasSingleUnicodeValue()) {
-                int mapped = encoding.mapChar(nc.getSingleUnicodeValue());
-                if (mapped > 0) {
-                    cm.setCharCode(mapped);
+                int codePoint = encoding.mapChar(nc.getSingleUnicodeValue());
+                if (codePoint > 0) {
+                    if (mapped[codePoint] != null) {
+                        if (LOG.isDebugEnabled()) {
+                            AFMCharMetrics other = mapped[codePoint];
+                            String msg = "Not mapping character " + nc + " to code point "
+                                + codePoint + " (" + Integer.toHexString(codePoint) + ") in "
+                                + encoding + ". "
+                                + other + " has already been assigned that code point.";
+                            if (other.getUnicodeSequence()
+                                    .equals(nc.getUnicodeSequence())) {
+                                msg += " This is a specialized glyph for the"
+                                    + " same Unicode character.";
+                                //TODO should these be mapped to a private Unicode area to make
+                                //them accessible?
+                            } else {
+                                msg += " This is a similar character.";
+                            }
+                            if (cm.getWidthX() != other.getWidthX()) {
+                                msg += " They have differing widths: "
+                                    + cm.getWidthX() + " vs. " + other.getWidthX();
+                            }
+                            LOG.debug(msg);
+                        }
+                    } else {
+                        cm.setCharCode(codePoint);
+                        mapped[codePoint] = cm;
+                    }
                 } else {
                     cm.setCharCode(-1);
                 }
@@ -470,6 +497,7 @@ public class AFMFile {
     }
 
     /** {@inheritDoc} */
+    @Override
     public String toString() {
         return "AFM: " + getFullName();
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMParser.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMParser.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/AFMParser.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,10 @@ package org.apache.fop.fonts.type1;
 import java.awt.Rectangle;
 import java.beans.Statement;
 import java.io.BufferedReader;
-import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.Reader;
+import java.util.HashMap;
 import java.util.Map;
 import java.util.Stack;
 
@@ -97,11 +97,11 @@ public class AFMParser {
     private static final int PARSE_NORMAL = 0;
     private static final int PARSE_CHAR_METRICS = 1;
 
-    private static final Map VALUE_PARSERS;
-    private static final Map PARSE_MODE_CHANGES;
+    private static final Map<String, ValueHandler> VALUE_PARSERS;
+    private static final Map<String, Integer> PARSE_MODE_CHANGES;
 
     static {
-        VALUE_PARSERS = new java.util.HashMap();
+        VALUE_PARSERS = new HashMap<String, ValueHandler>();
         VALUE_PARSERS.put(START_FONT_METRICS, new StartFontMetrics());
         VALUE_PARSERS.put(FONT_NAME, new StringSetter(FONT_NAME));
         VALUE_PARSERS.put(FULL_NAME, new StringSetter(FULL_NAME));
@@ -146,7 +146,7 @@ public class AFMParser {
         VALUE_PARSERS.put(KPX, new KPXHandler());
         VALUE_PARSERS.put(KPY, new NotImplementedYet(KPY));
 
-        PARSE_MODE_CHANGES = new java.util.HashMap();
+        PARSE_MODE_CHANGES = new HashMap<String, Integer>();
         PARSE_MODE_CHANGES.put(START_CHAR_METRICS, new Integer(PARSE_CHAR_METRICS));
         PARSE_MODE_CHANGES.put(END_CHAR_METRICS, new Integer(PARSE_NORMAL));
     }
@@ -155,34 +155,19 @@ public class AFMParser {
      * Main constructor.
      */
     public AFMParser() {
-        //nop
-    }
-
-    /**
-     * Parses an AFM file from a local file.
-     * @param afmFile the AFM file
-     * @return the parsed AFM file
-     * @throws IOException if an I/O error occurs
-     */
-    public AFMFile parse(File afmFile) throws IOException {
-        InputStream in = new java.io.FileInputStream(afmFile);
-        try {
-            return parse(in);
-        } finally {
-            IOUtils.closeQuietly(in);
-        }
     }
 
     /**
      * Parses an AFM file from a stream.
      * @param in the stream to read from
+     * @param afmFileName the name of the AFM file
      * @return the parsed AFM file
      * @throws IOException if an I/O error occurs
      */
-    public AFMFile parse(InputStream in) throws IOException {
+    public AFMFile parse(InputStream in, String afmFileName) throws IOException {
         Reader reader = new java.io.InputStreamReader(in, "US-ASCII");
         try {
-            return parse(new BufferedReader(reader));
+            return parse(new BufferedReader(reader), afmFileName);
         } finally {
             IOUtils.closeQuietly(reader);
         }
@@ -191,11 +176,12 @@ public class AFMParser {
     /**
      * Parses an AFM file from a BufferedReader.
      * @param reader the BufferedReader instance to read from
+     * @param afmFileName the name of the AFM file
      * @return the parsed AFM file
      * @throws IOException if an I/O error occurs
      */
-    public AFMFile parse(BufferedReader reader) throws IOException {
-        Stack stack = new Stack();
+    public AFMFile parse(BufferedReader reader, String afmFileName) throws IOException {
+        Stack<Object> stack = new Stack<Object>();
         int parseMode = PARSE_NORMAL;
         while (true) {
             String line = reader.readLine();
@@ -208,12 +194,12 @@ public class AFMParser {
                 key = parseLine(line, stack);
                 break;
             case PARSE_CHAR_METRICS:
-                key = parseCharMetrics(line, stack);
+                key = parseCharMetrics(line, stack, afmFileName);
                 break;
             default:
                 throw new IllegalStateException("Invalid parse mode");
             }
-            Integer newParseMode = (Integer)PARSE_MODE_CHANGES.get(key);
+            Integer newParseMode = PARSE_MODE_CHANGES.get(key);
             if (newParseMode != null) {
                 parseMode = newParseMode.intValue();
             }
@@ -221,7 +207,7 @@ public class AFMParser {
         return (AFMFile)stack.pop();
     }
 
-    private String parseLine(String line, Stack stack) throws IOException {
+    private String parseLine(String line, Stack<Object> stack) throws IOException {
         int startpos = 0;
         //Find key
         startpos = skipToNonWhiteSpace(line, startpos);
@@ -230,47 +216,24 @@ public class AFMParser {
 
         //Parse value
         startpos = skipToNonWhiteSpace(line, endpos);
-        ValueHandler vp = (ValueHandler)VALUE_PARSERS.get(key);
+        ValueHandler vp = VALUE_PARSERS.get(key);
         if (vp != null) {
             vp.parse(line, startpos, stack);
         }
         return key;
     }
 
-    private String parseCharMetrics(String line, Stack stack) throws IOException {
-        int startpos = 0;
-        AFMCharMetrics chm = new AFMCharMetrics();
-        stack.push(chm);
-        while (true) {
-            //Find key
-            startpos = skipToNonWhiteSpace(line, startpos);
-            int endpos = skipToWhiteSpace(line, startpos);
-            String key = line.substring(startpos, endpos);
-            if (END_CHAR_METRICS.equals(key)) {
-                stack.pop(); //Pop and forget unused AFMCharMetrics instance
-                return key;
-            } else if (key.length() == 0) {
-                //EOL: No more key so break
-                break;
-            }
-
-            //Extract value
-            startpos = skipToNonWhiteSpace(line, endpos);
-            endpos = skipToSemicolon(line, startpos);
-            String value = line.substring(startpos, endpos).trim();
-            startpos = endpos + 1;
-
-            //Parse value
-            ValueHandler vp = (ValueHandler)VALUE_PARSERS.get(key);
-            if (vp != null) {
-                vp.parse(value, 0, stack);
-            }
-            if (false) {
-                break;
-            }
-        }
-        stack.pop();
-        AFMFile afm = (AFMFile)stack.peek();
+    private String parseCharMetrics(String line, Stack<Object> stack, String afmFileName)
+            throws IOException {
+        String trimmedLine = line.trim();
+        if (END_CHAR_METRICS.equals(trimmedLine)) {
+            return trimmedLine;
+        }
+        AFMFile afm = (AFMFile) stack.peek();
+        String encoding = afm.getEncodingScheme();
+        CharMetricsHandler charMetricsHandler = CharMetricsHandler.getHandler(VALUE_PARSERS,
+                encoding);
+        AFMCharMetrics chm = charMetricsHandler.parse(trimmedLine, stack, afmFileName);
         afm.addCharMetrics(chm);
         return null;
     }
@@ -291,14 +254,6 @@ public class AFMParser {
         return pos;
     }
 
-    private static int skipToSemicolon(String line, int startpos) {
-        int pos = startpos;
-        while (pos < line.length() && ';' != line.charAt(pos)) {
-            pos++;
-        }
-        return pos;
-    }
-
     private static boolean isWhitespace(char ch) {
         return ch == ' '
             || ch == '\t';
@@ -306,8 +261,8 @@ public class AFMParser {
 
     // ---------------- Value Handlers ---------------------------
 
-    private interface ValueHandler {
-        void parse(String line, int startpos, Stack stack) throws IOException;
+    interface ValueHandler {
+        void parse(String line, int startpos, Stack<Object> stack) throws IOException;
     }
 
     private abstract static class AbstractValueHandler implements ValueHandler {
@@ -345,7 +300,7 @@ public class AFMParser {
     }
 
     private static class StartFontMetrics extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             int endpos = findValue(line, startpos);
             double version = Double.parseDouble(line.substring(startpos, endpos));
             if (version < 2) {
@@ -382,7 +337,7 @@ public class AFMParser {
             super(variable);
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             String s = getStringValue(line, startpos);
             Object obj = stack.peek();
             setValue(obj, s);
@@ -395,7 +350,7 @@ public class AFMParser {
             super(variable);
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             NamedCharacter ch = new NamedCharacter(getStringValue(line, startpos));
             Object obj = stack.peek();
             setValue(obj, ch);
@@ -407,11 +362,11 @@ public class AFMParser {
             super(variable);
         }
 
-        protected Object getContextObject(Stack stack) {
+        protected Object getContextObject(Stack<Object> stack) {
             return stack.peek();
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             Number num = getNumberValue(line, startpos);
             setValue(getContextObject(stack), num);
         }
@@ -422,7 +377,7 @@ public class AFMParser {
             super(variable);
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             int value = getIntegerValue(line, startpos);
             setValue(getContextObject(stack), new Integer(value));
         }
@@ -433,7 +388,7 @@ public class AFMParser {
             super(variable);
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             double value = getDoubleValue(line, startpos);
             setValue(getContextObject(stack), new Double(value));
         }
@@ -445,7 +400,7 @@ public class AFMParser {
             super(variable);
         }
 
-        protected Object getContextObject(Stack stack) {
+        protected Object getContextObject(Stack<Object> stack) {
             if (stack.peek() instanceof AFMWritingDirectionMetrics) {
                 return (AFMWritingDirectionMetrics)stack.peek();
             } else {
@@ -467,7 +422,7 @@ public class AFMParser {
             super(variable);
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             double value = getDoubleValue(line, startpos);
             setValue(getContextObject(stack), new Double(value));
         }
@@ -480,11 +435,11 @@ public class AFMParser {
             this.method = "set" + variable.substring(2); //Cut "Is" in front
         }
 
-        protected Object getContextObject(Stack stack) {
+        protected Object getContextObject(Stack<Object> stack) {
             return (AFMFile)stack.peek();
         }
 
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             Boolean b = getBooleanValue(line, startpos);
             //Uses Java Beans API
             Statement statement = new Statement(getContextObject(stack),
@@ -504,7 +459,7 @@ public class AFMParser {
             super(variable);
         }
 
-        protected Object getContextObject(Stack stack) {
+        protected Object getContextObject(Stack<Object> stack) {
             if (stack.peek() instanceof AFMWritingDirectionMetrics) {
                 return (AFMWritingDirectionMetrics)stack.peek();
             } else {
@@ -521,7 +476,7 @@ public class AFMParser {
     }
 
     private static class FontBBox extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             Rectangle rect = parseBBox(line, startpos);
 
             AFMFile afm = (AFMFile)stack.peek();
@@ -554,7 +509,7 @@ public class AFMParser {
     }
 
     private static class CharBBox extends FontBBox {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             Rectangle rect = parseBBox(line, startpos);
 
             AFMCharMetrics metrics = (AFMCharMetrics)stack.peek();
@@ -563,7 +518,7 @@ public class AFMParser {
     }
 
     private static class IsBaseFont extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             if (getBooleanValue(line, startpos).booleanValue()) {
                 throw new IOException("Only base fonts are currently supported!");
             }
@@ -571,7 +526,7 @@ public class AFMParser {
     }
 
     private static class IsCIDFont extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             if (getBooleanValue(line, startpos).booleanValue()) {
                 throw new IOException("CID fonts are currently not supported!");
             }
@@ -592,7 +547,7 @@ public class AFMParser {
     }
 
     private static class StartDirection extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             int index = getIntegerValue(line, startpos);
             AFMWritingDirectionMetrics wdm = new AFMWritingDirectionMetrics();
             AFMFile afm = (AFMFile)stack.peek();
@@ -602,7 +557,7 @@ public class AFMParser {
     }
 
     private static class EndDirection extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             if (!(stack.pop() instanceof AFMWritingDirectionMetrics)) {
                 throw new IOException("AFM format error: nesting incorrect");
             }
@@ -610,7 +565,7 @@ public class AFMParser {
     }
 
     private static class KPXHandler extends AbstractValueHandler {
-        public void parse(String line, int startpos, Stack stack) throws IOException {
+        public void parse(String line, int startpos, Stack<Object> stack) throws IOException {
             AFMFile afm = (AFMFile)stack.peek();
             int endpos;
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBData.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBData.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBData.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBData.java Thu Apr  5 16:19:19 2012
@@ -19,8 +19,8 @@
 
 package org.apache.fop.fonts.type1;
 
-import java.io.OutputStream;
 import java.io.IOException;
+import java.io.OutputStream;
 
 /**
  * Class that represents the contents of a PFB file.
@@ -158,4 +158,4 @@ public class PFBData {
                 + " len3=" + getLength3();
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBParser.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBParser.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFBParser.java Thu Apr  5 16:19:19 2012
@@ -19,12 +19,11 @@
 
 package org.apache.fop.fonts.type1;
 
+import java.io.BufferedInputStream;
+import java.io.DataInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.DataInputStream;
-import java.io.BufferedInputStream;
 
-//Commons
 import org.apache.commons.io.IOUtils;
 
 /**
@@ -233,4 +232,4 @@ public class PFBParser {
         calcLengths(pfb, IOUtils.toByteArray(bin));
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFMInputStream.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFMInputStream.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFMInputStream.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/PFMInputStream.java Thu Apr  5 16:19:19 2012
@@ -19,10 +19,10 @@
 
 package org.apache.fop.fonts.type1;
 
+import java.io.DataInputStream;
 import java.io.EOFException;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.DataInputStream;
 import java.io.InputStreamReader;
 
 /**

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java Thu Apr  5 16:19:19 2012
@@ -22,7 +22,7 @@ package org.apache.fop.fonts.type1;
 import java.awt.geom.RectangularShape;
 import java.io.IOException;
 import java.io.InputStream;
-import java.util.Iterator;
+import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
 
@@ -52,7 +52,7 @@ public class Type1FontLoader extends Fon
      */
     public Type1FontLoader(String fontFileURI, boolean embedded, boolean useKerning,
             FontResolver resolver) throws IOException {
-        super(fontFileURI, embedded, useKerning, resolver);
+        super(fontFileURI, embedded, useKerning, true, resolver);
     }
 
     private String getPFMURI(String pfbURI) {
@@ -65,27 +65,29 @@ public class Type1FontLoader extends Fon
     private static final String[] AFM_EXTENSIONS = new String[] {".AFM", ".afm", ".Afm"};
 
     /** {@inheritDoc} */
+    @Override
     protected void read() throws IOException {
         AFMFile afm = null;
         PFMFile pfm = null;
 
         InputStream afmIn = null;
+        String afmUri = null;
         for (int i = 0; i < AFM_EXTENSIONS.length; i++) {
             try {
-                String afmUri = this.fontFileURI.substring(0, this.fontFileURI.length() - 4)
+                afmUri = this.fontFileURI.substring(0, this.fontFileURI.length() - 4)
                         + AFM_EXTENSIONS[i];
                 afmIn = openFontUri(resolver, afmUri);
                 if (afmIn != null) {
                     break;
                 }
             } catch (IOException ioe) {
-                //Ignore, AFM probably not available under the URI
+                // Ignore, AFM probably not available under the URI
             }
         }
         if (afmIn != null) {
             try {
                 AFMParser afmParser = new AFMParser();
-                afm = afmParser.parse(afmIn);
+                afm = afmParser.parse(afmIn, afmUri);
             } finally {
                 IOUtils.closeQuietly(afmIn);
             }
@@ -96,7 +98,7 @@ public class Type1FontLoader extends Fon
         try {
             pfmIn = openFontUri(resolver, pfmUri);
         } catch (IOException ioe) {
-            //Ignore, PFM probably not available under the URI
+            // Ignore, PFM probably not available under the URI
         }
         if (pfmIn != null) {
             try {
@@ -104,7 +106,7 @@ public class Type1FontLoader extends Fon
                 pfm.load(pfmIn);
             } catch (IOException ioe) {
                 if (afm == null) {
-                    //Ignore the exception if we have a valid PFM. PFM is only the fallback.
+                    // Ignore the exception if we have a valid PFM. PFM is only the fallback.
                     throw ioe;
                 }
             } finally {
@@ -138,15 +140,13 @@ public class Type1FontLoader extends Fon
     }
 
     private void handleEncoding(AFMFile afm, PFMFile pfm) {
-        //Encoding
+        // Encoding
         if (afm != null) {
             String encoding = afm.getEncodingScheme();
             singleFont.setUseNativeEncoding(true);
             if ("AdobeStandardEncoding".equals(encoding)) {
                 singleFont.setEncoding(CodePointMapping.STANDARD_ENCODING);
                 addUnencodedBasedOnEncoding(afm);
-                //char codes in the AFM cannot be relied on in this case, so we override
-                afm.overridePrimaryEncoding(singleFont.getEncoding());
             } else {
                 String effEncodingName;
                 if ("FontSpecific".equals(encoding)) {
@@ -168,15 +168,15 @@ public class Type1FontLoader extends Fon
             } else {
                 log.warn("The PFM reports an unsupported encoding ("
                         + pfm.getCharSetName() + "). The font may not work as expected.");
-                singleFont.setEncoding("WinAnsiEncoding"); //Try fallback, no guarantees!
+                singleFont.setEncoding("WinAnsiEncoding"); // Try fallback, no guarantees!
             }
         }
     }
 
-    private Set toGlyphSet(String[] glyphNames) {
-        Set glyphSet = new java.util.HashSet();
-        for (int i = 0, c = glyphNames.length; i < c; i++) {
-            glyphSet.add(glyphNames[i]);
+    private Set<String> toGlyphSet(String[] glyphNames) {
+        Set<String> glyphSet = new java.util.HashSet<String>();
+        for (String name : glyphNames) {
+            glyphSet.add(name);
         }
         return glyphSet;
     }
@@ -188,10 +188,9 @@ public class Type1FontLoader extends Fon
      */
     private void addUnencodedBasedOnEncoding(AFMFile afm) {
         SingleByteEncoding encoding = singleFont.getEncoding();
-        Set glyphNames = toGlyphSet(encoding.getCharNameMap());
-        List charMetrics = afm.getCharMetrics();
-        for (int i = 0, c = afm.getCharCount(); i < c; i++) {
-            AFMCharMetrics metrics = (AFMCharMetrics)charMetrics.get(i);
+        Set<String> glyphNames = toGlyphSet(encoding.getCharNameMap());
+        List<AFMCharMetrics> charMetrics = afm.getCharMetrics();
+        for (AFMCharMetrics metrics : charMetrics) {
             String charName = metrics.getCharName();
             if (charName != null && !glyphNames.contains(charName)) {
                 singleFont.addUnencodedCharacter(metrics.getCharacter(),
@@ -218,26 +217,26 @@ public class Type1FontLoader extends Fon
     }
 
     private void handleFontName(AFMFile afm, PFMFile pfm) {
-        //Font name
+        // Font name
         if (afm != null) {
-            returnFont.setFontName(afm.getFontName()); //PostScript font name
+            returnFont.setFontName(afm.getFontName()); // PostScript font name
             returnFont.setFullName(afm.getFullName());
-            Set names = new java.util.HashSet();
+            Set<String> names = new HashSet<String>();
             names.add(afm.getFamilyName());
             returnFont.setFamilyNames(names);
         } else {
             returnFont.setFontName(pfm.getPostscriptName());
             String fullName = pfm.getPostscriptName();
-            fullName = fullName.replace('-', ' '); //Hack! Try to emulate full name
-            returnFont.setFullName(fullName); //emulate afm.getFullName()
-            Set names = new java.util.HashSet();
-            names.add(pfm.getWindowsName()); //emulate afm.getFamilyName()
+            fullName = fullName.replace('-', ' '); // Hack! Try to emulate full name
+            returnFont.setFullName(fullName); // emulate afm.getFullName()
+            Set<String> names = new HashSet<String>();
+            names.add(pfm.getWindowsName()); // emulate afm.getFamilyName()
             returnFont.setFamilyNames(names);
         }
     }
 
     private void handleMetrics(AFMFile afm, PFMFile pfm) {
-        //Basic metrics
+        // Basic metrics
         if (afm != null) {
             if (afm.getCapHeight() != null) {
                 returnFont.setCapHeight(afm.getCapHeight().intValue());
@@ -256,16 +255,16 @@ public class Type1FontLoader extends Fon
             if (afm.getStdVW() != null) {
                 returnFont.setStemV(afm.getStdVW().intValue());
             } else {
-                returnFont.setStemV(80); //Arbitrary value
+                returnFont.setStemV(80); // Arbitrary value
             }
-            returnFont.setItalicAngle((int)afm.getWritingDirectionMetrics(0).getItalicAngle());
+            returnFont.setItalicAngle((int) afm.getWritingDirectionMetrics(0).getItalicAngle());
         } else {
             returnFont.setFontBBox(pfm.getFontBBox());
             returnFont.setStemV(pfm.getStemV());
             returnFont.setItalicAngle(pfm.getItalicAngle());
         }
         if (pfm != null) {
-            //Sometimes the PFM has these metrics while the AFM doesn't (ex. Symbol)
+            // Sometimes the PFM has these metrics while the AFM doesn't (ex. Symbol)
             if (returnFont.getCapHeight() == 0) {
                 returnFont.setCapHeight(pfm.getCapHeight());
             }
@@ -280,8 +279,8 @@ public class Type1FontLoader extends Fon
             }
         }
 
-        //Fallbacks when some crucial font metrics aren't available
-        //(the following are all optional in AFM, but FontBBox is always available)
+        // Fallbacks when some crucial font metrics aren't available
+        // (the following are all optional in AFM, but FontBBox is always available)
         if (returnFont.getXHeight(1) == 0) {
             int xHeight = 0;
             if (afm != null) {
@@ -289,7 +288,7 @@ public class Type1FontLoader extends Fon
                 if (chm != null) {
                     RectangularShape rect = chm.getBBox();
                     if (rect != null) {
-                        xHeight = (int)Math.round(rect.getMinX());
+                        xHeight = (int) Math.round(rect.getMinX());
                     }
                 }
             }
@@ -305,7 +304,7 @@ public class Type1FontLoader extends Fon
                 if (chm != null) {
                     RectangularShape rect = chm.getBBox();
                     if (rect != null) {
-                        asc = (int)Math.round(rect.getMinX());
+                        asc = (int) Math.round(rect.getMinX());
                     }
                 }
             }
@@ -321,7 +320,7 @@ public class Type1FontLoader extends Fon
                 if (chm != null) {
                     RectangularShape rect = chm.getBBox();
                     if (rect != null) {
-                        desc = (int)Math.round(rect.getMinX());
+                        desc = (int) Math.round(rect.getMinX());
                     }
                 }
             }
@@ -338,30 +337,28 @@ public class Type1FontLoader extends Fon
             String charSet = afm.getCharacterSet();
             int flags = 0;
             if ("Special".equals(charSet)) {
-                flags |= 4; //bit 3: Symbolic
+                flags |= 4; // bit 3: Symbolic
             } else {
                 if (singleFont.getEncoding().mapChar('A') == 'A') {
-                    //High likelyhood that the font is non-symbolic
-                    flags |= 32; //bit 6: Nonsymbolic
+                    // High likelyhood that the font is non-symbolic
+                    flags |= 32; // bit 6: Nonsymbolic
                 } else {
-                    flags |= 4; //bit 3: Symbolic
+                    flags |= 4; // bit 3: Symbolic
                 }
             }
             if (afm.getWritingDirectionMetrics(0).isFixedPitch()) {
-                flags |= 1; //bit 1: FixedPitch
+                flags |= 1; // bit 1: FixedPitch
             }
             if (afm.getWritingDirectionMetrics(0).getItalicAngle() != 0.0) {
-                flags |= 64; //bit 7: Italic
+                flags |= 64; // bit 7: Italic
             }
             returnFont.setFlags(flags);
 
             returnFont.setFirstChar(afm.getFirstChar());
             returnFont.setLastChar(afm.getLastChar());
-            Iterator iter = afm.getCharMetrics().iterator();
-            while (iter.hasNext()) {
-                AFMCharMetrics chm = (AFMCharMetrics)iter.next();
+            for (AFMCharMetrics chm : afm.getCharMetrics()) {
                 if (chm.hasCharCode()) {
-                    singleFont.setWidth(chm.getCharCode(), (int)Math.round(chm.getWidthX()));
+                    singleFont.setWidth(chm.getCharCode(), (int) Math.round(chm.getWidthX()));
                 }
             }
             if (useKerning) {
@@ -381,12 +378,10 @@ public class Type1FontLoader extends Fon
     }
 
     private CodePointMapping buildCustomEncoding(String encodingName, AFMFile afm) {
-        List chars = afm.getCharMetrics();
         int mappingCount = 0;
-        //Just count the first time...
-        Iterator iter = chars.iterator();
-        while (iter.hasNext()) {
-            AFMCharMetrics charMetrics = (AFMCharMetrics)iter.next();
+        // Just count the first time...
+        List<AFMCharMetrics> chars = afm.getCharMetrics();
+        for (AFMCharMetrics charMetrics : chars) {
             if (charMetrics.getCharCode() >= 0) {
                 String u = charMetrics.getUnicodeSequence();
                 if (u != null && u.length() == 1) {
@@ -394,13 +389,11 @@ public class Type1FontLoader extends Fon
                 }
             }
         }
-        //...and now build the table.
+        // ...and now build the table.
         int[] table = new int[mappingCount * 2];
         String[] charNameMap = new String[256];
-        iter = chars.iterator();
         int idx = 0;
-        while (iter.hasNext()) {
-            AFMCharMetrics charMetrics = (AFMCharMetrics)iter.next();
+        for (AFMCharMetrics charMetrics : chars) {
             if (charMetrics.getCharCode() >= 0) {
                 charNameMap[charMetrics.getCharCode()] = charMetrics.getCharName();
                 String unicodes = charMetrics.getUnicodeSequence();

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/ByteVector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/ByteVector.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/ByteVector.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/ByteVector.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,10 @@ package org.apache.fop.hyphenation;
 import java.io.Serializable;
 
 /**
- * This class implements a simple byte vector with access to the
- * underlying array.
+ * <p>This class implements a simple byte vector with access to the
+ * underlying array.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public class ByteVector implements Serializable {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/CharVector.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/CharVector.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/CharVector.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/CharVector.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,10 @@ package org.apache.fop.hyphenation;
 import java.io.Serializable;
 
 /**
- * This class implements a simple char vector with access to the
- * underlying array.
+ * <p>This class implements a simple char vector with access to the
+ * underlying array.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public class CharVector implements Cloneable, Serializable {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphen.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphen.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphen.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphen.java Thu Apr  5 16:19:19 2012
@@ -22,16 +22,16 @@ package org.apache.fop.hyphenation;
 import java.io.Serializable;
 
 /**
- * This class represents a hyphen. A 'full' hyphen is made of 3 parts:
+ * <p>This class represents a hyphen. A 'full' hyphen is made of 3 parts:
  * the pre-break text, post-break text and no-break. If no line-break
  * is generated at this position, the no-break text is used, otherwise,
  * pre-break and post-break are used. Typically, pre-break is equal to
  * the hyphen character and the others are empty. However, this general
  * scheme allows support for cases in some languages where words change
  * spelling if they're split across lines, like german's 'backen' which
- * hyphenates 'bak-ken'. BTW, this comes from TeX.
+ * hyphenates 'bak-ken'. BTW, this comes from TeX.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 
 /**

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenation.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenation.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenation.java Thu Apr  5 16:19:19 2012
@@ -20,9 +20,9 @@
 package org.apache.fop.hyphenation;
 
 /**
- * This class represents a hyphenated word.
+ * <p.This class represents a hyphenated word.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public class Hyphenation {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationException.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationException.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationException.java Thu Apr  5 16:19:19 2012
@@ -20,8 +20,10 @@
 package org.apache.fop.hyphenation;
 
 /**
- * An hyphenation exception.
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>An hyphenation exception.</p>
+ *
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
+ *
  * TODO Derive from FOPException
  */
 public class HyphenationException extends Exception {

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTree.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTree.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTree.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTree.java Thu Apr  5 16:19:19 2012
@@ -35,11 +35,11 @@ import java.util.HashMap;
 import org.xml.sax.InputSource;
 
 /**
- * This tree structure stores the hyphenation patterns in an efficient
+ * <p>This tree structure stores the hyphenation patterns in an efficient
  * way for fast lookup. It provides the provides the method to
- * hyphenate a word.
+ * hyphenate a word.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public class HyphenationTree extends TernaryTree
             implements PatternConsumer, Serializable {
@@ -84,7 +84,8 @@ public class HyphenationTree extends Ter
      * are stored.
      */
     protected int packValues(String values) {
-        int i, n = values.length();
+        int i;
+        int n = values.length();
         int m = (n & 1) == 1 ? (n >> 1) + 2 : (n >> 1) + 1;
         int offset = vspace.alloc(m);
         byte[] va = vspace.getArray();
@@ -247,7 +248,8 @@ public class HyphenationTree extends Ter
     protected void searchPatterns(char[] word, int index, byte[] il) {
         byte[] values;
         int i = index;
-        char p, q;
+        char p;
+        char q;
         char sp = word[i];
         p = root;
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeCache.java Thu Apr  5 16:19:19 2012
@@ -24,7 +24,7 @@ import java.util.Map;
 import java.util.Set;
 
 /**
- * This is a cache for HyphenationTree instances.
+ * <p>This is a cache for HyphenationTree instances.</p>
  */
 public class HyphenationTreeCache {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/HyphenationTreeResolver.java Thu Apr  5 16:19:19 2012
@@ -22,7 +22,7 @@ package org.apache.fop.hyphenation;
 import javax.xml.transform.Source;
 
 /**
- * This interface is used to resolve relative URIs pointing to hyphenation tree files.
+ * <p>This interface is used to resolve relative URIs pointing to hyphenation tree files.</p>
  */
 public interface HyphenationTreeResolver {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/Hyphenator.java Thu Apr  5 16:19:19 2012
@@ -29,16 +29,17 @@ import java.util.Map;
 import javax.xml.transform.Source;
 import javax.xml.transform.stream.StreamSource;
 
+import org.xml.sax.InputSource;
+
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.xml.sax.InputSource;
 
 /**
- * This class is the main entry point to the hyphenation package.
- * You can use only the static methods or create an instance.
+ * <p>This class is the main entry point to the hyphenation package.
+ * You can use only the static methods or create an instance.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public final class Hyphenator {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternConsumer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternConsumer.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternConsumer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternConsumer.java Thu Apr  5 16:19:19 2012
@@ -22,10 +22,10 @@ package org.apache.fop.hyphenation;
 import java.util.ArrayList;
 
 /**
- * This interface is used to connect the XML pattern file parser to
- * the hyphenation tree.
+ * <p>This interface is used to connect the XML pattern file parser to
+ * the hyphenation tree.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public interface PatternConsumer {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternParser.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternParser.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/PatternParser.java Thu Apr  5 16:19:19 2012
@@ -19,15 +19,6 @@
 
 package org.apache.fop.hyphenation;
 
-// SAX
-import org.xml.sax.XMLReader;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-import org.xml.sax.Attributes;
-
-// Java
 import java.io.File;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
@@ -39,11 +30,18 @@ import java.util.ArrayList;
 
 import javax.xml.parsers.SAXParserFactory;
 
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.DefaultHandler;
+
 /**
- * A SAX document handler to read and parse hyphenation patterns
- * from a XML file.
+ * <p>A SAX document handler to read and parse hyphenation patterns
+ * from a XML file.</p>
  *
- * @author Carlos Villegas <ca...@uniscope.co.jp>
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 public class PatternParser extends DefaultHandler implements PatternConsumer {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/SerializeHyphPattern.java Thu Apr  5 16:19:19 2012
@@ -25,9 +25,9 @@ import java.io.IOException;
 import java.io.ObjectOutputStream;
 
 /**
- * Serialize hyphenation patterns
- * For all xml files in the source directory a pattern file is built in the target directory
- * This class may be called from the ant build file in a java task
+ * <p>Serialize hyphenation patterns.</p>
+ * <p>For all xml files in the source directory a pattern file is built in the target directory.</p>
+ * <p>This class may be called from the ant build file in a java task.</p>
  */
 public class SerializeHyphPattern {
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/TernaryTree.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/TernaryTree.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/TernaryTree.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/hyphenation/TernaryTree.java Thu Apr  5 16:19:19 2012
@@ -19,9 +19,9 @@
 
 package org.apache.fop.hyphenation;
 
+import java.io.Serializable;
 import java.util.Enumeration;
 import java.util.Stack;
-import java.io.Serializable;
 
 /**
  * <h2>Ternary Search Tree.</h2>
@@ -62,7 +62,7 @@ import java.io.Serializable;
  * char value as an index to an array that contains the object
  * values.</p>
  *
- * @author cav@uniscope.co.jp
+ * <p>This work was authored by Carlos Villegas (cav@uniscope.co.jp).</p>
  */
 
 public class TernaryTree implements Cloneable, Serializable {
@@ -271,7 +271,9 @@ public class TernaryTree implements Clon
      * @return an integer
      */
     public static int strcmp(String str, char[] a, int start) {
-        int i, d, len = str.length();
+        int i;
+        int d;
+        int len = str.length();
         for (i = 0; i < len; i++) {
             d = (int)str.charAt(i) - a[start + i];
             if (d != 0) {
@@ -448,7 +450,8 @@ public class TernaryTree implements Clon
     public void balance() {
         // System.out.print("Before root splitchar = "); System.out.println(sc[root]);
 
-        int i = 0, n = length;
+        int i = 0;
+        int n = length;
         String[] k = new String[n];
         char[] v = new char[n];
         Iterator iter = new Iterator();

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/Graphics2DImagePainterImpl.java Thu Apr  5 16:19:19 2012
@@ -83,4 +83,4 @@ public class Graphics2DImagePainterImpl 
         root.paint(g2d);
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java Thu Apr  5 16:19:19 2012
@@ -25,13 +25,14 @@ import java.util.Map;
 
 import org.w3c.dom.Document;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.GVTBuilder;
 import org.apache.batik.bridge.UserAgent;
 import org.apache.batik.dom.svg.SVGDOMImplementation;
 import org.apache.batik.gvt.GraphicsNode;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.GraphicsConstants;
 import org.apache.xmlgraphics.image.loader.Image;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/ImageConverterWMF2G2D.java Thu Apr  5 16:19:19 2012
@@ -24,11 +24,12 @@ import java.awt.Graphics2D;
 import java.awt.geom.Rectangle2D;
 import java.util.Map;
 
-import org.apache.batik.transcoder.wmf.tosvg.WMFPainter;
-import org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.batik.transcoder.wmf.tosvg.WMFPainter;
+import org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore;
+
 import org.apache.xmlgraphics.image.loader.Image;
 import org.apache.xmlgraphics.image.loader.ImageFlavor;
 import org.apache.xmlgraphics.image.loader.impl.AbstractImageConverter;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java Thu Apr  5 16:19:19 2012
@@ -30,13 +30,14 @@ import javax.xml.transform.dom.DOMSource
 import org.w3c.dom.Element;
 import org.w3c.dom.svg.SVGDocument;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 import org.apache.batik.bridge.BridgeContext;
 import org.apache.batik.bridge.UnitProcessor;
 import org.apache.batik.bridge.UserAgent;
 import org.apache.batik.dom.svg.SAXSVGDocumentFactory;
 import org.apache.batik.dom.svg.SVGOMDocument;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import org.apache.xmlgraphics.image.loader.ImageContext;
 import org.apache.xmlgraphics.image.loader.ImageInfo;

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/image/loader/batik/PreloaderWMF.java Thu Apr  5 16:19:19 2012
@@ -25,13 +25,14 @@ import java.io.InputStream;
 
 import javax.xml.transform.Source;
 
-import org.apache.batik.transcoder.wmf.WMFConstants;
-import org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore;
 import org.apache.commons.io.EndianUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import org.apache.batik.transcoder.wmf.WMFConstants;
+import org.apache.batik.transcoder.wmf.tosvg.WMFRecordStore;
+
 import org.apache.xmlgraphics.image.loader.ImageContext;
 import org.apache.xmlgraphics.image.loader.ImageInfo;
 import org.apache.xmlgraphics.image.loader.ImageSize;



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