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();
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);
}
/**
}
public void reverse() {
+ if (mapping == null) {
+ return;
+ }
if (mapping.length() > 0) {
mapping = new StringBuffer(mapping).reverse().toString();
}
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;