public static final Dimension getPreferredSize(Font font, String text) {
		int width = 0;
		int height = 0;
		int length = text.length();
		if (length > 0) {
			TIntIntHashMap map = getWidthMap(font);
			int fHeight = getFontHeight(font);
			char ch = 0;
			int curWidth = 0;
			for (int i = 0; i < length; i++) {
				ch = text.charAt(i);
				if (ch == '\n') {
					height += fHeight;
					if (curWidth > width) {
						width = curWidth;
					}
					curWidth = 0;
				} else {
					curWidth += getCharWidth(font, ch, map);
				}
			}
			if (ch != '\n') {
				height += fHeight;
			}
			if (curWidth > width) {
				width = curWidth;
			}
			if (width == 0) {
				width = getCharWidth(font, ' ', map);
			}
		}
		return new Dimension(width, height);
	}