diff options
author | Glenn Adams <gadams@apache.org> | 2014-08-18 18:43:50 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2014-08-18 18:43:50 +0000 |
commit | 484c5fdefb02cd6ac4d36429343888d46ca04772 (patch) | |
tree | c892b4976a5feddbe3f898fe886cc57427ca2f4a /src/java/org/apache | |
parent | 1b2b91898d8d4d71c9e566b4e4b7aafc4ea66342 (diff) | |
download | xmlgraphics-fop-484c5fdefb02cd6ac4d36429343888d46ca04772.tar.gz xmlgraphics-fop-484c5fdefb02cd6ac4d36429343888d46ca04772.zip |
FOP-2391: ensure mapping is non-null in CS SVG text
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1618701 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
3 files changed, 12 insertions, 8 deletions
diff --git a/src/java/org/apache/fop/fonts/GlyphMapping.java b/src/java/org/apache/fop/fonts/GlyphMapping.java index 69943242d..f0fadaad4 100644 --- a/src/java/org/apache/fop/fonts/GlyphMapping.java +++ b/src/java/org/apache/fop/fonts/GlyphMapping.java @@ -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(); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 24c1fcbbb..c7258ee6b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -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; diff --git a/src/java/org/apache/fop/svg/font/FOPGVTGlyphVector.java b/src/java/org/apache/fop/svg/font/FOPGVTGlyphVector.java index 0abffc52c..40a1e8ad3 100644 --- a/src/java/org/apache/fop/svg/font/FOPGVTGlyphVector.java +++ b/src/java/org/apache/fop/svg/font/FOPGVTGlyphVector.java @@ -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; |