OpenDiablo2/d2common/d2fileformats/d2font/d2fontglyph/font_glyph.go

68 lines
1.3 KiB
Go

// Package d2fontglyph represents a single font glyph
package d2fontglyph
// Create creates a new font glyph
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{
frame: frame,
width: width,
height: height,
}
return result
}
// FontGlyph represents a single font glyph
type FontGlyph struct {
frame int
width int
height int
}
// SetSize sets glyph's size to w, h
func (fg *FontGlyph) SetSize(w, h int) {
fg.width, fg.height = w, h
}
// Size returns glyph's size
func (fg *FontGlyph) Size() (w, h int) {
return fg.width, fg.height
}
// Width returns font width
func (fg *FontGlyph) Width() int {
return fg.width
}
// Height returns glyph's height
func (fg *FontGlyph) Height() int {
return fg.height
}
// SetFrameIndex sets frame index to idx
func (fg *FontGlyph) SetFrameIndex(idx int) {
fg.frame = idx
}
// FrameIndex returns glyph's frame
func (fg *FontGlyph) FrameIndex() int {
return fg.frame
}
// Unknown1 returns unknowns bytes
func (fg *FontGlyph) Unknown1() []byte {
return []byte{0}
}
// Unknown2 returns unknowns bytes
func (fg *FontGlyph) Unknown2() []byte {
return []byte{1, 0, 0}
}
// Unknown3 returns unknowns bytes
func (fg *FontGlyph) Unknown3() []byte {
return []byte{0, 0, 0, 0}
}