From de13d285b10d2b3c50811367793adc24eca75368 Mon Sep 17 00:00:00 2001 From: KillzXGaming Date: Wed, 17 Jul 2019 19:10:52 -0400 Subject: [PATCH] Parse cmap properly for newer bffnt --- .vs/Toolbox/v15/.suo | Bin 276992 -> 276992 bytes File_Format_Library/FileFormats/Font/BFFNT.cs | 20 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/.vs/Toolbox/v15/.suo b/.vs/Toolbox/v15/.suo index 1e4871034877c9dc90340b9c36fe7563cc39402c..af128e433c7936503a36f891701ec00d6a0118f0 100644 GIT binary patch delta 159 zcmZqpBGB+fV1j`r0}Kc-FvtMe%s~9_|Ns9WVMZX92VzAa{BlJp!FNb1egWB95EX5$Ov_rCw*mmau`mAs delta 160 zcmZqpBGB+fV1j`r69W_oFfa%Lnan`^@Bjb*AW;xo9EgR1IAdd^FcWLTf%}f1Hy1Mf zVP=WDPy%GJv5PS>Y_62~&&$ZTxl*hB>^23aQwD-tfI1*R;lM#4LvZ^Y4MtUyWwDHh aH~lz`D!&&fF9(rtXKZEK&e+QQe+vNA#VdvY diff --git a/File_Format_Library/FileFormats/Font/BFFNT.cs b/File_Format_Library/FileFormats/Font/BFFNT.cs index 819757db..82856d85 100644 --- a/File_Format_Library/FileFormats/Font/BFFNT.cs +++ b/File_Format_Library/FileFormats/Font/BFFNT.cs @@ -711,7 +711,7 @@ namespace FirstPlugin reader.ReadSignature(4, "CMAP"); SectionSize = reader.ReadUInt32(); - if (header.Version.SwapBytes() > 0x3000000 || header.Version > 0x00000103) + if (header.Version > 0x3000000 || header.Version > 0x00000103) { CodeBegin = reader.ReadUInt32(); CodeEnd = reader.ReadUInt32(); @@ -754,9 +754,21 @@ namespace FirstPlugin var CharEntryCount = reader.ReadUInt16(); for (int i = 0; i < CharEntryCount; i++) { - char charCode = reader.ReadChar(); - short index = reader.ReadInt16(); - if (index != -1) header.FontSection.CodeMapDictionary[charCode] = index; + if (header.Version > 0x3000000 || header.Version > 0x00000103) + { + //Seems to have a spacing of a ushort for each entry + char charCode = reader.ReadChar(); + short padding = reader.ReadInt16(); + short index = reader.ReadInt16(); + short padding2 = reader.ReadInt16(); + if (index != -1) header.FontSection.CodeMapDictionary[charCode] = index; + } + else + { + char charCode = reader.ReadChar(); + short index = reader.ReadInt16(); + if (index != -1) header.FontSection.CodeMapDictionary[charCode] = index; + } } break; }