]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
FOP-2391: ensure mapping is non-null in CS SVG text
authorGlenn Adams <gadams@apache.org>
Mon, 18 Aug 2014 18:43:50 +0000 (18:43 +0000)
committerGlenn Adams <gadams@apache.org>
Mon, 18 Aug 2014 18:43:50 +0000 (18:43 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1618701 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fonts/GlyphMapping.java
src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
src/java/org/apache/fop/svg/font/FOPGVTGlyphVector.java

index 69943242de9cbf1b3e0e21b8fbd0dc6750bfc37a..f0fadaad476952ebc999c7dc270cf04220386700 100644 (file)
@@ -83,22 +83,22 @@ public class GlyphMapping {
     public static GlyphMapping doGlyphMapping(TextFragment text, int startIndex, int endIndex,
             Font font, MinOptMax letterSpaceIPD, MinOptMax[] letterSpaceAdjustArray,
             char precedingChar, char breakOpportunityChar, final boolean endsWithHyphen, int level,
-            boolean retainAssociations) {
+            boolean dontOptimizeForIdentityMapping, boolean retainAssociations) {
         GlyphMapping mapping;
         if (font.performsSubstitution() || font.performsPositioning()) {
             mapping = processWordMapping(text, startIndex, endIndex, font,
-                    breakOpportunityChar, endsWithHyphen, level, retainAssociations);
+                breakOpportunityChar, endsWithHyphen, level, dontOptimizeForIdentityMapping, retainAssociations);
         } else {
             mapping = processWordNoMapping(text, startIndex, endIndex, font,
-                    letterSpaceIPD, letterSpaceAdjustArray, precedingChar, breakOpportunityChar, endsWithHyphen,
-                    level);
+                letterSpaceIPD, letterSpaceAdjustArray, precedingChar, breakOpportunityChar, endsWithHyphen, level);
         }
         return mapping;
     }
 
     private static GlyphMapping processWordMapping(TextFragment text, int startIndex,
             int endIndex, final Font font, final char breakOpportunityChar,
-            final boolean endsWithHyphen, int level, boolean retainAssociations) {
+            final boolean endsWithHyphen, int level,
+            boolean dontOptimizeForIdentityMapping, boolean retainAssociations) {
         int e = endIndex; // end index of word in FOText character buffer
         int nLS = 0; // # of letter spaces
         String script = text.getScript();
@@ -163,7 +163,8 @@ public class GlyphMapping {
 
         return new GlyphMapping(startIndex, e, 0, nLS, ipd, endsWithHyphen, false,
                 breakOpportunityChar != 0, font, level, gpa,
-                CharUtilities.isSameSequence(mcs, ics) ? null : mcs.toString(), associations);
+                !dontOptimizeForIdentityMapping && CharUtilities.isSameSequence(mcs, ics) ? null : mcs.toString(),
+                associations);
     }
 
     /**
@@ -320,6 +321,9 @@ public class GlyphMapping {
     }
 
     public void reverse() {
+        if (mapping == null) {
+            return;
+        }
         if (mapping.length() > 0) {
             mapping = new StringBuffer(mapping).reverse().toString();
         }
index 24c1fcbbbe13e505f4cc877d3323430e0d9d1526..c7258ee6b94db42fcdb2e77d4ddf239c758f1b9f 100644 (file)
@@ -934,7 +934,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
                 && prevMapping.endIndex > 0 ? foText.charAt(prevMapping.endIndex - 1) : 0;
         GlyphMapping mapping = GlyphMapping.doGlyphMapping(foText, thisStart, lastIndex, font,
                 letterSpaceIPD, letterSpaceAdjustArray, precedingChar, breakOpportunityChar,
-                endsWithHyphen, level, false);
+                endsWithHyphen, level, false, false);
         prevMapping = mapping;
         addGlyphMapping(mapping);
         tempStart = nextStart;
index 0abffc52c433519445e972bd071fcb3ea0bb7beb..40a1e8ad3d1bdbbf903c86c4835f649b8aebb638 100644 (file)
@@ -90,7 +90,7 @@ class FOPGVTGlyphVector implements GVTGlyphVector {
         MinOptMax letterSpaceIPD = MinOptMax.ZERO;
         MinOptMax[] letterSpaceAdjustments = new MinOptMax[charIter.getEndIndex() - charIter.getBeginIndex()];
         GlyphMapping mapping = GlyphMapping.doGlyphMapping(text, charIter.getBeginIndex(), charIter.getEndIndex(),
-            f, letterSpaceIPD, letterSpaceAdjustments, '\0', '\0', false, 0, true);
+            f, letterSpaceIPD, letterSpaceAdjustments, '\0', '\0', false, 0, true, true);
         maybeReverse(mapping);
         CharacterIterator glyphAsCharIter =
             mapping.mapping != null ? new StringCharacterIterator(mapping.mapping) : charIter;