final int nonWordChars = actualWordStart - this.wordStart;
// Extract the word that should be evaluated by the hyphenation system.
final int wordSize = server.wordSize(this.currentChars, actualWordStart,
language, country);
// See if there are discretionary hyphenation points.
Hyphenation hyph = null;
try {
hyph = server.hyphenate(this.currentChars, actualWordStart,
wordSize, language, country,
this.currentLineText.inlineHyphenationRemainCount(),
this.currentLineText.inlineHyphenationPushCount(), false);
} catch (final HyphenationException e) {
/* Log the exception and continue. */
this.getLogger().error("Hyphenation error", e);
}
// If none, the word cannot be hyphenated.
if (hyph == null) {
return this.wordStart;
}
// Select a hyphenation point.
final CharSequence wordToHyphenate = this.currentChars.subSequence(actualWordStart,
actualWordStart + wordSize);
final int index = selectDiscretionaryHyphenationPoint(
this.currentLineText, wordToHyphenate, hyph);
// If none fit, then the word cannot be hyphenated.
if (index < 0) {
return this.wordStart;
}
// Compute the number of characters that should be included.
final int charsToInclude = hyph.getPoints()[index];
// Add it and the non-word characters to the count to be returned.
return this.wordStart + nonWordChars + charsToInclude;
}