diff --git a/readers/fonts/Font.java b/readers/fonts/Font.java index 8833275..beba116 100644 --- a/readers/fonts/Font.java +++ b/readers/fonts/Font.java @@ -5,17 +5,40 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.nio.file.StandardOpenOption; +import java.util.List; import java.awt.Color; public class Font { - Glyph[] data = new Glyph[9]; + Glyph[] data = new Glyph[10]; final static int TRANSPARENT = new Color(0,0,0,0).getRGB(); public static Font LoadFont(String fontName) { Path f = Paths.get("readers","fonts",fontName); if (Files.exists(f)) { - //TODO Read the file. - return new Font(); + Font font = new Font(); + try { + List data = Files.readAllLines(f); + for (int i=0;iendY) { - endY=Y; - } + } + //If we got to here it means we found transparent on everything. + if (startX!=-1) { + endX=x; + //Create a Glyph out of this. + Glyph g = new Glyph(); + g.width=endX-startX; + g.height=data.getHeight(); + int[] arr = data.getRGB(startX,0,g.width,g.height,null,0,g.width); + //Find the min and max Y. + int startY=g.height; + int endY=0; + for (int X=0;XendY) { + endY=Y; } } - int index = expectedGlyphs.charAt(0)-'0'; - font.data[index]=g; - System.out.println("Glyph for number "+index+" has been saved."); - expectedGlyphs=expectedGlyphs.substring(1); } + g.height=endY-startY; + g.data = new boolean[g.width*g.height]; + for (int X=0;X