} else { context.setWidth(graphicsLength);
    public static void breakText(LayoutContext c,             LineBreakContext context, int avail, IdentValue whitespace, Font font) {        // ====== handle nowrap        if (whitespace == IdentValue.NOWRAP) {        	context.setEnd(context.getLast());        	context.setWidth(FontUtil.len(context.getCalculatedSubstring(), font,        			c.getTextRenderer(), c.getGraphics()));            return;        }        //check if we should break on the next newline        if (whitespace == IdentValue.PRE ||                whitespace == IdentValue.PRE_WRAP ||                whitespace == IdentValue.PRE_LINE) {            int n = context.getStartSubstring().indexOf(WhitespaceStripper.EOL);            if (n > -1) {                context.setEnd(context.getStart() + n + 1);                context.setWidth(FontUtil.len(context.getCalculatedSubstring(), font,                         c.getTextRenderer(), c.getGraphics()));                                context.setNeedsNewLine(true);            } else if (whitespace == IdentValue.PRE) {            	context.setEnd(context.getLast());                context.setWidth(FontUtil.len(context.getCalculatedSubstring(), font,                         c.getTextRenderer(), c.getGraphics()));               }        }        //check if we may wrap        if (whitespace == IdentValue.PRE) {            return;        }        String currentString = context.getStartSubstring();        int left = 0;        int right = currentString.indexOf(WhitespaceStripper.SPACE, left + 1);        int lastWrap = 0;        int graphicsLength = 0;        int lastGraphicsLength = 0;        while (right > 0 && graphicsLength <= avail) {            lastGraphicsLength = graphicsLength;            graphicsLength += FontUtil.len(currentString.substring(left, right),                     font, c.getTextRenderer(), c.getGraphics());            lastWrap = left;            left = right;            right = currentString.indexOf(WhitespaceStripper.SPACE, left + 1);        }        if (graphicsLength <= avail) {            //try for the last bit too!            lastWrap = left;            lastGraphicsLength = graphicsLength;            graphicsLength += FontUtil.len(currentString.substring(left), font,                     c.getTextRenderer(), c.getGraphics());        }        if (graphicsLength <= avail) {            context.setWidth(graphicsLength);            context.setEnd(context.getMaster().length());            //It fit!            return;        }                context.setNeedsNewLine(true);        if (lastWrap != 0) {//found a place to wrap            context.setEnd(context.getStart() + lastWrap);            context.setWidth(lastGraphicsLength);        } else {//unbreakable string            if (left == 0) {                left = currentString.length();            }                        context.setEnd(context.getStart() + left);            context.setUnbreakable(true);                        if (left == 0) {                context.setWidth(FontUtil.len(context.getCalculatedSubstring(), font,                         c.getTextRenderer(), c.getGraphics()));            }        }        return;    }