package org.gvsig.mobile.symbology.labeling.fonts;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

import org.gvsig.mobile.symbology.labeling.fonts.houseblend.HersheyFont;


public class ShowAll {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int x = 5;
		int y = 95;
		int xini = 5;
		int yini = 95;
		int xmax = 750;
		
		String[] fonts = {
				"astrology.jhf",
				"cursive.jhf",
				"cyrilc_1.jhf",
				"cyrillic.jhf",
				"futural.jhf",
				"futuram.jhf",
				"gothgbt.jhf",
				"gothgrt.jhf",
				"gothiceng.jhf",
				"gothicger.jhf",
				"gothicita.jhf",
				"gothitt.jhf",
				"greek.jhf",
				"greekc.jhf",
				"greeks.jhf",
				"houseblend",
				"japanese.jhf",
				"markers.jhf",
				"mathlow.jhf",
				"mathupp.jhf",
				"meteorology.jhf",
				"music.jhf",
				"rowmand.jhf",
				"rowmans.jhf",
				"rowmant.jhf",
				"scriptc.jhf",
				"scripts.jhf",
				"symbolic.jhf",
				"timesg.jhf",
				"timesi.jhf",
				"timesib.jhf",
				"timesr.jhf",
				"timesrb.jhf"};
		
		BufferedImage img = new BufferedImage(800, 800, BufferedImage.TYPE_INT_ARGB);
		Graphics g = img.getGraphics();
		
		for (int i=0;i<fonts.length;i++){
			System.out.println("\n" + fonts[i]);
			x=xini;
			y=yini;
			g.setColor( Color.white );
		    g.fillRect( 0,0,img.getWidth(), img.getHeight());
		    try{
		    	HersheyFont font = new HersheyFont();
		    	font.loadFont(ShowAll.class.getClassLoader().getResource("."), fonts[i]);
		    	// 1.0f equivale a tamao de fuente 28
		    	// girado 30 con tamao 0.43f (12p) se ve mejor meteorology
		    	font.setHeight( 2.0f );
		        font.setWidth( 2.0f );
		        
		        //font.setRotation(30);
				for (int j=(int)' ';j<256;j++){
				    g.setColor( 
				    		new Color(
				    				(int)(Math.random()*155),
				    				(int)(Math.random()*155),
				    				(int)(Math.random()*155)));

					try{
						font.drawString("" + (char)j, x, y, g);
					} catch (Exception e){
						//e.printStackTrace();
						System.out.print((char)j + "," );
					}
					x+=50;
					if (x>xmax){
						y+=70;
						x=xini;
					}
				}
				try {
				    File outputfile = new File(fonts[i]+".png");
				    ImageIO.write(img, "png", outputfile);
				} catch (IOException e) {
				    e.printStackTrace();
				}
		    } catch (Exception e1){
		    	e1.printStackTrace();
		    }
		}
	}

}
