private static void MakeFont(string charlistName, string ttfName, string dstName, int fontSize, float scaleRatio, int maxcharnums = -1)
        {
            string charlist = ReadFromFile(charlistName, "base.TBL");

            if (maxcharnums != -1)
            {
                if (charlist.Length > maxcharnums)
                {
                    charlist = charlist.Substring(0, maxcharnums);
                }
            }
            PersonaFont font = new PersonaFont();

            PersonaFont.FontInfo fInfo = font.LoadFont("font0.fnt");

            fInfo.OverrideFontSize(fontSize);

            List <PFontGlyph> pglyphs = BMFont.GetGlyphs(charlist, ttfName, fontSize, fontSize, scaleRatio);

            byte[] dstFont;
            font.MakeFont(fInfo, pglyphs, out dstFont);

            FileStream   fs = File.Create(dstName);
            BinaryWriter bw = new BinaryWriter(fs);

            bw.Write(dstFont);
            bw.Close();
            fs.Close();

            /*TextureEncoder encoder = new TextureEncoder();
             * FileStream fs = File.Create("test.bin");
             * BinaryWriter bw = new BinaryWriter(fs);
             * for (int i = 0; i < pglyphs.Count; i++)
             * {
             *  PFontGlyph glyph = pglyphs[i];
             *  byte[] data = encoder.create4Bpp(glyph.bitmap, 24, 24, encoder.getPS2PaletteData(fInfo.palette_data), EndianType.BIG);
             *  bw.Write(data);
             * }
             * bw.Close();
             * fs.Close();
             */
        }
示例#2
0
        static void Main(string[] args)
        {
            PersonaFont font = new PersonaFont();

            font.LoadFont("font0.fnt");
        }