1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-09-25 04:36:12 -04:00

Merge pull request #1070 from gucio321/hotfix2

hotfix: font format:
This commit is contained in:
gravestench 2021-02-19 01:11:00 -08:00 committed by GitHub
commit 318e4ac7e2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -6,7 +6,7 @@ func Create(frame, width, height int) *FontGlyph {
// nolint:gomnd // thes bytes are constant
// comes from https://d2mods.info/forum/viewtopic.php?t=42044
result := &FontGlyph{
unknown1: []byte{0, 0},
unknown1: []byte{0},
unknown2: []byte{1, 0, 0},
unknown3: []byte{0, 0, 0, 0, 0},
frame: frame,

View File

@ -16,6 +16,8 @@ const (
)
const (
numHeaderBytes = 12
bytesPerGlyph = 14
signatureBytesCount = 5
unknownHeaderBytesCount = 7
unknown1BytesCount = 1
@ -147,13 +149,13 @@ func (f *Font) RenderText(text string, target d2interface.Surface) error {
func (f *Font) initGlyphs(sr *d2datautils.StreamReader) error {
glyphs := make(map[rune]*d2fontglyph.FontGlyph)
for i := 12; i < len(f.table); i += 14 {
for i := numHeaderBytes; i < len(f.table); i += bytesPerGlyph {
code, err := sr.ReadUInt16()
if err != nil {
return err
}
// two bytes of 0
// byte of 0
sr.SkipBytes(unknown1BytesCount)
width, err := sr.ReadByte()