public GraphicsFont(Font font) {

		this.setFont(font);

		//create a Graphics2D to get the character sizes
		Graphics2D fontGraphics = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB).createGraphics();
		fontGraphics.setFont(font);
		fontGraphics.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
		setFontMetrics(fontGraphics.getFontMetrics());

		// create a list to sort and hold the bounds and character
		SortedSet<CharRect> sortedRects = new TreeSet<CharRect>();

		//for all the characters (except invisible ones) get their sizes
		for (char i = 0; i < CHARS; i++) {

			if (Character.isWhitespace(i) || !font.canDisplay(i))
				continue;

			getBounds()[i] = new Rectangle(0, 0, getFontMetrics().charWidth(i), getFontMetrics().getHeight() + OFFSET);
			getBounds()[i].width += OFFSET;//fix an issue with chars overlapping
			sortedRects.add(new CharRect(i, getBounds()[i]));
		}

		//Pack the character bounds into the smallest multiple of 2 rectangle
		Packer packer = new Packer();
		packer.fit(sortedRects);

		int width = packer.getSize().width;
		int height = packer.getSize().height;

		// create an intermediate image to render the text to
		BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
		Graphics2D gr = image.createGraphics();
		gr.setFont(font);
		gr.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
		gr.setColor(Color.WHITE);

		//render each char and also update the char bounds
		for (CharRect rect : sortedRects) {

//			bounds[rect.c].width -= 2;//fix an issue with chars overlapping
//			gr.setColor(Color.GRAY);
//			gr.fillRect(rect.x, rect.y, rect.width, rect.height);
			gr.setColor(Color.WHITE);
			if (rect.c == 'j')
				rect.x++;
			gr.drawChars(new char[]{rect.c}, 0, 1, rect.x + 1, rect.y + getFontMetrics().getAscent());
			rect.width -= OFFSET - 1;
			rect.height -= OFFSET - 1;
			getBounds()[rect.c].setBounds(rect);
		}

		setAtlas(new Texture());
		getAtlas().setDataFromImage(image);

//		try {
//			ImageIO.write(image, "png", new File(font.toString() + ".png"));
//			System.out.println("picture done");
//		} catch (IOException e) {
//			e.printStackTrace();
//			System.out.println("failed");
//		}
	}