diff --git a/d2common/d2fileformats/d2font/d2fontglyph/font_glyph.go b/d2common/d2fileformats/d2font/d2fontglyph/font_glyph.go index 3ee8e6eb..0f6df70b 100644 --- a/d2common/d2fileformats/d2font/d2fontglyph/font_glyph.go +++ b/d2common/d2fileformats/d2font/d2fontglyph/font_glyph.go @@ -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, diff --git a/d2common/d2fileformats/d2font/font.go b/d2common/d2fileformats/d2font/font.go index bb9beedb..7ffd6032 100644 --- a/d2common/d2fileformats/d2font/font.go +++ b/d2common/d2fileformats/d2font/font.go @@ -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()