public static void MakeFontFromCSV(string fName) { BMFont bmfont = new BMFont(); string[] lines = System.IO.File.ReadAllLines(fName, EncodingType.GetType(fName)); foreach (string line in lines) { if (line.IndexOf("//") == 0) { continue; } if (line.Contains(",")) { string c_line = line.Replace("\n", ""); c_line = c_line.Replace("\r", ""); string[] par = c_line.Split(','); string _fontName = par[0]; string _ttfName = par[1]; string _charmap = par[2]; int _fontWidth = Convert.ToInt16(par[3]); int _fontHeight = Convert.ToInt16(par[4]); int _fontSize = Convert.ToInt16(par[5]); string chars = ReadFromFile(_charmap); int _texture_width = 1024; int a2 = _texture_width / _fontWidth; int t1 = chars.Length / a2; int t2 = chars.Length % a2; int _texture_height = t1 * _fontHeight; if (t2 > 0) { _texture_height += _fontHeight; } if (_texture_height % 256 != 0) { _texture_height = _texture_height + (256 - _texture_height % 256); } Config.fontWidth = _fontWidth; Config.fontHeight = _fontHeight; Config.fontSize = _fontSize; Config.ttfName = _ttfName; Config.texture_width = _texture_width; Config.texture_height = _texture_height; Config.unk0 = Convert.ToUInt32(par[6], 16); Config.unk1 = Convert.ToUInt32(par[7], 16); Config.unk2 = Convert.ToUInt32(par[8], 16); Config.unk3 = Convert.ToUInt32(par[9], 16); if (File.Exists(_ttfName)) { Console.WriteLine("Gen NIS font...\n_fontName:{0},{1},{2},{3},{4}:{5}x{6}", _fontName, _ttfName, _charmap, _fontHeight, chars.Length, _texture_width, _texture_height); NISFont fnt_data = bmfont.DrawT3BFontBitmap(chars.ToCharArray()); if (!Directory.Exists("import")) { Directory.CreateDirectory("import"); } using (Graphics g = Graphics.FromImage(fnt_data.bitmap)) { IntPtr hdc = g.GetHdc(); string dst_imgname = string.Format("import//{0}.tga", _fontName); string dst_nmfname = string.Format("import//{0}.nmf", _fontName); FIBITMAP fBitmap = FreeImage.CreateFromHbitmap(fnt_data.bitmap.GetHbitmap(), hdc ); if (File.Exists(dst_imgname)) { File.Delete(dst_imgname); } FreeImage.SaveEx(fBitmap, dst_imgname); byte[] dst_data = MakeFrm(fnt_data.charvalues); File.WriteAllBytes(dst_nmfname, dst_data); } } } } }