public async Task BuildFontDigraphsFromFolder(string inDir, string outFile) { using Font font = Font.CreateFromCharsDir(inDir); font.AddDigraphs(); using FileStream outStream = new FileStream(outFile, FileMode.Create, FileAccess.Write); await font.WriteFontPar(outStream, false); }
public async Task PatchFont() { try { ClearStatus(); ContainerEntry fontEntry = ArcFile.GetEntry("im2nx_font.par"); if (fontEntry == null) { throw new FileNotFoundException("File im2nx_font.par not found. Make sure you are opening disc.arc"); } using (Stream parStream = await fontEntry.GetData()) { ReportMessage("Reading im2nx_font.par..."); Font font = await Task.Run(() => Font.CreateFromPar(parStream)); ReportMessage("Patching font..."); await Task.Run(() => font.AddDigraphs()); ReportMessage("Writing font as par..."); using MemoryStream memStream = new MemoryStream(); await font.WriteFontPar(memStream, false); memStream.Position = 0; await fontEntry.SetData(memStream); } ReportMessage("Done."); } catch (Exception ex) { ReportException(ex); } }
public void BlackFontTest(string inDir) { using Font font = Font.CreateFromCharsDir(inDir); font.UseBlackBitmaps(); font.AddDigraphs(); Assert.IsTrue(font.CheckTree()); font.SaveBigBitmap("../textbox-display/fontblack.png"); }
public void WriteJSONTest(string inDir) { using Font font = Font.CreateFromCharsDir(inDir); font.AddDigraphs(); Assert.IsTrue(font.CheckTree()); font.SaveBigBitmap("../textbox-display/fontwhite.png"); using StreamWriter writer = new StreamWriter("../textbox-display/fontdata.js"); font.WriteJSON(writer); }
public async Task AddAllDigraphsToFontTest(string inFile, string expectedPng, string expectedPar) { using (FileStream inStream = new FileStream(inFile, FileMode.Open, FileAccess.Read)) { using Font font = await Font.CreateFromPar(inStream); font.AddDigraphs(); Assert.IsTrue(font.CheckTree()); font.SaveBigBitmap(expectedPng); using FileStream outStream = new FileStream(expectedPar, FileMode.Create, FileAccess.Write); await font.WriteFontPar(outStream, false); } //bool eq = Compare.CompareFiles(expectedPar, "temp.par") && Compare.CompareFiles(expectedPng, "temp.png"); //File.Delete("temp.par"); //File.Delete("temp.png"); //Assert.IsTrue(eq); }