// 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;
package com.game.tools.fontconverter;





public class FontConverter {
	private static final Logger log = LoggerFactory.getLogger(FontConverter.class);

	public static final int DEFAULT_FONT_SIZE = 11;

	protected static final Options options;

	static {
		options = new Options();

		options.addOption("h", "help", false, "Print this help.");
		options.addOption("i", "input-file", true, "The TTF font file to convert.");
		options.addOption("go", "glyph-output-file", true, "Path to the glyph output file, default <fontname>.png.");
		options.addOption("do", "data-output-file", true, "Path to the data output file, default <fontname>.xml.");
		options.addOption("s", "size", true, "The font size, default " + DEFAULT_FONT_SIZE + ".");

		PersistenceManager.alias("FontData", FontData.class);
// 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;

package com.game.tools.fontconverter;





public class FontConverter {
	private static final Logger log = LoggerFactory.getLogger(FontConverter.class);

	public static final int DEFAULT_FONT_SIZE = 11;

	protected static final Options options;

	static {
		options = new Options();

		options.addOption("h", "help", false, "Print this help.");
		options.addOption("i", "input-file", true, "The TTF font file to convert.");
		options.addOption("go", "glyph-output-file", true, "Path to the glyph output file, default <fontname>.png.");
		options.addOption("do", "data-output-file", true, "Path to the data output file, default <fontname>.xml.");
		options.addOption("s", "size", true, "The font size, default " + DEFAULT_FONT_SIZE + ".");

		PersistenceManager.alias("FontData", FontData.class);
		PersistenceManager.alias("Glyph", Glyph.class);