xmlgraphics-fop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vhenneb...@apache.org
Subject svn commit: r1040969 [2/2] - in /xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ src/java/org/apache/fop/afp/apps/ src/java/org/apache/fop/afp/parser/ src/java/org/apache/fop/fonts/ src/java/org/apache/fop/fonts/autodetect/ src/java/org/apache/f...
Date Wed, 01 Dec 2010 11:58:59 GMT
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=1040969&r1=1040968&r2=1040969&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 Wed Dec  1 11:58:58 2010
@@ -22,7 +22,6 @@ package org.apache.fop.fonts.autodetect;
 import java.io.InputStream;
 import java.net.URL;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
 import java.util.regex.Pattern;
@@ -30,7 +29,6 @@ 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.EncodingMode;
@@ -52,7 +50,7 @@ import org.apache.fop.fonts.truetype.TTF
 public class FontInfoFinder {
 
     /** logging instance */
-    private Log log = LogFactory.getLog(FontInfoFinder.class);
+    private final Log log = LogFactory.getLog(FontInfoFinder.class);
 
     private FontEventListener eventListener;
 
@@ -72,7 +70,7 @@ public class FontInfoFinder {
      * @param customFont CustomFont
      * @param triplets Collection that will take the generated triplets
      */
-    private void generateTripletsFromFont(CustomFont customFont, Collection triplets) {
+    private void generateTripletsFromFont(CustomFont customFont, Collection<FontTriplet> triplets) {
         if (log.isTraceEnabled()) {
             log.trace("Font: " + customFont.getFullName()
                     + ", family: " + customFont.getFamilyNames()
@@ -99,10 +97,9 @@ public class FontInfoFinder {
         if (!fullName.equals(strippedName)) {
             triplets.add(new FontTriplet(strippedName, Font.STYLE_NORMAL, Font.WEIGHT_NORMAL));
         }
-        Set familyNames = customFont.getFamilyNames();
-        Iterator iter = familyNames.iterator();
-        while (iter.hasNext()) {
-            String familyName = stripQuotes((String)iter.next());
+        Set<String> familyNames = customFont.getFamilyNames();
+        for (String familyName : familyNames) {
+            familyName = stripQuotes(familyName);
             if (!fullName.equals(familyName)) {
                 /* Heuristic:
                  *   The more similar the family name to the full font name,
@@ -135,17 +132,17 @@ public class FontInfoFinder {
 
     /**
      * Attempts to determine FontInfo from a given custom font
-     * @param fontUrl the font URL
+     * @param fontURL the font URL
      * @param customFont the custom font
      * @param fontCache font cache (may be null)
      * @return FontInfo from the given custom font
      */
     private EmbedFontInfo getFontInfoFromCustomFont(
-            URL fontUrl, CustomFont customFont, FontCache fontCache) {
-        List fontTripletList = new java.util.ArrayList();
+            URL fontURL, CustomFont customFont, FontCache fontCache) {
+        List<FontTriplet> fontTripletList = new java.util.ArrayList<FontTriplet>();
         generateTripletsFromFont(customFont, fontTripletList);
         String embedUrl;
-        embedUrl = fontUrl.toExternalForm();
+        embedUrl = fontURL.toExternalForm();
         String subFontName = null;
         if (customFont instanceof MultiByteFont) {
             subFontName = ((MultiByteFont)customFont).getTTCName();
@@ -162,29 +159,29 @@ public class FontInfoFinder {
     /**
      * Attempts to determine EmbedFontInfo from a given font file.
      *
-     * @param fontUrl font URL. Assumed to be local.
+     * @param fontURL font URL. Assumed to be local.
      * @param resolver font resolver used to resolve font
      * @param fontCache font cache (may be null)
      * @return an array of newly created embed font info. Generally, this array
      *         will have only one entry, unless the fontUrl is a TrueType Collection
      */
-    public EmbedFontInfo[] find(URL fontUrl, FontResolver resolver, FontCache fontCache) {
-        String embedUrl = null;
-        embedUrl = fontUrl.toExternalForm();
+    public EmbedFontInfo[] find(URL fontURL, FontResolver resolver, FontCache fontCache) {
+        String embedURL = null;
+        embedURL = fontURL.toExternalForm();
 
         long fileLastModified = -1;
         if (fontCache != null) {
-            fileLastModified = FontCache.getLastModified(fontUrl);
+            fileLastModified = FontCache.getLastModified(fontURL);
             // firstly try and fetch it from cache before loading/parsing the font file
-            if (fontCache.containsFont(embedUrl)) {
-                EmbedFontInfo[] fontInfos = fontCache.getFontInfos(embedUrl, fileLastModified);
+            if (fontCache.containsFont(embedURL)) {
+                EmbedFontInfo[] fontInfos = fontCache.getFontInfos(embedURL, fileLastModified);
                 if (fontInfos != null) {
                     return fontInfos;
                 }
             // is this a previously failed parsed font?
-            } else if (fontCache.isFailedFont(embedUrl, fileLastModified)) {
+            } else if (fontCache.isFailedFont(embedURL, fileLastModified)) {
                 if (log.isDebugEnabled()) {
-                    log.debug("Skipping font file that failed to load previously: " + embedUrl);
+                    log.debug("Skipping font file that failed to load previously: " + embedURL);
                 }
                 return null;
             }
@@ -193,77 +190,72 @@ public class FontInfoFinder {
 
         // try to determine triplet information from font file
         CustomFont customFont = null;
-        if (fontUrl.toExternalForm().endsWith(".ttc")) {
+        if (fontURL.toExternalForm().endsWith(".ttc")) {
             // Get a list of the TTC Font names
-            List ttcNames = null; //List<String>
-            String fontFileURI = fontUrl.toExternalForm().trim();
+            List<String> ttcNames = null;
+            String fontFileURL = fontURL.toExternalForm().trim();
             InputStream in = null;
             try {
-                in = FontLoader.openFontUri(resolver, fontFileURI);
+                in = FontLoader.openFontUri(resolver, fontFileURL);
                 TTFFile ttf = new TTFFile();
                 FontFileReader reader = new FontFileReader(in);
                 ttcNames = ttf.getTTCnames(reader);
             } catch (Exception e) {
                 if (this.eventListener != null) {
-                    this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURI, e);
+                    this.eventListener.fontLoadingErrorAtAutoDetection(this, fontFileURL, e);
                 }
                 return null;
             } finally {
                 IOUtils.closeQuietly(in);
             }
 
-            List/*<EmbedFontInfo>*/ embedFontInfoList
-                = new java.util.ArrayList/*<EmbedFontInfo>*/();
+            List<EmbedFontInfo> embedFontInfoList = new java.util.ArrayList<EmbedFontInfo>();
 
             // For each font name ...
-            //for (String fontName : ttcNames) {
-            Iterator ttcNamesIterator = ttcNames.iterator();
-            while (ttcNamesIterator.hasNext()) {
-                String fontName = (String)ttcNamesIterator.next();
-
+            for (String fontName : ttcNames) {
                 if (log.isDebugEnabled()) {
                     log.debug("Loading " + fontName);
                 }
                 try {
                     TTFFontLoader ttfLoader = new TTFFontLoader(
-                            fontFileURI, fontName, true, EncodingMode.AUTO, true, resolver);
+                            fontFileURL, fontName, true, EncodingMode.AUTO, true, resolver);
                     customFont = ttfLoader.getFont();
                     if (this.eventListener != null) {
                         customFont.setEventListener(this.eventListener);
                     }
                 } catch (Exception e) {
                     if (fontCache != null) {
-                        fontCache.registerFailedFont(embedUrl, fileLastModified);
+                        fontCache.registerFailedFont(embedURL, fileLastModified);
                     }
                     if (this.eventListener != null) {
-                        this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+                        this.eventListener.fontLoadingErrorAtAutoDetection(this, embedURL, e);
                     }
                     continue;
                 }
-                EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache);
+                EmbedFontInfo fi = getFontInfoFromCustomFont(fontURL, customFont, fontCache);
                 if (fi != null) {
                     embedFontInfoList.add(fi);
                 }
             }
-            return (EmbedFontInfo[])embedFontInfoList.toArray(
+            return embedFontInfoList.toArray(
                     new EmbedFontInfo[embedFontInfoList.size()]);
         } else {
             // The normal case
             try {
-                customFont = FontLoader.loadFont(fontUrl, null, true, EncodingMode.AUTO, resolver);
+                customFont = FontLoader.loadFont(fontURL, null, true, EncodingMode.AUTO, resolver);
                 if (this.eventListener != null) {
                     customFont.setEventListener(this.eventListener);
                 }
             } catch (Exception e) {
                 if (fontCache != null) {
-                    fontCache.registerFailedFont(embedUrl, fileLastModified);
+                    fontCache.registerFailedFont(embedURL, fileLastModified);
                 }
                 if (this.eventListener != null) {
-                    this.eventListener.fontLoadingErrorAtAutoDetection(this, embedUrl, e);
+                    this.eventListener.fontLoadingErrorAtAutoDetection(this, embedURL, e);
                 }
                 return null;
             }
-            EmbedFontInfo fi = getFontInfoFromCustomFont(fontUrl, customFont, fontCache);
+            EmbedFontInfo fi = getFontInfoFromCustomFont(fontURL, customFont, fontCache);
             if (fi != null) {
                 return new EmbedFontInfo[] {fi};
             } else {

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/fonts/autodetect/NativeFontDirFinder.java Wed Dec  1 11:58:58 2010
@@ -25,15 +25,15 @@ import java.util.List;
 /**
  * Native font finder base class
  */
-public abstract class NativeFontDirFinder implements FontFinder {
+public abstract class NativeFontDirFinder implements FontDirFinder {
 
     /**
      * Generic method used by Mac and Unix font finders.
      * @return list of natively existing font directories
      * {@inheritDoc}
      */
-    public List find() {
-        List fontDirList = new java.util.ArrayList();
+    public List<File> find() {
+        List<File> fontDirList = new java.util.ArrayList<File>();
         String[] searchableDirectories = getSearchableDirectories();
         if (searchableDirectories != null) {
             for (int i = 0; i < searchableDirectories.length; i++) {

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=1040969&r1=1040968&r2=1040969&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 Wed Dec  1 11:58:58 2010
@@ -28,7 +28,7 @@ import java.util.List;
 /**
  * FontFinder for native Windows platforms
  */
-public class WindowsFontDirFinder implements FontFinder {
+public class WindowsFontDirFinder implements FontDirFinder {
 
     /**
      * Attempts to read windir environment variable on windows
@@ -51,8 +51,8 @@ public class WindowsFontDirFinder implem
      * {@inheritDoc}
      * @return a list of detected font files
      */
-    public List find() {
-        List fontDirList = new java.util.ArrayList();
+    public List<File> find() {
+        List<File> fontDirList = new java.util.ArrayList<File>();
         String windir = null;
         try {
             windir = System.getProperty("env.windir");

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=1040969&r1=1040968&r2=1040969&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 Wed Dec  1 11:58:58 2010
@@ -28,10 +28,8 @@ import java.util.Set;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
-import org.apache.xmlgraphics.fonts.Glyphs;
-
 import org.apache.fop.fonts.FontUtil;
+import org.apache.xmlgraphics.fonts.Glyphs;
 
 /**
  * Reads a TrueType file or a TrueType Collection.
@@ -132,17 +130,17 @@ public class TTFFile {
     /** Set to true to get even more debug output than with level DEBUG */
     public static final boolean TRACE_ENABLED = false;
 
-    private String encoding = "WinAnsiEncoding";    // Default encoding
+    private final String encoding = "WinAnsiEncoding";    // Default encoding
 
-    private short firstChar = 0;
+    private final short firstChar = 0;
     private boolean isEmbeddable = true;
     private boolean hasSerifs = true;
     /**
      * Table directory
      */
     protected Map dirTabs;
-    private Map kerningTab;                          // for CIDs
-    private Map ansiKerningTab;                      // For winAnsiEncoding
+    private Map<Integer, Map<Integer, Integer>> kerningTab;     // for CIDs
+    private Map<Integer, Map<Integer, Integer>> ansiKerningTab; // For winAnsiEncoding
     private List<TTFCmapEntry> cmaps;
     private List unicodeMapping;
 
@@ -161,12 +159,12 @@ public class TTFFile {
      * Contains glyph data
      */
     protected TTFMtxEntry[] mtxTab;                  // Contains glyph data
-    private int[] mtxEncoded = null;
+    private final int[] mtxEncoded = null;
 
     private String postScriptName = "";
     private String fullName = "";
     private String notice = "";
-    private Set familyNames = new java.util.HashSet(); //Set<String>
+    private final Set familyNames = new java.util.HashSet(); //Set<String>
     private String subFamilyName = "";
 
     private long italicAngle = 0;
@@ -199,8 +197,8 @@ public class TTFFile {
 
     // internal mapping of glyph indexes to unicode indexes
     // used for quick mappings in this class
-    private Map glyphToUnicodeMap = new java.util.HashMap();
-    private Map unicodeToGlyphMap = new java.util.HashMap();
+    private final Map glyphToUnicodeMap = new java.util.HashMap();
+    private final Map unicodeToGlyphMap = new java.util.HashMap();
 
     private TTFDirTabEntry currentDirTab;
 
@@ -216,8 +214,8 @@ public class TTFFile {
      */
     class UnicodeMapping {
 
-        private int unicodeIndex;
-        private int glyphIndex;
+        private final int unicodeIndex;
+        private final int glyphIndex;
 
         UnicodeMapping(int glyphIndex, int unicodeIndex) {
             this.unicodeIndex = unicodeIndex;
@@ -884,7 +882,7 @@ public class TTFFile {
      * Returns the kerning table.
      * @return Map The kerning table
      */
-    public Map getKerning() {
+    public Map<Integer, Map<Integer, Integer>> getKerning() {
         return kerningTab;
     }
 
@@ -892,7 +890,7 @@ public class TTFFile {
      * Returns the ANSI kerning table.
      * @return Map The ANSI kerning table
      */
-    public Map getAnsiKerning() {
+    public Map<Integer, Map<Integer, Integer>> getAnsiKerning() {
         return ansiKerningTab;
     }
 
@@ -1553,7 +1551,7 @@ public class TTFFile {
                             log.debug("Ignoring kerning pair because Unicode index was"
                                     + " found for the second glyph " + i);
                         } else {
-                            Map adjTab = (Map)kerningTab.get(iObj);
+                            Map adjTab = kerningTab.get(iObj);
                             if (adjTab == null) {
                                 adjTab = new java.util.HashMap();
                             }
@@ -1571,8 +1569,8 @@ public class TTFFile {
             while (ae.hasNext()) {
                 Integer unicodeKey1 = (Integer)ae.next();
                 Integer cidKey1 = unicodeToGlyph(unicodeKey1.intValue());
-                Map akpx = new java.util.HashMap();
-                Map ckpx = (Map)kerningTab.get(unicodeKey1);
+                Map<Integer, Integer> akpx = new java.util.HashMap();
+                Map ckpx = kerningTab.get(unicodeKey1);
 
                 Iterator aee = ckpx.keySet().iterator();
                 while (aee.hasNext()) {
@@ -1683,8 +1681,8 @@ public class TTFFile {
      * @return True if not collection or font name present, false otherwise
      * @throws IOException In case of an I/O problem
      */
-    public final List getTTCnames(FontFileReader in) throws IOException {
-        List fontNames = new java.util.ArrayList();
+    public final List<String> getTTCnames(FontFileReader in) throws IOException {
+        List<String> fontNames = new java.util.ArrayList<String>();
 
         String tag = in.readTTFString(4);
 

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=1040969&r1=1040968&r2=1040969&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 Wed Dec  1 11:58:58 2010
@@ -24,6 +24,7 @@ import java.io.InputStream;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 
 import org.apache.commons.io.IOUtils;
 
@@ -46,7 +47,7 @@ public class TTFFontLoader extends FontL
 
     private MultiByteFont multiFont;
     private SingleByteFont singleFont;
-    private String subFontName;
+    private final String subFontName;
     private EncodingMode encodingMode;
 
     /**
@@ -212,21 +213,20 @@ public class TTFFontLoader extends FontL
     private void copyKerning(TTFFile ttf, boolean isCid) {
 
         // Get kerning
-        Iterator iter;
+        Set<Integer> kerningSet;
         if (isCid) {
-            iter = ttf.getKerning().keySet().iterator();
+            kerningSet = ttf.getKerning().keySet();
         } else {
-            iter = ttf.getAnsiKerning().keySet().iterator();
+            kerningSet = ttf.getAnsiKerning().keySet();
         }
 
-        while (iter.hasNext()) {
-            Integer kpx1 = (Integer)iter.next();
+        for (Integer kpx1 : kerningSet) {
 
-            Map h2;
+            Map<Integer, Integer> h2;
             if (isCid) {
-                h2 = (Map)ttf.getKerning().get(kpx1);
+                h2 = ttf.getKerning().get(kpx1);
             } else {
-                h2 = (Map)ttf.getAnsiKerning().get(kpx1);
+                h2 = ttf.getAnsiKerning().get(kpx1);
             }
             returnFont.putKerningEntry(kpx1, h2);
         }

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=1040969&r1=1040968&r2=1040969&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 Wed Dec  1 11:58:58 2010
@@ -604,7 +604,7 @@ public class TTFSubSetFile extends TTFFi
      * @throws IOException in case of an I/O problem
      */
     public byte[] readFont(FontFileReader in, String name,
-                           Map glyphs) throws IOException {
+                           Map<Integer, Integer> glyphs) throws IOException {
 
         //Check if TrueType collection, and that the name exists in the collection
         if (!checkTTC(in, name)) {

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Wed Dec  1 11:58:58 2010
@@ -27,7 +27,6 @@ import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-
 import org.apache.fop.area.Area;
 import org.apache.fop.area.LineArea;
 import org.apache.fop.area.Trait;
@@ -94,7 +93,7 @@ public class LineLayoutManager extends I
      */
     private static Log log = LogFactory.getLog(LineLayoutManager.class);
 
-    private Block fobj;
+    private final Block fobj;
     private boolean isFirstInBlock;
 
     /**
@@ -103,19 +102,19 @@ public class LineLayoutManager extends I
      * inline break positions.
      */
     private static class LineBreakPosition extends LeafPosition {
-        private int parIndex; // index of the Paragraph this Position refers to
-        private int startIndex; //index of the first element this Position refers to
-        private int availableShrink;
-        private int availableStretch;
-        private int difference;
-        private double dAdjust; // Percentage to adjust (stretch or shrink)
-        private double ipdAdjust; // Percentage to adjust (stretch or shrink)
-        private int startIndent;
-        private int lineHeight;
-        private int lineWidth;
-        private int spaceBefore;
-        private int spaceAfter;
-        private int baseline;
+        private final int parIndex; // index of the Paragraph this Position refers to
+        private final int startIndex; //index of the first element this Position refers to
+        private final int availableShrink;
+        private final int availableStretch;
+        private final int difference;
+        private final double dAdjust; // Percentage to adjust (stretch or shrink)
+        private final double ipdAdjust; // Percentage to adjust (stretch or shrink)
+        private final int startIndent;
+        private final int lineHeight;
+        private final int lineWidth;
+        private final int spaceBefore;
+        private final int spaceAfter;
+        private final int baseline;
 
         LineBreakPosition(                                       // CSOK: ParameterNumber
                 LayoutManager lm, int index, int startIndex, int breakIndex,
@@ -151,9 +150,9 @@ public class LineLayoutManager extends I
     private int whiteSpaceTreament;
     //private LayoutProps layoutProps;
 
-    private Length lineHeight;
-    private int lead;
-    private int follow;
+    private final Length lineHeight;
+    private final int lead;
+    private final int follow;
     private AlignmentContext alignmentContext;
 
     private List knuthParagraphs;
@@ -194,12 +193,12 @@ public class LineLayoutManager extends I
 
         // space at the end of the last line (in millipoints)
         private MinOptMax lineFiller;
-        private int textAlignment;
-        private int textAlignmentLast;
-        private int textIndent;
-        private int lastLineEndIndent;
+        private final int textAlignment;
+        private final int textAlignmentLast;
+        private final int textIndent;
+        private final int lastLineEndIndent;
         // the LM which created the paragraph
-        private LineLayoutManager layoutManager;
+        private final LineLayoutManager layoutManager;
 
         Paragraph(LineLayoutManager llm, int alignment, int alignmentLast,
                          int indent, int endIndent) {
@@ -211,6 +210,7 @@ public class LineLayoutManager extends I
             lastLineEndIndent = endIndent;
         }
 
+        @Override
         public void startSequence() {
             // set the minimum amount of empty space at the end of the
             // last line
@@ -245,6 +245,7 @@ public class LineLayoutManager extends I
             }
         }
 
+        @Override
         public KnuthSequence endSequence() {
             if (this.size() > ignoreAtStart) {
                 if (textAlignment == EN_CENTER
@@ -294,14 +295,14 @@ public class LineLayoutManager extends I
     }
 
     private class LineBreakingAlgorithm extends BreakingAlgorithm {
-        private LineLayoutManager thisLLM;
-        private int pageAlignment;
+        private final LineLayoutManager thisLLM;
+        private final int pageAlignment;
         private int activePossibility;
         private int addedPositions;
-        private int textIndent;
-        private int lineHeight;
-        private int lead;
-        private int follow;
+        private final int textIndent;
+        private final int lineHeight;
+        private final int lead;
+        private final int follow;
         private static final double MAX_DEMERITS = 10e6;
 
         public LineBreakingAlgorithm(                            // CSOK: ParameterNumber
@@ -317,6 +318,7 @@ public class LineLayoutManager extends I
             activePossibility = -1;
         }
 
+        @Override
         public void updateData1(int lineCount, double demerits) {
             lineLayouts.addPossibility(lineCount, demerits);
             if (log.isTraceEnabled()) {
@@ -324,6 +326,7 @@ public class LineLayoutManager extends I
             }
         }
 
+        @Override
         public void updateData2(KnuthNode bestActiveNode,
                                 KnuthSequence par,
                                 int total) {
@@ -466,6 +469,7 @@ public class LineLayoutManager extends I
             }
         }
 
+        @Override
         protected int filterActiveNodes() {
             KnuthNode bestActiveNode = null;
 
@@ -537,6 +541,7 @@ public class LineLayoutManager extends I
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         textAlignment = fobj.getTextAlign();
         textAlignmentLast = fobj.getTextAlignLast();
@@ -560,6 +565,7 @@ public class LineLayoutManager extends I
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
         if (alignmentContext == null) {
             FontInfo fi = fobj.getFOEventHandler().getFontInfo();
@@ -771,7 +777,8 @@ public class LineLayoutManager extends I
                 // we only need an entry in lineLayoutsList.
                 llPoss = new LineLayoutPossibilities();
             } else {
-                llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq);
+                llPoss = findOptimalBreakingPoints(alignment, (Paragraph) seq,
+                                                   !paragraphsIterator.hasNext());
             }
             lineLayoutsList[i] = llPoss;
         }
@@ -783,16 +790,17 @@ public class LineLayoutManager extends I
     }
 
     /**
-     * Fint the optimal linebreaks for a paragraph
+     * Find the optimal linebreaks for a paragraph
      * @param alignment alignment of the paragraph
      * @param currPar the Paragraph for which the linebreaks are found
+     * @param isLastPar flag indicating whether currPar is the last paragraph
      * @return the line layout possibilities for the paragraph
      */
-    private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar) {
+    private LineLayoutPossibilities findOptimalBreakingPoints(int alignment, Paragraph currPar,
+                                                              boolean isLastPar) {
         // use the member lineLayouts, which is read by LineBreakingAlgorithm.updateData1 and 2
         lineLayouts = new LineLayoutPossibilities();
         double maxAdjustment = 1;
-        int iBPcount = 0;
         LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment,
                                         textAlignment, textAlignmentLast,
                                         textIndent.getValue(this), currPar.lineFiller.getOpt(),
@@ -801,26 +809,26 @@ public class LineLayoutManager extends I
                                         hyphenationLadderCount.getEnum() == EN_NO_LIMIT
                                         ? 0 : hyphenationLadderCount.getValue(),
                                         this);
+        alg.setConstantLineWidth(ipd);
+        boolean canWrap = (wrapOption != EN_NO_WRAP);
+        boolean canHyphenate = (canWrap && hyphenationProperties.hyphenate.getEnum() == EN_TRUE);
 
-        if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
-                && fobj.getWrapOption() != EN_NO_WRAP && !hyphenationPerformed) {
-            hyphenationPerformed = true;
+        // find hyphenation points, if allowed and not yet done
+        if (canHyphenate && !hyphenationPerformed) {
+            // make sure findHyphenationPoints() is bypassed if
+            // the method is called twice (e.g. due to changing page-ipd)
+            hyphenationPerformed = isLastPar;
             findHyphenationPoints(currPar);
         }
 
-        // first try
-        int allowedBreaks;
-        if (wrapOption == EN_NO_WRAP) {
-            allowedBreaks = BreakingAlgorithm.ONLY_FORCED_BREAKS;
-        } else {
-            allowedBreaks = BreakingAlgorithm.NO_FLAGGED_PENALTIES;
-        }
-        alg.setConstantLineWidth(ipd);
-        iBPcount = alg.findBreakingPoints(currPar,
-                                          maxAdjustment, false, allowedBreaks);
-        if (iBPcount == 0 || alignment == EN_JUSTIFY) {
+        // first try: do not consider hyphenation points as legal breaks
+        int allowedBreaks = (canWrap ? BreakingAlgorithm.NO_FLAGGED_PENALTIES
+                : BreakingAlgorithm.ONLY_FORCED_BREAKS);
+        int breakingPoints = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks);
+
+        if (breakingPoints == 0 || alignment == EN_JUSTIFY) {
             // if the first try found a set of breaking points, save them
-            if (iBPcount > 0) {
+            if (breakingPoints > 0) {
                 alg.resetAlgorithm();
                 lineLayouts.savePossibilities(false);
             } else {
@@ -829,10 +837,10 @@ public class LineLayoutManager extends I
             }
 
             // now try something different
-            log.debug("Hyphenation possible? "
-                      + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE));
-            if (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
-                && !(allowedBreaks == BreakingAlgorithm.ONLY_FORCED_BREAKS)) {
+            log.debug("Hyphenation possible? " + canHyphenate);
+            // Note: if allowedBreaks is guaranteed to be unchanged by alg.findBreakingPoints(),
+            // the below check can be simplified to 'if (canHyphenate) ...'
+            if (canHyphenate && allowedBreaks != BreakingAlgorithm.ONLY_FORCED_BREAKS) {
                 // consider every hyphenation point as a legal break
                 allowedBreaks = BreakingAlgorithm.ALL_BREAKS;
             } else {
@@ -840,68 +848,22 @@ public class LineLayoutManager extends I
                 maxAdjustment = 5;
             }
 
-            iBPcount = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks);
-            if (iBPcount == 0) {
+            breakingPoints = alg.findBreakingPoints(currPar, maxAdjustment, false, allowedBreaks);
+            if (breakingPoints == 0) {
                 // the second try failed too, try with a huge threshold
-                // and force the algorithm to find
-                // a set of breaking points
+                // and force the algorithm to find a set of breaking points
                 if (log.isDebugEnabled()) {
                     log.debug("No set of breaking points found with maxAdjustment = "
-                              + maxAdjustment
-                              + (hyphenationProperties.hyphenate.getEnum() == EN_TRUE
-                                      ? " and hyphenation" : ""));
+                            + maxAdjustment + (canHyphenate ? " and hyphenation" : ""));
                 }
                 maxAdjustment = 20;
-                iBPcount
-                    = alg.findBreakingPoints(currPar,
-                                             maxAdjustment, true, allowedBreaks);
+                alg.findBreakingPoints(currPar, maxAdjustment, true, allowedBreaks);
             }
 
             // use non-hyphenated breaks, when possible
             lineLayouts.restorePossibilities();
-
-            /* extension (not in the XSL FO recommendation): if vertical alignment
-               is justify and the paragraph has only one layout, try using
-               shorter or longer lines */
-            //TODO This code snippet is disabled. Reenable?
-            /* [GA] remove dead code
-            if (false && alignment == EN_JUSTIFY && textAlignment == EN_JUSTIFY) {
-                //log.debug("LLM.getNextKnuthElements> layouts with more lines? "
-                //+ lineLayouts.canUseMoreLines());
-                //log.debug("                          layouts with fewer lines? "
-                //+ lineLayouts.canUseLessLines());
-                if (!lineLayouts.canUseMoreLines()) {
-                    alg.resetAlgorithm();
-                    lineLayouts.savePossibilities(true);
-                    // try with shorter lines
-                    int savedLineWidth = ipd;
-                    ipd = (int) (ipd * 0.95);
-                    iBPcount = alg.findBreakingPoints(currPar,
-                            maxAdjustment, true, allowedBreaks);
-                    // use normal lines, when possible
-                    lineLayouts.restorePossibilities();
-                    ipd = savedLineWidth;
-                }
-                if (!lineLayouts.canUseLessLines()) {
-                    alg.resetAlgorithm();
-                    lineLayouts.savePossibilities(true);
-                    // try with longer lines
-                    int savedLineWidth = ipd;
-                    ipd = (int) (ipd * 1.05);
-                    alg.setConstantLineWidth(ipd);
-                    iBPcount = alg.findBreakingPoints(currPar,
-                            maxAdjustment, true, allowedBreaks);
-                    // use normal lines, when possible
-                    lineLayouts.restorePossibilities();
-                    ipd = savedLineWidth;
-                }
-                //log.debug("LLM.getNextKnuthElements> now, layouts with more lines? "
-                //+ lineLayouts.canUseMoreLines());
-                //log.debug("                          now, layouts with fewer lines? "
-                //+ lineLayouts.canUseLessLines());
-            }
-            */
         }
+
         return lineLayouts;
     }
 
@@ -1204,6 +1166,7 @@ public class LineLayoutManager extends I
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment) {
         List returnList = new LinkedList();
         for (int p = 0; p < knuthParagraphs.size(); p++) {
@@ -1278,8 +1241,6 @@ public class LineLayoutManager extends I
             } else if (currLM == null) {
                 break;
             }
-            //TODO Something's not right here. See block_hyphenation_linefeed_preserve.xml
-            //for more info: see also https://issues.apache.org/bugzilla/show_bug.cgi?id=38264
 
             // collect word fragments, ignoring auxiliary elements;
             // each word fragment was created by a different TextLM
@@ -1388,6 +1349,7 @@ public class LineLayoutManager extends I
      * @param isNotFirst ignored
      * @return always true
      */
+    @Override
     protected boolean hasLeadingFence(boolean isNotFirst) {
         return true;
     }
@@ -1397,6 +1359,7 @@ public class LineLayoutManager extends I
      * @param isNotLast ignored
      * @return always true
      */
+    @Override
     protected boolean hasTrailingFence(boolean isNotLast) {
         return true;
     }
@@ -1444,6 +1407,7 @@ public class LineLayoutManager extends I
      * @param parentIter the iterator of break positions
      * @param context the context for adding areas
      */
+    @Override
     public void addAreas(PositionIterator parentIter,
                          LayoutContext context) {
         while (parentIter.hasNext()) {
@@ -1472,8 +1436,6 @@ public class LineLayoutManager extends I
      */
     private void addInlineArea(LayoutContext context, LineBreakPosition lbp,
             boolean isLastPosition) {
-        // the TLM which created the last KnuthElement in this line
-        LayoutManager lastLM = null;
 
         KnuthSequence seq = (KnuthSequence) knuthParagraphs.get(lbp.parIndex);
         int startElementIndex = lbp.startIndex;
@@ -1505,15 +1467,16 @@ public class LineLayoutManager extends I
             }
         }
 
-        // Remove trailing spaces if allowed so
-        if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED
-                || whiteSpaceTreament == EN_IGNORE
-                || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) {
-            // ignore the last element in the line if it is a KnuthGlue object
-            ListIterator seqIterator = seq.listIterator(endElementIndex);
-            KnuthElement lastElement = (KnuthElement) seqIterator.next();
-            lastLM = lastElement.getLayoutManager();
-            if (lastElement.isGlue()) {
+        // ignore the last element in the line if it is a KnuthGlue object
+        ListIterator seqIterator = seq.listIterator(endElementIndex);
+        KnuthElement lastElement = (KnuthElement) seqIterator.next();
+        // the TLM which created the last KnuthElement in this line
+        LayoutManager lastLM = lastElement.getLayoutManager();
+        if (lastElement.isGlue()) {
+            // Remove trailing spaces if allowed so
+            if (whiteSpaceTreament == EN_IGNORE_IF_SURROUNDING_LINEFEED
+                    || whiteSpaceTreament == EN_IGNORE
+                    || whiteSpaceTreament == EN_IGNORE_IF_BEFORE_LINEFEED) {
                 endElementIndex--;
                 // this returns the same KnuthElement
                 seqIterator.previous();
@@ -1529,7 +1492,7 @@ public class LineLayoutManager extends I
                 || whiteSpaceTreament == EN_IGNORE_IF_AFTER_LINEFEED) {
             // ignore KnuthGlue and KnuthPenalty objects
             // at the beginning of the line
-            ListIterator seqIterator = seq.listIterator(startElementIndex);
+            seqIterator = seq.listIterator(startElementIndex);
             while (seqIterator.hasNext() && !((KnuthElement) seqIterator.next()).isBox()) {
                 startElementIndex++;
             }
@@ -1546,40 +1509,6 @@ public class LineLayoutManager extends I
         lc.setTrailingSpace(new SpaceSpecifier(false));
         lc.setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
 
-        /*
-         * extension (not in the XSL FO recommendation): if the left and right margins
-         * have been optimized, recompute indents and / or adjust ratio, according
-         * to the paragraph horizontal alignment
-         */
-        /* [GA] remove dead code
-        if (false && textAlignment == EN_JUSTIFY) {
-            // re-compute space adjust ratio
-            int updatedDifference = context.getRefIPD()
-            - lbp.lineWidth + lbp.difference;
-            double updatedRatio = 0.0;
-            if (updatedDifference > 0) {
-                updatedRatio = (float) updatedDifference / lbp.availableStretch;
-            } else if (updatedDifference < 0) {
-                updatedRatio = (float) updatedDifference / lbp.availableShrink;
-            }
-            lc.setIPDAdjust(updatedRatio);
-            //log.debug("LLM.addAreas> old difference = " + lbp.difference
-            //+ " new difference = " + updatedDifference);
-            //log.debug("              old ratio = " + lbp.ipdAdjust
-            //+ " new ratio = " + updatedRatio);
-        } else if (false && textAlignment == EN_CENTER) {
-            // re-compute indent
-            int updatedIndent = lbp.startIndent
-            + (context.getRefIPD() - lbp.lineWidth) / 2;
-            lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
-        } else if (false && textAlignment == EN_END) {
-            // re-compute indent
-            int updatedIndent = lbp.startIndent
-            + (context.getRefIPD() - lbp.lineWidth);
-            lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent));
-        }
-        */
-
         setCurrentArea(lineArea);
         setChildContext(lc);
         LayoutManager childLM;
@@ -1649,6 +1578,7 @@ public class LineLayoutManager extends I
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addChildArea(Area childArea) {
         // Make sure childArea is inline area
         if (childArea instanceof InlineArea) {
@@ -1664,19 +1594,21 @@ public class LineLayoutManager extends I
     // --------- Property Resolution related functions --------- //
 
     /** {@inheritDoc} */
+    @Override
     public boolean getGeneratesBlockArea() {
         return true;
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean getGeneratesLineArea() {
         return true;
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean isRestartable() {
         return true;
     }
 
 }
-

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java Wed Dec  1 11:58:58 2010
@@ -165,7 +165,8 @@ public class TextLayoutManager extends L
     private int hyphIPD;
 
     private boolean hasChanged = false;
-    private int returnedIndex = 0;
+    private int[] returnedIndices = {0, 0};
+    private int changeOffset = 0;
     private int thisStart = 0;
     private int tempStart = 0;
     private List changeList = new LinkedList();
@@ -811,19 +812,19 @@ public class TextLayoutManager extends L
                 //TODO: add kern to wordIPD?
             }
         }
-        int iLetterSpaces = wordLength - 1;
+        int letterSpaces = wordLength - 1;
         // if there is a break opportunity and the next one
         // is not a space, it could be used as a line end;
         // add one more letter space, in case other text follows
         if (breakOpportunity && !TextLayoutManager.isSpace(ch)) {
-            iLetterSpaces++;
+            letterSpaces++;
         }
-        assert iLetterSpaces >= 0;
-        wordIPD = wordIPD.plus(letterSpaceIPD.mult(iLetterSpaces));
+        assert letterSpaces >= 0;
+        wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
 
         // create the AreaInfo object
         AreaInfo areaInfo = new AreaInfo(thisStart, lastIndex, 0,
-                iLetterSpaces, wordIPD,
+                letterSpaces, wordIPD,
                 endsWithHyphen,
                 false, breakOpportunity, font);
         prevAreaInfo = areaInfo;
@@ -903,11 +904,9 @@ public class TextLayoutManager extends L
         }
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public void hyphenate(Position pos, HyphContext hyphContext) {
-        AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos());
+        AreaInfo areaInfo = getAreaInfo(((LeafPosition) pos).getLeafPos() + changeOffset);
         int startIndex = areaInfo.startIndex;
         int stopIndex;
         boolean nothingChanged = true;
@@ -962,7 +961,7 @@ public class TextLayoutManager extends L
                 // the new AreaInfo object is not equal to the old one
                 changeList.add(new PendingChange(new AreaInfo(startIndex, stopIndex, 0,
                         letterSpaceCount, newIPD, hyphenFollows, false, false, font),
-                        ((LeafPosition) pos).getLeafPos()));
+                        ((LeafPosition) pos).getLeafPos() + changeOffset));
                 nothingChanged = false;
             }
             startIndex = stopIndex;
@@ -972,11 +971,41 @@ public class TextLayoutManager extends L
 
     /** {@inheritDoc} */
     public boolean applyChanges(final List oldList) {
+
+        // make sure the LM appears unfinished in between this call
+        // and the next call to getChangedKnuthElements()
         setFinished(false);
 
+        if (oldList.isEmpty()) {
+            return false;
+        }
+
+        // Find the first and last positions in oldList that point to an AreaInfo
+        // (i.e. getLeafPos() != -1)
+        LeafPosition startPos = null, endPos = null;
+        ListIterator oldListIter;
+        for (oldListIter = oldList.listIterator(); oldListIter.hasNext();) {
+            startPos = (LeafPosition) ((KnuthElement) oldListIter.next()).getPosition();
+            if (startPos != null && startPos.getLeafPos() != -1) {
+                break;
+            }
+        }
+        for (oldListIter = oldList.listIterator(oldList.size()); oldListIter.hasPrevious();) {
+            endPos = (LeafPosition) ((KnuthElement) oldListIter.previous()).getPosition();
+            if (endPos != null && endPos.getLeafPos() != -1) {
+                break;
+            }
+        }
+
+        // set start/end index, taking into account any offset due to
+        // changes applied to previous paragraphs
+        returnedIndices[0] = (startPos != null ? startPos.getLeafPos() : -1) + changeOffset;
+        returnedIndices[1] = (endPos != null ? endPos.getLeafPos() : -1) + changeOffset;
+
+        int areaInfosAdded = 0;
+        int areaInfosRemoved = 0;
+
         if (!changeList.isEmpty()) {
-            int areaInfosAdded = 0;
-            int areaInfosRemoved = 0;
             int oldIndex = -1, changeIndex;
             PendingChange currChange;
             ListIterator changeListIterator = changeList.listIterator();
@@ -997,7 +1026,11 @@ public class TextLayoutManager extends L
             changeList.clear();
         }
 
-        returnedIndex = 0;
+        // increase the end index for getChangedKnuthElements()
+        returnedIndices[1] += (areaInfosAdded - areaInfosRemoved);
+        // increase offset to use for subsequent paragraphs
+        changeOffset += (areaInfosAdded - areaInfosRemoved);
+
         return hasChanged;
     }
 
@@ -1009,27 +1042,24 @@ public class TextLayoutManager extends L
 
         final LinkedList returnList = new LinkedList();
 
-        while (returnedIndex < areaInfos.size()) {
-            AreaInfo areaInfo = getAreaInfo(returnedIndex);
+        for (; returnedIndices[0] <= returnedIndices[1]; returnedIndices[0]++) {
+            AreaInfo areaInfo = getAreaInfo(returnedIndices[0]);
             if (areaInfo.wordSpaceCount == 0) {
                 // areaInfo refers either to a word or a word fragment
-                addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndex);
+                addElementsForAWordFragment(returnList, alignment, areaInfo, returnedIndices[0]);
             } else {
                 // areaInfo refers to a space
-                addElementsForASpace(returnList, alignment, areaInfo, returnedIndex);
+                addElementsForASpace(returnList, alignment, areaInfo, returnedIndices[0]);
             }
-            returnedIndex++;
         }
-        setFinished(true);
+        setFinished(returnedIndices[0] == areaInfos.size() - 1);
         //ElementListObserver.observe(returnList, "text-changed", null);
         return returnList;
     }
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
     public String getWordChars(Position pos) {
-        int leafValue = ((LeafPosition) pos).getLeafPos();
+        int leafValue = ((LeafPosition) pos).getLeafPos() + changeOffset;
         if (leafValue != -1) {
             AreaInfo areaInfo = getAreaInfo(leafValue);
             StringBuffer buffer = new StringBuffer(areaInfo.getCharLength());

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFResources.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFResources.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFResources.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/pdf/PDFResources.java Wed Dec  1 11:58:58 2010
@@ -98,11 +98,9 @@ public class PDFResources extends PDFObj
      * @param fontInfo font info object to get font information from
      */
    public void addFonts(PDFDocument doc, FontInfo fontInfo) {
-        Map usedFonts = fontInfo.getUsedFonts();
-        Iterator e = usedFonts.keySet().iterator();
-        while (e.hasNext()) {
-            String f = (String)e.next();
-            Typeface font = (Typeface)usedFonts.get(f);
+        Map<String, Typeface> usedFonts = fontInfo.getUsedFonts();
+        for (String f : usedFonts.keySet()) {
+            Typeface font = usedFonts.get(f);
 
             //Check if the font actually had any mapping operations. If not, it is an indication
             //that it has never actually been used and therefore doesn't have to be embedded.
@@ -196,6 +194,7 @@ public class PDFResources extends PDFObj
      * @return the PDF
      * {@inheritDoc}
      */
+    @Override
     public String toPDFString() {
         StringBuffer p = new StringBuffer(128);
         p.append(getObjectID() + "<<\n");

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRenderer.java Wed Dec  1 11:58:58 2010
@@ -30,6 +30,7 @@ import org.apache.fop.apps.FOPException;
 import org.apache.fop.area.Area;
 import org.apache.fop.area.Trait;
 import org.apache.fop.fonts.CustomFontCollection;
+import org.apache.fop.fonts.EmbedFontInfo;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontCollection;
 import org.apache.fop.fonts.FontInfo;
@@ -48,13 +49,13 @@ public abstract class PrintRenderer exte
     protected FontResolver fontResolver = null;
 
     /** list of fonts */
-    protected List/*<EmbedFontInfo>*/ embedFontInfoList = null;
+    protected List<EmbedFontInfo> embedFontInfoList = null;
 
     /**
      * Adds a font list to current list of fonts
      * @param fontList a font info list
      */
-    public void addFontList(List/*<EmbedFontInfo>*/ fontList) {
+    public void addFontList(List<EmbedFontInfo> fontList) {
         if (embedFontInfoList == null) {
             setFontList(fontList);
         } else {
@@ -65,14 +66,14 @@ public abstract class PrintRenderer exte
     /**
      * @param embedFontInfoList list of available fonts
      */
-    public void setFontList(List/*<EmbedFontInfo>*/ embedFontInfoList) {
+    public void setFontList(List<EmbedFontInfo> embedFontInfoList) {
         this.embedFontInfoList = embedFontInfoList;
     }
 
     /**
      * @return list of available embedded fonts
      */
-    public List/*<EmbedFontInfo>*/ getFontList() {
+    public List<EmbedFontInfo> getFontList() {
         return this.embedFontInfoList;
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/PrintRendererConfigurator.java Wed Dec  1 11:58:58 2010
@@ -19,6 +19,7 @@
 
 package org.apache.fop.render;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -76,7 +77,7 @@ public class PrintRendererConfigurator e
 
         FontEventListener listener = new FontEventAdapter(
                 renderer.getUserAgent().getEventBroadcaster());
-        List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontList(cfg, fontResolver, listener);
+        List<EmbedFontInfo> embedFontInfoList = buildFontList(cfg, fontResolver, listener);
         printRenderer.addFontList(embedFontInfoList);
     }
 
@@ -88,7 +89,7 @@ public class PrintRendererConfigurator e
      * @return the list of {@link EmbedFontInfo} objects
      * @throws FOPException if an error occurs while processing the configuration
      */
-    protected List/*<EmbedFontInfo>*/ buildFontList(Configuration cfg, FontResolver fontResolver,
+    protected List<EmbedFontInfo> buildFontList(Configuration cfg, FontResolver fontResolver,
                     FontEventListener listener) throws FOPException {
         FopFactory factory = userAgent.getFactory();
         FontManager fontManager = factory.getFontManager();
@@ -102,7 +103,7 @@ public class PrintRendererConfigurator e
         //Read font configuration
         FontInfoConfigurator fontInfoConfigurator
             = new FontInfoConfigurator(cfg, fontManager, fontResolver, listener, strict);
-        List/*<EmbedFontInfo>*/ fontInfoList = new java.util.ArrayList/*<EmbedFontInfo>*/();
+        List<EmbedFontInfo> fontInfoList = new ArrayList<EmbedFontInfo>();
         fontInfoConfigurator.configure(fontInfoList);
         return fontInfoList;
     }
@@ -118,7 +119,7 @@ public class PrintRendererConfigurator e
     public void setupFontInfo(IFDocumentHandler documentHandler, FontInfo fontInfo)
                 throws FOPException {
         FontManager fontManager = userAgent.getFactory().getFontManager();
-        List fontCollections = new java.util.ArrayList();
+        List<FontCollection> fontCollections = new ArrayList<FontCollection>();
         fontCollections.add(new Base14FontCollection(fontManager.isBase14KerningEnabled()));
 
         Configuration cfg = super.getRendererConfig(documentHandler.getMimeType());
@@ -126,7 +127,7 @@ public class PrintRendererConfigurator e
             FontResolver fontResolver = new DefaultFontResolver(userAgent);
             FontEventListener listener = new FontEventAdapter(
                     userAgent.getEventBroadcaster());
-            List fontList = buildFontList(cfg, fontResolver, listener);
+            List<EmbedFontInfo> fontList = buildFontList(cfg, fontResolver, listener);
             fontCollections.add(new CustomFontCollection(fontResolver, fontList));
         }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/afp/AFPPainter.java Wed Dec  1 11:58:58 2010
@@ -30,11 +30,6 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.Map;
 
-import org.w3c.dom.Document;
-
-import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
-import org.apache.xmlgraphics.image.loader.ImageSessionContext;
-
 import org.apache.fop.afp.AFPBorderPainter;
 import org.apache.fop.afp.AFPPaintingState;
 import org.apache.fop.afp.AFPUnitConverter;
@@ -55,6 +50,7 @@ import org.apache.fop.afp.util.ResourceA
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
+import org.apache.fop.fonts.Typeface;
 import org.apache.fop.render.RenderingContext;
 import org.apache.fop.render.intermediate.AbstractIFPainter;
 import org.apache.fop.render.intermediate.BorderPainter;
@@ -64,6 +60,9 @@ import org.apache.fop.render.intermediat
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.RuleStyle;
 import org.apache.fop.util.CharUtilities;
+import org.apache.xmlgraphics.image.loader.ImageProcessingHints;
+import org.apache.xmlgraphics.image.loader.ImageSessionContext;
+import org.w3c.dom.Document;
 
 /**
  * IFPainter implementation that produces AFP (MO:DCA).
@@ -76,12 +75,12 @@ public class AFPPainter extends Abstract
     private static final int X = 0;
     private static final int Y = 1;
 
-    private AFPDocumentHandler documentHandler;
+    private final AFPDocumentHandler documentHandler;
 
     /** the border painter */
-    private AFPBorderPainterAdapter borderPainter;
+    private final AFPBorderPainterAdapter borderPainter;
     /** the rectangle painter */
-    private AbstractAFPPainter rectanglePainter;
+    private final AbstractAFPPainter rectanglePainter;
 
     /** unit converter */
     private final AFPUnitConverter unitConv;
@@ -101,6 +100,7 @@ public class AFPPainter extends Abstract
     }
 
     /** {@inheritDoc} */
+    @Override
     protected IFContext getContext() {
         return this.documentHandler.getContext();
     }
@@ -165,6 +165,7 @@ public class AFPPainter extends Abstract
     }
 
     /** {@inheritDoc} */
+    @Override
     protected Map createDefaultImageProcessingHints(ImageSessionContext sessionContext) {
         Map hints = super.createDefaultImageProcessingHints(sessionContext);
 
@@ -175,6 +176,7 @@ public class AFPPainter extends Abstract
     }
 
     /** {@inheritDoc} */
+    @Override
     protected RenderingContext createRenderingContext() {
         AFPRenderingContext psContext = new AFPRenderingContext(
                 getUserAgent(),
@@ -256,6 +258,7 @@ public class AFPPainter extends Abstract
     }
 
     /** {@inheritDoc} */
+    @Override
     public void drawBorderRect(Rectangle rect, BorderProps before, BorderProps after,
             BorderProps start, BorderProps end) throws IFException {
         if (before != null || after != null || start != null || end != null) {
@@ -271,32 +274,38 @@ public class AFPPainter extends Abstract
     //and this one. Not done for now to avoid a lot of re-implementation and code duplication.
     private static class AFPBorderPainterAdapter extends BorderPainter {
 
-        private AFPBorderPainter delegate;
+        private final AFPBorderPainter delegate;
 
         public AFPBorderPainterAdapter(AFPBorderPainter borderPainter) {
             this.delegate = borderPainter;
         }
 
+        @Override
         protected void clip() throws IOException {
             //not supported by AFP
         }
 
+        @Override
         protected void closePath() throws IOException {
             //used for clipping only, so not implemented
         }
 
+        @Override
         protected void moveTo(int x, int y) throws IOException {
             //used for clipping only, so not implemented
         }
 
+        @Override
         protected void lineTo(int x, int y) throws IOException {
             //used for clipping only, so not implemented
         }
 
+        @Override
         protected void saveGraphicsState() throws IOException {
             //used for clipping only, so not implemented
         }
 
+        @Override
         protected void restoreGraphicsState() throws IOException {
             //used for clipping only, so not implemented
         }
@@ -305,6 +314,7 @@ public class AFPPainter extends Abstract
             return mpt / 1000f;
         }
 
+        @Override
         protected void drawBorderLine(                           // CSOK: ParameterNumber
                 int x1, int y1, int x2, int y2, boolean horz,
                 boolean startOrBefore, int style, Color color) throws IOException {
@@ -314,6 +324,7 @@ public class AFPPainter extends Abstract
             delegate.paint(borderPaintInfo);
         }
 
+        @Override
         public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
                 throws IOException {
             if (start.y != end.y) {
@@ -331,6 +342,7 @@ public class AFPPainter extends Abstract
     }
 
     /** {@inheritDoc} */
+    @Override
     public void drawLine(Point start, Point end, int width, Color color, RuleStyle style)
                 throws IFException {
         try {
@@ -357,7 +369,7 @@ public class AFPPainter extends Abstract
         }
 
         // register font as necessary
-        Map/*<String,FontMetrics>*/ fontMetricMap = documentHandler.getFontInfo().getFonts();
+        Map<String, Typeface> fontMetricMap = documentHandler.getFontInfo().getFonts();
         final AFPFont afpFont = (AFPFont)fontMetricMap.get(fontKey);
         final Font font = getFontInfo().getFontInstance(triplet, fontSize);
         AFPPageFonts pageFonts = getPaintingState().getPageFonts();

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/ConfiguredFontCollection.java Wed Dec  1 11:58:58 2010
@@ -95,7 +95,7 @@ public class ConfiguredFontCollection im
 
                 fontInfo.addMetrics(internalName, font);
 
-                List triplets = configFontInfo.getFontTriplets();
+                List<FontTriplet> triplets = configFontInfo.getFontTriplets();
                 for (int c = 0; c < triplets.size(); c++) {
                     FontTriplet triplet = (FontTriplet) triplets.get(c);
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/java2d/CustomFontMetricsMapper.java Wed Dec  1 11:58:58 2010
@@ -161,7 +161,7 @@ public class CustomFontMetricsMapper ext
     }
 
     /** {@inheritDoc} */
-    public final Set getFamilyNames() {
+    public final Set<String> getFamilyNames() {
         return typeface.getFamilyNames();
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/FontResourceCache.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/FontResourceCache.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/FontResourceCache.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/FontResourceCache.java Wed Dec  1 11:58:58 2010
@@ -21,18 +21,17 @@ package org.apache.fop.render.ps;
 
 import java.util.Map;
 
-import org.apache.xmlgraphics.ps.PSResource;
-
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.LazyFont;
 import org.apache.fop.fonts.Typeface;
+import org.apache.xmlgraphics.ps.PSResource;
 
 /**
  * A cache for font resource objects.
  */
 class FontResourceCache {
 
-    private FontInfo fontInfo;
+    private final FontInfo fontInfo;
 
     /** This is a map of PSResource instances of all fonts defined (key: font key) */
     private Map fontResources = new java.util.HashMap();
@@ -68,8 +67,8 @@ class FontResourceCache {
             postFix = key.substring(pos);
             key = key.substring(0, pos);
         }
-        Map fonts = fontInfo.getFonts();
-        Typeface tf = (Typeface)fonts.get(key);
+        Map<String, Typeface> fonts = fontInfo.getFonts();
+        Typeface tf = fonts.get(key);
         if (tf instanceof LazyFont) {
             tf = ((LazyFont)tf).getRealFont();
         }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSFontUtils.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSFontUtils.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSFontUtils.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/render/ps/PSFontUtils.java Wed Dec  1 11:58:58 2010
@@ -23,7 +23,6 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
-import java.util.Iterator;
 import java.util.Map;
 
 import javax.xml.transform.Source;
@@ -105,7 +104,7 @@ public class PSFontUtils extends org.apa
      * @return a Map of PSResource instances representing all defined fonts (key: font key)
      * @throws IOException in case of an I/O problem
      */
-    public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts,
+    public static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map<String, Typeface> fonts,
             PSEventProducer eventProducer) throws IOException {
         return writeFontDict(gen, fontInfo, fonts, false, eventProducer);
     }
@@ -120,14 +119,12 @@ public class PSFontUtils extends org.apa
      * @return a Map of PSResource instances representing all defined fonts (key: font key)
      * @throws IOException in case of an I/O problem
      */
-    private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map fonts,
+    private static Map writeFontDict(PSGenerator gen, FontInfo fontInfo, Map<String, Typeface> fonts,
             boolean encodeAllCharacters, PSEventProducer eventProducer) throws IOException {
         gen.commentln("%FOPBeginFontDict");
 
         Map fontResources = new java.util.HashMap();
-        Iterator iter = fonts.keySet().iterator();
-        while (iter.hasNext()) {
-            String key = (String)iter.next();
+        for (String key : fonts.keySet()) {
             Typeface tf = getTypeFace(fontInfo, fonts, key);
             PSResource fontRes = new PSResource(PSResource.TYPE_FONT, tf.getEmbedFontName());
             PSFontResource fontResource = embedFont(gen, tf, fontRes, eventProducer);
@@ -164,7 +161,8 @@ public class PSFontUtils extends org.apa
         return fontResources;
     }
 
-    private static void reencodeFonts(PSGenerator gen, Map fonts) throws IOException {
+    private static void reencodeFonts(PSGenerator gen, Map<String, Typeface> fonts)
+            throws IOException {
         ResourceTracker tracker = gen.getResourceTracker();
 
         if (!tracker.isResourceSupplied(WINANSI_ENCODING_RESOURCE)) {
@@ -174,10 +172,8 @@ public class PSFontUtils extends org.apa
         gen.commentln("%FOPBeginFontReencode");
 
         //Rewrite font encodings
-        Iterator iter = fonts.keySet().iterator();
-        while (iter.hasNext()) {
-            String key = (String)iter.next();
-            Typeface tf = (Typeface)fonts.get(key);
+        for (String key : fonts.keySet()) {
+            Typeface tf = fonts.get(key);
             if (tf instanceof LazyFont) {
                 tf = ((LazyFont)tf).getRealFont();
                 if (tf == null) {
@@ -206,8 +202,9 @@ public class PSFontUtils extends org.apa
         gen.commentln("%FOPEndFontReencode");
     }
 
-    private static Typeface getTypeFace(FontInfo fontInfo, Map fonts, String key) {
-        Typeface tf = (Typeface)fonts.get(key);
+    private static Typeface getTypeFace(FontInfo fontInfo, Map<String, Typeface> fonts,
+            String key) {
+        Typeface tf = fonts.get(key);
         if (tf instanceof LazyFont) {
             tf = ((LazyFont)tf).getRealFont();
         }
@@ -215,7 +212,7 @@ public class PSFontUtils extends org.apa
             //This is to avoid an NPE if a malconfigured font is in the configuration but not
             //used in the document. If it were used, we wouldn't get this far.
             String fallbackKey = fontInfo.getInternalFontKey(Font.DEFAULT_FONT);
-            tf = (Typeface)fonts.get(fallbackKey);
+            tf = fonts.get(fallbackKey);
         }
         return tf;
     }
@@ -562,11 +559,9 @@ public class PSFontUtils extends org.apa
      * @return a Map of PSResource instances representing all defined fonts (key: font key)
      */
     public static Map determineSuppliedFonts(ResourceTracker resTracker,
-            FontInfo fontInfo, Map fonts) {
+            FontInfo fontInfo, Map<String, Typeface> fonts) {
         Map fontResources = new java.util.HashMap();
-        Iterator iter = fonts.keySet().iterator();
-        while (iter.hasNext()) {
-            String key = (String)iter.next();
+        for (String key : fonts.keySet()) {
             Typeface tf = getTypeFace(fontInfo, fonts, key);
             PSResource fontRes = new PSResource("font", tf.getEmbedFontName());
             fontResources.put(key, fontRes);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/fontlist/FontSpec.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/fontlist/FontSpec.java?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/fontlist/FontSpec.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/tools/fontlist/FontSpec.java Wed Dec  1 11:58:58 2010
@@ -22,6 +22,7 @@ package org.apache.fop.tools.fontlist;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.SortedSet;
+import java.util.TreeSet;
 
 import org.apache.fop.fonts.FontMetrics;
 import org.apache.fop.fonts.FontTriplet;
@@ -33,8 +34,8 @@ public class FontSpec implements Compara
 
     private String key;
     private FontMetrics metrics;
-    private SortedSet familyNames = new java.util.TreeSet();
-    private Collection triplets = new java.util.TreeSet();
+    private SortedSet<String> familyNames = new TreeSet<String>();
+    private Collection triplets = new TreeSet();
 
     /**
      * Creates a new font spec.
@@ -50,7 +51,7 @@ public class FontSpec implements Compara
      * Adds font family names.
      * @param names the names
      */
-    public void addFamilyNames(Collection names) {
+    public void addFamilyNames(Collection<String> names) {
         this.familyNames.addAll(names);
     }
 

Propchange: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/util/ColorExt.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec  1 11:58:58 2010
@@ -2,4 +2,4 @@
 /xmlgraphics/fop/branches/Temp_Accessibility/src/java/org/apache/fop/util/ColorExt.java:745924-830281
 /xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/util/ColorExt.java:603620-746655
 /xmlgraphics/fop/branches/fop-0_95/src/java/org/apache/fop/util/ColorExt.java:684572,688085,688696
-/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:959946-1039182
+/xmlgraphics/fop/trunk/src/java/org/apache/fop/util/ColorExt.java:959946-1040962

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/status.xml Wed Dec  1 11:58:58 2010
@@ -58,6 +58,9 @@
       documents. Example: the fix of marks layering will be such a case when it's done.
     -->
     <release version="FOP Trunk" date="TBD">
+      <action context="Layout" dev="AD" type="fix" fixes-bug="38264">
+        Fixed behavior when combining hyphenation with preserved linefeeds or whitespace.
+      </action>
       <action context="Code" dev="VH" type="fix" fixes-bug="49695" due-to="Joshua Marquart">
         Replaced magic numbers with constants from UnitConv and GraphicsConstants.
       </action>

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/disabled-testcases.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/disabled-testcases.xml?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/disabled-testcases.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/disabled-testcases.xml Wed Dec  1 11:58:58 2010
@@ -39,12 +39,6 @@
     <description>Font-stretch is not implemented, yet.</description>
   </testcase>
   <testcase>
-    <name>Hyphenation with preserved linefeeds</name>
-    <file>block_hyphenation_linefeed_preserve.xml</file>
-    <description>When hyphenation is enabled and linefeeds are preserved,
-    the text is output multiple times.</description>
-  </testcase>
-  <testcase>
     <name>linefeed-treatment</name>
     <file>block_linefeed-treatment.xml</file>
     <description>Preserved linefeeds in a fo:character are not handled

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml?rev=1040969&r1=1040968&r2=1040969&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml Wed Dec  1 11:58:58 2010
@@ -19,7 +19,11 @@
 <testcase>
   <info>
     <p>
-      Check for bug: Duplicate content and linefeeds as "#".
+      Check for bug 38264: 
+      <ul>
+        <li>duplication of content with linefeed-treatment="preserve" and hyphenate="true"</li>
+        <li>missing hyphens with white-space-treatment="preserve" and hyphenate="true"</li>
+      </ul>
     </p>
   </info>
   <fo>
@@ -31,21 +35,39 @@
       </fo:layout-master-set>
       <fo:page-sequence master-reference="simple">
         <fo:flow flow-name="xsl-region-body">
-          <fo:block line-height="10pt" background-color="orange"
-            white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas semper. Proin at.</fo:block>
-          <fo:block line-height="10pt" background-color="orange"
-            white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">
+          <fo:block white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">
 line1
 line2
 
-Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas semper. Proin at1.
-</fo:block>
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas semper. Proin at.
+          </fo:block>
         </fo:flow>
       </fo:page-sequence>
     </fo:root>
   </fo>
   <checks>
-    <!-- Dummy check. We don't want an NPE. -->
-    <eval expected="2" xpath="count(//*[contains(text(), 'adipiscing')])"/>
+    <!-- check number of lines and word fragments -->
+    <eval expected="13" xpath="count(//flow[1]/block/lineArea)" />
+    <eval expected="17" xpath="count(//flow[1]/block/lineArea/text/word)" />
+    <!-- check individual word fragments -->
+    <eval expected="line1" xpath="(//flow[1]/block/lineArea/text/word)[1]" />
+    <eval expected="line2" xpath="(//flow[1]/block/lineArea/text/word)[2]" />
+    <eval expected="Lorem" xpath="(//flow[1]/block/lineArea/text/word)[3]" />
+    <eval expected="ip-" xpath="(//flow[1]/block/lineArea/text/word)[4]" />
+    <eval expected="sum" xpath="(//flow[1]/block/lineArea/text/word)[5]" />
+    <eval expected="dolor" xpath="(//flow[1]/block/lineArea/text/word)[6]" />
+    <eval expected="sit" xpath="(//flow[1]/block/lineArea/text/word)[7]" />
+    <eval expected="amet," xpath="(//flow[1]/block/lineArea/text/word)[8]" />
+    <eval expected="con-" xpath="(//flow[1]/block/lineArea/text/word)[9]" />
+    <eval expected="sectetuer" xpath="(//flow[1]/block/lineArea/text/word)[10]" />
+    <eval expected="adipiscing" xpath="(//flow[1]/block/lineArea/text/word)[11]" />
+    <eval expected="elit." xpath="(//flow[1]/block/lineArea/text/word)[12]" />
+    <eval expected="Maece-" xpath="(//flow[1]/block/lineArea/text/word)[13]" />
+    <eval expected="nas" xpath="(//flow[1]/block/lineArea/text/word)[14]" />
+    <eval expected="semper." xpath="(//flow[1]/block/lineArea/text/word)[15]" />
+    <eval expected="Proin" xpath="(//flow[1]/block/lineArea/text/word)[16]" />
+    <eval expected="at." xpath="(//flow[1]/block/lineArea/text/word)[17]" />
+    <!-- check preservation of spaces on the last line -->
+    <eval expected="10" xpath="count((//flow[1]/block/lineArea)[13]/text/space)" />
   </checks>
 </testcase>



---------------------------------------------------------------------
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