void WritePage(string filename, File.Font f) { string nfilename = Path.ChangeExtension(filename, ".png"); // we just have one f.Frame.Image.Save(nfilename); // just in case -png was not set sw.Write("page "); sw.Write("id", 0); sw.Write("file", nfilename); sw.WriteLine(); }
public static void SaveAsBMFont(string filename, File.Font f) { BMFontWriter writer = new BMFontWriter(); writer.sw = new StreamWriter(filename); writer.WriteInfoTag(f); writer.WriteCommon(f); writer.WritePage(filename, f); writer.WriteChars(f); writer.sw.Flush(); writer.sw.Close(); }
void WriteChars(File.Font f) { AppendField("chars count", f.Glyphs.Length); sw.WriteLine(); foreach (var g in f.Glyphs) { sw.Write("char "); sw.WriteLine("char id={0,-3} x={1,-4} y={2,-4} width={3,-4} height={4,-4} xoffset={5,-4} yoffset={6,-4} xadvance={7,-4} page=0 chnl=15", g.ch, g.x, g.y, g.width, g.height, 0, g.offset, g.shift); } sw.WriteLine(); }
static void DoFileWrite(string path, File.Font f) { CodeTask.RunOneThing(path, f); if (Context.saveAllPngs) { string filename = Path.ChangeExtension(Path.Combine(path, f.Name), ".fnt"); // we just have one BMFontWriter.SaveAsBMFont(filename, f); // f.Frame.Image.Save(filename); } }
void WriteCommon(File.Font f) { sw.Write("common "); AppendField("lineHeight", f.Size); AppendField("base", f.Size); // hope this is right AppendField("scaleW", f.Frame.Width); AppendField("scaleH", f.Frame.Height); AppendField("pages", 1); AppendField("packed", 0); AppendField("alphaChnl", 0); AppendField("redChnl", 0); AppendField("greenChnl", 0); AppendField("blueChnl", 0); sw.WriteLine(); }
void WriteInfoTag(File.Font f) { // Info tag sw.Write("info "); AppendField("face", f.Description); AppendField("size", f.Size); AppendField("bold", f.Bold); AppendField("italic", f.Italic); AppendField("charset", ""); // not sure if we need this // AppendField("unicode", false); AppendField("aa", f.AntiAlias); //AppendField("smooth", false); AppendField("padding", 0, 0, 0, 0); AppendField("spacing", 0); AppendField("outline", 0); sw.WriteLine(); }