private static Font getAppropriateFont(String text, int width, int height) {
		int i = height;
		Font font = new Font("Arial", Font.PLAIN, i);
		FontRenderContext context = new FontRenderContext(null, false, false);
		Rectangle2D bounds = font.getStringBounds(text, context);
		while (i > 1
				&& (bounds.getWidth() > width || bounds.getHeight() > height)) {
			--i;
			font = new Font("Arial", Font.PLAIN, i);
			bounds = font.getStringBounds(text, context);
		}
		return font;
	}