-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
dbf23ab
commit a6b9c14
Showing
4 changed files
with
98 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using DALLib.Exceptions; | ||
using DALLib.IO; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.Linq; | ||
using System.Runtime.Remoting.Messaging; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace DALLib.File | ||
{ | ||
public class FNTFile : FileBase | ||
{ | ||
|
||
public FontFile FontCode { get; set; } | ||
public TEXFile FontTexture { get; set; } | ||
|
||
public override void Load(ExtendedBinaryReader reader, bool keepOpen = false) | ||
{ | ||
string tableSig = reader.ReadDALSignature("Table"); | ||
if (tableSig != "Table" && tableSig.Length <= 4) | ||
throw new SignatureMismatchException("Table", tableSig); | ||
|
||
int textureOffset = reader.ReadInt32(); | ||
|
||
FontCode = new FontFile(); | ||
FontTexture = new TEXFile(); | ||
|
||
FontCode.WidthScale = -1; | ||
FontCode.HeightScale = -1; | ||
FontCode.MonospaceOnly = true; | ||
FontCode.Load(reader, true); | ||
|
||
// Load texture | ||
reader.JumpTo(textureOffset); | ||
FontTexture.Load(reader, true); | ||
|
||
// Set scale size | ||
FontCode.WidthScale = (float)FontCode.CharacterHeight / FontTexture.SheetWidth; | ||
FontCode.HeightScale = (float)FontCode.CharacterHeight / FontTexture.SheetHeight; | ||
} | ||
|
||
public override void Save(ExtendedBinaryWriter writer) | ||
{ | ||
writer.WriteDALSignature("Table", false); | ||
|
||
writer.AddOffset("texture"); | ||
|
||
// Code | ||
FontCode.WidthScale = -1; | ||
FontCode.HeightScale = -1; | ||
FontCode.Save(writer); | ||
|
||
// Texture | ||
writer.FillInOffset("texture"); | ||
FontTexture.Save(writer); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters