From 66ac5ff6578e4dcc57d025600270db162e34bf44 Mon Sep 17 00:00:00 2001 From: "M. Sz" Date: Wed, 17 Feb 2021 10:28:36 +0100 Subject: [PATCH] font table format: methods to set size and frame index --- d2common/d2fileformats/d2font/font.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/d2common/d2fileformats/d2font/font.go b/d2common/d2fileformats/d2font/font.go index 38ce32ea..015b4178 100644 --- a/d2common/d2fileformats/d2font/font.go +++ b/d2common/d2fileformats/d2font/font.go @@ -32,8 +32,8 @@ type FontGlyph struct { height int } -func (fg *FontGlyph) setHeight(h int) { - fg.height = h +func (fg *FontGlyph) SetSize(w, h int) { + fg.width, fg.height = w, h } // Size returns glyph's size @@ -41,6 +41,10 @@ func (fg *FontGlyph) Size() (w, h int) { return fg.width, fg.height } +func (fg *FontGlyph) SetFrameIndex(idx int) { + fg.frame = idx +} + // FrameIndex returns glyph's frame func (fg *FontGlyph) FrameIndex() int { return fg.frame @@ -94,7 +98,7 @@ func (f *Font) SetBackground(sheet d2interface.Animation) { _, h := f.sheet.GetFrameBounds() for i := range f.Glyphs { - f.Glyphs[i].setHeight(h) + f.Glyphs[i].SetSize(f.Glyphs[i].width, h) } }