mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-27 21:56:19 -04:00
hotfix: font format:
- removed magic numbers - corrected unknown1 bytes count in d2fontglyph.Create
This commit is contained in:
parent
30fb02bc10
commit
7574293624
@ -6,7 +6,7 @@ func Create(frame, width, height int) *FontGlyph {
|
|||||||
// nolint:gomnd // thes bytes are constant
|
// nolint:gomnd // thes bytes are constant
|
||||||
// comes from https://d2mods.info/forum/viewtopic.php?t=42044
|
// comes from https://d2mods.info/forum/viewtopic.php?t=42044
|
||||||
result := &FontGlyph{
|
result := &FontGlyph{
|
||||||
unknown1: []byte{0, 0},
|
unknown1: []byte{0},
|
||||||
unknown2: []byte{1, 0, 0},
|
unknown2: []byte{1, 0, 0},
|
||||||
unknown3: []byte{0, 0, 0, 0, 0},
|
unknown3: []byte{0, 0, 0, 0, 0},
|
||||||
frame: frame,
|
frame: frame,
|
||||||
|
@ -16,6 +16,8 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
numHeaderBytes = 12
|
||||||
|
bytesPerGlyph = 14
|
||||||
signatureBytesCount = 5
|
signatureBytesCount = 5
|
||||||
unknownHeaderBytesCount = 7
|
unknownHeaderBytesCount = 7
|
||||||
unknown1BytesCount = 1
|
unknown1BytesCount = 1
|
||||||
@ -147,13 +149,13 @@ func (f *Font) RenderText(text string, target d2interface.Surface) error {
|
|||||||
func (f *Font) initGlyphs(sr *d2datautils.StreamReader) error {
|
func (f *Font) initGlyphs(sr *d2datautils.StreamReader) error {
|
||||||
glyphs := make(map[rune]*d2fontglyph.FontGlyph)
|
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()
|
code, err := sr.ReadUInt16()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// two bytes of 0
|
// byte of 0
|
||||||
sr.SkipBytes(unknown1BytesCount)
|
sr.SkipBytes(unknown1BytesCount)
|
||||||
|
|
||||||
width, err := sr.ReadByte()
|
width, err := sr.ReadByte()
|
||||||
|
Loading…
Reference in New Issue
Block a user