}
private AreaInfo processWordNoMapping(int lastIndex, final Font font, AreaInfo prevAreaInfo,
final char breakOpportunityChar, final boolean endsWithHyphen, int level) {
boolean kerning = font.hasKerning();
MinOptMax wordIPD = MinOptMax.ZERO;
if (LOG.isDebugEnabled()) {
LOG.debug ( "PW: [" + thisStart + "," + lastIndex + "]: {"
+ " -M"
+ ", level = " + level
+ " }" );
}
for (int i = thisStart; i < lastIndex; i++) {
char currentChar = foText.charAt(i);
//character width
int charWidth = font.getCharWidth(currentChar);
wordIPD = wordIPD.plus(charWidth);
//kerning
if (kerning) {
int kern = 0;
if (i > thisStart) {
char previousChar = foText.charAt(i - 1);
kern = font.getKernValue(previousChar, currentChar);
} else if (prevAreaInfo != null
&& !prevAreaInfo.isSpace && prevAreaInfo.breakIndex > 0) {
char previousChar = foText.charAt(prevAreaInfo.breakIndex - 1);
kern = font.getKernValue(previousChar, currentChar);
}
if (kern != 0) {
addToLetterAdjust(i, kern);
wordIPD = wordIPD.plus(kern);
}
}
}
if (kerning
&& ( breakOpportunityChar != 0 )
&& !TextLayoutManager.isSpace(breakOpportunityChar)
&& lastIndex > 0
&& endsWithHyphen) {
int kern = font.getKernValue(foText.charAt(lastIndex - 1), breakOpportunityChar);
if (kern != 0) {
addToLetterAdjust(lastIndex, kern);
//TODO: add kern to wordIPD?
}
}
// shy+chars at start of word: wordLength == 0 && breakOpportunity
// shy only characters in word: wordLength == 0 && !breakOpportunity
int wordLength = lastIndex - thisStart;
int letterSpaces = 0;
if (wordLength != 0) {
letterSpaces = wordLength - 1;
// if there is a break opportunity and the next one (break character)
// is not a space, it could be used as a line end;
// add one more letter space, in case other text follows
if (( breakOpportunityChar != 0 ) && !TextLayoutManager.isSpace(breakOpportunityChar)) {
letterSpaces++;
}
}
assert letterSpaces >= 0;
wordIPD = wordIPD.plus(letterSpaceIPD.mult(letterSpaces));
// create and return the AreaInfo object
return new AreaInfo(thisStart, lastIndex, 0,
letterSpaces, wordIPD,
endsWithHyphen,