Skip to content

Commit

Permalink
Bitmap font fix
Browse files Browse the repository at this point in the history
IIgs fonts with extra data in the header (offsetToMF != 6) were being
mis-handled.
  • Loading branch information
fadden committed Dec 22, 2024
1 parent 61c1869 commit c2bb2d3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions FileConv/Gfx/BitmapFont.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,10 @@ public bool Load(byte[] buf, ref int offset, Notes notes) {
if (extraLen < 0) {
notes.AddW("Warning: invalid OffsetToMF " + OffsetToMF);
// keep going
} else if (OffsetToMF > BASE_LENGTH) {
} else if (extraLen > 0) {
ExtraData = new byte[extraLen];
Array.Copy(buf, offset, ExtraData, 0, extraLen);
offset += extraLen;
}
return true;
}
Expand Down Expand Up @@ -175,7 +176,9 @@ public bool Load(byte[] buf, ref int offset, Notes notes) {
Debug.Assert(offset - startOffset == BASE_LENGTH);

if (LastChar < 0 || LastChar > 255 || FirstChar > LastChar) {
notes.AddE("Error: bad first/last char " + FirstChar + " / " + LastChar);
notes.AddE("Error: bad first/last char: first=$" +
((int)FirstChar).ToString("x2") + " '" + FirstChar + "' last=$" +
((int)LastChar).ToString("x2") + " '" + LastChar + "'");
return false;
}
if (FRectWidth <= 0 || FRectHeight <= 0 || RowWords <= 0) {
Expand Down

0 comments on commit c2bb2d3

Please sign in to comment.