private void OpenFont(string fileName) { FONTTABLE = null; FONTDATA = new string[0]; FONT = new FontChar[0]; string BMP = System.IO.Path.GetDirectoryName(fileName); try { BMP += "\\" + (int.Parse(System.IO.Path.GetFileNameWithoutExtension(fileName)) - 1) + ".bmp"; } catch { MessageBox.Show("Can't find BMP font file, try rename the font file to original pak extracted file name.", "Super Danganronpa 2 Font Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (System.IO.File.Exists(BMP)) { FONTTABLE = (Bitmap)Image.FromFile(BMP); } else { MessageBox.Show("Can't find BMP file, try rename to original pak extracted file name.", "Super Danganronpa 2 Font Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } FontTable.Image = FONTTABLE; FONTDATA = Tools.ByteArrayToString(System.IO.File.ReadAllBytes(fileName)).Split('-'); string signature = "0x74467053"; if (signature != "0x" + FONTDATA[0] + FONTDATA[1] + FONTDATA[2] + FONTDATA[3]) { MessageBox.Show("This not is a font table info file.", "Super Danganronpa 2 Font Editor", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int StartFontTable = GetOffset(FONTDATA, 12); int Position = StartFontTable; while (FONTDATA[Position] + FONTDATA[Position + 1] + FONTDATA[Position + 2] + FONTDATA[Position + 3] + FONTDATA[Position + 4] + FONTDATA[Position + 5] + FONTDATA[Position + 6] + FONTDATA[Position + 7] + FONTDATA[Position + 8] + FONTDATA[Position + 9] + FONTDATA[Position + 10] + FONTDATA[Position + 11] + FONTDATA[Position + 12] + FONTDATA[Position + 13] + FONTDATA[Position + 14] + FONTDATA[Position + 15] != "00000000000000000000000000000000") { object[] LETTER = GetChar(Position); char CHAR = (char)LETTER[0]; Point POINT = (Point)LETTER[1]; System.Drawing.Size SIZE = (System.Drawing.Size)LETTER[2]; string[] EC = (string[])LETTER[3]; FontChar[] temp = new FontChar[FONT.Length + 1]; FONT.CopyTo(temp, 0); FontChar FC = new FontChar(); FC.Letter = CHAR; FC.Point = POINT; FC.Size = SIZE; FC.ExtraContent = EC; temp[FONT.Length] = FC; FONT = temp; Position += 16; } for (; Position < FONTDATA.Length; Position++) { string[] temp = new string[FontBotton.Length + 1]; FontBotton.CopyTo(temp, 0); temp[FontBotton.Length] = FONTDATA[Position]; FontBotton = temp; } WriteRetangles(); UpdateScrolls(); SelectLetter(0); groupBox1.Enabled = true; groupBox2.Enabled = true; BNTTestFont.Enabled = true; BNTSave.Enabled = true; }
/*.font format * * HEX POS - Without data * (Offset)= Hex Data * ========================== * 2-3 = Posição X ----------- * * ========================== | | | 4-5 = Posição Y | | ========================== | | 6-7 = tamanho X = --------- | | ========================== | 8-9 = tamanho Y | | | | | 00 00 11 11 22 22 33 33 44 44 ?? ?? ?? ?? ?? ?? ?? | | 00 00 = Unicode Char | | 11 11 = 2-3 (Posição X) | | 22 22 = 4-5 (Posição Y) | | 33 33 = 6-7 (Tamanho X) | | 44 44 = 8-9 (Tamanho Y)*/ private string[] ExportChar(FontChar Char) { string Letter = Tools.UnicodeStringToHex(Char.Letter.ToString()); string PointX = Tools.IntToHex(Char.Point.X).Substring(0, 5); string PointY = Tools.IntToHex(Char.Point.Y).Substring(0, 5); string WidthX = Tools.IntToHex(Char.Size.Width).Substring(0, 5); string HeigthY = Tools.IntToHex(Char.Size.Height).Substring(0, 5); string EC = ""; foreach (string hex in Char.ExtraContent) { EC += " " + hex; } string Content = Letter + " " + PointX + " " + PointY + " " + WidthX + " " + HeigthY + EC; return(Content.Split(' ')); }