public static String wrapToPixelWidth(Font font, String text, int width) {
		int[] lineWidth = { 0 };
		StringBuilder buffer = new StringBuilder(text.length() * 2);
		StringBuilder lineBuffer = new StringBuilder(text.length());
		StringTokenizer tokenizer = new StringTokenizer(text + NEWLINE, " \t/\\\n", true); //$NON-NLS-1$
		boolean wrapped = false;
		while (tokenizer.hasMoreTokens()) {
			String token = tokenizer.nextToken();
			if (token.equals(NEWLINE)) {
				if (lineWidth[0] > 0) {
					buffer.append(lineBuffer);
				}
				buffer.append(token);
				wrapped = false;
				lineBuffer.setLength(0);
				lineWidth[0] = 0;
			} else {
				if (!wrapped || lineWidth[0] != 0 || !token.equals(SPACE)) {
					wrapped = processOneTokenForWrapToPixelWidth(token, font, buffer, lineBuffer, width, lineWidth, wrapped);
				}
			}
		}
		if (lineWidth[0] > 0) {
			buffer.append(lineBuffer);
		}
		buffer.setLength(buffer.length() - 1);
		return buffer.toString();
	}