// Path: game-common/src/main/java/com/game/common/util/PersistenceManager.java
// public class PersistenceManager {
// 	private static final Logger log = LoggerFactory.getLogger(PersistenceManager.class);
// 
// 	public class PacketHandler {
// 		public Packet.Type[] types;
// 		public Class<?> handler;
// 	}
// 
// 	public class ItemHandler {
// 		public int[] ids;
// 		public Class<?> handler;
// 	}
// 
// 	protected static final XStream xstream;
// 
// 	static {
// 		xstream = new XStream();
// 
// 		xstream.alias("type", Packet.Type.class);
// 
// 		xstream.alias("PacketHandler", PacketHandler.class);
// 		xstream.alias("ItemHandler", ItemHandler.class);
// 
// 		xstream.alias("ItemDef", Item.Definition.class);
// 		xstream.alias("TileDef", Tile.Definition.class);
// 	}
// 
// 	public static void alias(String name, Class<?> type) {
// 		xstream.alias(name, type);
// 	}
// 
// 	public static Object load(URL path) {
// 		try {
// 			InputStream in = path.openStream();
// 			Object o = xstream.fromXML(in);
// 			in.close();
// 
// 			return o;
// 		}
// 		catch (IOException ioe) {
// 			log.error("Error loading object: " + ioe.getMessage());
// 			System.exit(1); // fatal error
// 
// 			return null;
// 		}
// 	}
// 
// 	public static void save(Object o, File f) throws IOException {
// 		OutputStream out = new FileOutputStream(f);
// 		xstream.toXML(o, out);
// 		out.close();
// 	}
// }
// 
// Path: game-graphics/src/main/java/com/game/graphics/renderer/FontData.java
// public class FontData {
// 	public final Glyph[] glyphs;
// 	public final int fontHeight;
// 
// 	public FontData(int numGlyphs, int fontHeight) {
// 		glyphs = new Glyph[numGlyphs];
// 		this.fontHeight = fontHeight;
// 	}
// }
// 
// Path: game-graphics/src/main/java/com/game/graphics/renderer/Glyph.java
// public class Glyph {
// 	public final int width;
// 	public final int height;
// 	public final int x;
// 	public final int y;
// 
// 	public Glyph(int width, int height, int x, int y) {
// 		this.width = width;
// 		this.height = height;
// 		this.x = x;
// 		this.y = y;
// 	}
// }


import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.game.common.util.PersistenceManager;
import com.game.graphics.renderer.FontData;
import com.game.graphics.renderer.Glyph;
	protected final FontMetrics metrics;
	protected final FontData data;
	protected final BufferedImage texture;

	public FontConverter(Font font, int numGlyphs) {
		this.font = font;
		metrics = this.getMetrics(font);

		data = new FontData(numGlyphs, metrics.getHeight());
		texture = this.loadGlyphs(data.glyphs);
	}

	public FontData getData() {
		return data;
	}

	public BufferedImage getTexture() {
		return texture;
	}

	private FontMetrics getMetrics(Font font) {
		BufferedImage tmp = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

		Graphics2D g = tmp.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g.setFont(font);

		return g.getFontMetrics();
	}

// Path: game-common/src/main/java/com/game/common/util/PersistenceManager.java
// public class PersistenceManager {
// 	private static final Logger log = LoggerFactory.getLogger(PersistenceManager.class);
// 
// 	public class PacketHandler {
// 		public Packet.Type[] types;
// 		public Class<?> handler;
// 	}
// 
// 	public class ItemHandler {
// 		public int[] ids;
// 		public Class<?> handler;
// 	}
// 
// 	protected static final XStream xstream;
// 
// 	static {
// 		xstream = new XStream();
// 
// 		xstream.alias("type", Packet.Type.class);
// 
// 		xstream.alias("PacketHandler", PacketHandler.class);
// 		xstream.alias("ItemHandler", ItemHandler.class);
// 
// 		xstream.alias("ItemDef", Item.Definition.class);
// 		xstream.alias("TileDef", Tile.Definition.class);
// 	}
// 
// 	public static void alias(String name, Class<?> type) {
// 		xstream.alias(name, type);
// 	}
// 
// 	public static Object load(URL path) {
// 		try {
// 			InputStream in = path.openStream();
// 			Object o = xstream.fromXML(in);
// 			in.close();
// 
// 			return o;
// 		}
// 		catch (IOException ioe) {
// 			log.error("Error loading object: " + ioe.getMessage());
// 			System.exit(1); // fatal error
// 
// 			return null;
// 		}
// 	}
// 
// 	public static void save(Object o, File f) throws IOException {
// 		OutputStream out = new FileOutputStream(f);
// 		xstream.toXML(o, out);
// 		out.close();
// 	}
// }
// 
// Path: game-graphics/src/main/java/com/game/graphics/renderer/FontData.java
// public class FontData {
// 	public final Glyph[] glyphs;
// 	public final int fontHeight;
// 
// 	public FontData(int numGlyphs, int fontHeight) {
// 		glyphs = new Glyph[numGlyphs];
// 		this.fontHeight = fontHeight;
// 	}
// }
// 
// Path: game-graphics/src/main/java/com/game/graphics/renderer/Glyph.java
// public class Glyph {
// 	public final int width;
// 	public final int height;
// 	public final int x;
// 	public final int y;
// 
// 	public Glyph(int width, int height, int x, int y) {
// 		this.width = width;
// 		this.height = height;
// 		this.x = x;
// 		this.y = y;
// 	}
// }


// Path: game-tools/src/main/java/com/game/tools/fontconverter/FontConverter.java
import java.awt.Color;
import java.awt.Font;
import java.awt.FontFormatException;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.PosixParser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.game.common.util.PersistenceManager;
import com.game.graphics.renderer.FontData;
import com.game.graphics.renderer.Glyph;

	protected final FontMetrics metrics;
	protected final FontData data;
	protected final BufferedImage texture;

	public FontConverter(Font font, int numGlyphs) {
		this.font = font;
		metrics = this.getMetrics(font);

		data = new FontData(numGlyphs, metrics.getHeight());
		texture = this.loadGlyphs(data.glyphs);
	}

	public FontData getData() {
		return data;
	}

	public BufferedImage getTexture() {
		return texture;
	}

	private FontMetrics getMetrics(Font font) {
		BufferedImage tmp = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);

		Graphics2D g = tmp.createGraphics();
		g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		g.setFont(font);

		return g.getFontMetrics();
	}

	private BufferedImage loadGlyphs(Glyph[] glyphs) {