long spacerOpt = 0;
final int lastPos = Math.min(glyphs.getSize(), offset + length);
for (int i = offset; i < lastPos; i++)
{
final Glyph glyph = glyphs.getGlyph(i);
// heightAbove = Math.max(glyph.getBaseLine(), heightAbove);
// heightBelow = Math.max(glyph.getHeight() - glyph.getBaseLine(), heightBelow);
final int kerning = glyph.getKerning();
final int width = glyph.getWidth();
final int realCharSpace = width - kerning;
realCharTotal += realCharSpace;
if (i == (lastPos - 1))
{
wordMinChunkWidth += realCharSpace;
}
else
{
final Spacing spacing = glyph.getSpacing();
spacerMax += spacing.getMaximum();
spacerMin += spacing.getMinimum();
spacerOpt += spacing.getOptimum();
if (normalTextSpacing == true &&
Spacing.EMPTY_SPACING.equals(spacing) == false)
{
normalTextSpacing = false;
}
wordMinChunkWidth += spacing.getMinimum() + realCharSpace;
}
if (glyph.getBreakWeight() > BreakOpportunityProducer.BREAK_CHAR)
{
minimumChunkWidth = Math.max(minimumChunkWidth, wordMinChunkWidth);
wordMinChunkWidth = 0;
// Paranoid sanity checks: The word- and linebreaks should have been
// replaced by other definitions in the text factory.
if (glyph.getBreakWeight() == BreakOpportunityProducer.BREAK_LINE)
{
throw new IllegalStateException("A renderable text cannot and must " +
"not contain linebreaks.");
}
}