From c2bb2d3ff968e0541ece8b5fb7fe590ddc8d7c52 Mon Sep 17 00:00:00 2001 From: Andy McFadden Date: Sun, 22 Dec 2024 09:22:20 -0800 Subject: [PATCH] Bitmap font fix IIgs fonts with extra data in the header (offsetToMF != 6) were being mis-handled. --- FileConv/Gfx/BitmapFont.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/FileConv/Gfx/BitmapFont.cs b/FileConv/Gfx/BitmapFont.cs index e61f2c7..ccadb2f 100644 --- a/FileConv/Gfx/BitmapFont.cs +++ b/FileConv/Gfx/BitmapFont.cs @@ -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; } @@ -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) {