tdf

package
v0.0.0-...-0803133 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2023 License: CC0-1.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Alignments       []TheDrawFontAlignment = []TheDrawFontAlignment{AlignLeft, AlignCenter, AlignRight}
	AlignmentStrings []string               = []string{"left", "center", "right"}
)
View Source
var (
	BuiltInFonts []*FontInfo
)
View Source
var BuiltinFontsFiles embed.FS
View Source
var TheDrawFontNotSupported = errors.New("Font type not supported. Only support Color types.")

Functions

This section is empty.

Types

type ColorPair

type ColorPair struct {
	color.Style
	ColorPair4
}

func NewColorPair8

func NewColorPair8(fg, bg uint8) *ColorPair

type ColorPair4

type ColorPair4 struct {
	Fg color.Color
	Bg color.Color
}

type ColorPairGroup

type ColorPairGroup struct {
	Pairs map[string]ColorPair
}

func (*ColorPairGroup) AddPair

func (cpg *ColorPairGroup) AddPair(cp *ColorPair)

func (*ColorPairGroup) Detail

func (cpg *ColorPairGroup) Detail() string

func (*ColorPairGroup) String

func (cpg *ColorPairGroup) String() string

type ColorPairRGB

type ColorPairRGB struct {
	// contains filtered or unexported fields
}

type FontInfo

type FontInfo struct {
	File, Path string
	FontDir    string
	BuiltIn    bool
}

func FindFont

func FindFont(font string) *FontInfo

func FindFonts

func FindFonts(font string) []*FontInfo

func GetFonts

func GetFonts(pat string) []*FontInfo

func NewFontInfo

func NewFontInfo(file, path string) *FontInfo

func SearchBuiltinFonts

func SearchBuiltinFonts(s string) []*FontInfo

type TheDrawFont

type TheDrawFont struct {
	Offset      int                       `bin:"-"`
	CharOffsets int                       `bin:"-"`
	MetaData    TheDrawFontMetaData       // `bin:"len:233"`
	Glyphs      []TheDrawFontCharacter    `bin:"-"` // `bin:"len:fontBlockSize"` //
	Space       TheDrawFontCharacter      `bin:"-"` // `bin:"len:fontBlockSize"` //
	Colors      *ColorPairGroup           `bin:"-"`
	Options     *TheDrawFontStringOptions `bin:"-"`
}

type TheDrawFontGlyphs []TheDrawFontCharacter

func (*TheDrawFont) Chars

func (tdf *TheDrawFont) Chars(inclMissing bool) string

func (*TheDrawFont) FillCharContent

func (tdf *TheDrawFont) FillCharContent(d *TheDrawFontCharacter) error

func (*TheDrawFont) HasChar

func (tdf *TheDrawFont) HasChar(char rune) (*TheDrawFontCharacter, bool)

func (*TheDrawFont) HasChars

func (tdf *TheDrawFont) HasChars(chars string) (string, bool)

func (*TheDrawFont) InfoString

func (tdf *TheDrawFont) InfoString() string

func (*TheDrawFont) NullTerminatedString

func (tdf *TheDrawFont) NullTerminatedString(r binstruct.Reader, d *TheDrawFontCharacter) error

func (*TheDrawFont) Print

func (tdf *TheDrawFont) Print(s string)

func (*TheDrawFont) ReadCharacters

func (tdf *TheDrawFont) ReadCharacters(r binstruct.Reader) error

func (*TheDrawFont) Render

func (tdf *TheDrawFont) Render(s string) string

func (*TheDrawFont) SetOptions

func (tdf *TheDrawFont) SetOptions(o func(*TheDrawFontStringOptions))

func (*TheDrawFont) Supported

func (tdf *TheDrawFont) Supported() bool

type TheDrawFontAlignment

type TheDrawFontAlignment int
const (
	AlignLeft TheDrawFontAlignment = iota + 1
	AlignCenter
	AlignRight
)

func (TheDrawFontAlignment) String

func (a TheDrawFontAlignment) String() string

type TheDrawFontCell

type TheDrawFontCell struct {
	Char      byte                `bin:"len:1"`
	Character string              `bin:"-"`
	Coloring  TheDrawFontColoring `bin:"-"`
}

func (*TheDrawFontCell) FixEncoding

func (tdfc *TheDrawFontCell) FixEncoding(b byte) rune

func (*TheDrawFontCell) GetCharacter

func (tdfc *TheDrawFontCell) GetCharacter(readByte byte, second bool)

type TheDrawFontCharacter

type TheDrawFontCharacter struct {
	Offset  uint32            `bin:"-"`
	Width   uint8             `bin:"len:1"`
	Height  uint8             `bin:"len:1"`
	Content []TheDrawFontCell `bin:"-"`
	Colors  []string          `bin:"-"`
}

func (*TheDrawFontCharacter) GetFor

func (tdfc *TheDrawFontCharacter) GetFor(row, col uint8) (string, string)

type TheDrawFontColoring

type TheDrawFontColoring struct {
	BgFg uint8      `bin:"len:1,ParseColor"`
	Bg   uint8      `bin:"-"`
	Fg   uint8      `bin:"-"`
	Pair *ColorPair `bin:"-"`
}

func (*TheDrawFontColoring) MakeColorPair

func (tdfc *TheDrawFontColoring) MakeColorPair(tdf *TheDrawFont) error

func (*TheDrawFontColoring) ParseColor

func (tdfc *TheDrawFontColoring) ParseColor(col uint8, tdf *TheDrawFont) error

type TheDrawFontFile

type TheDrawFontFile struct {
	FontInfo *FontInfo     `bin:"-"`
	FileSize int           `bin:"-"`
	Fonts    []TheDrawFont `bin:"ReadFonts"`
}

func LoadBuiltinFont

func LoadBuiltinFont(name string, efs *embed.FS) (*TheDrawFontFile, error)

func LoadFont

func LoadFont(fi *FontInfo) (*TheDrawFontFile, error)

func NewTheDrawFontFile

func NewTheDrawFontFile(fi *FontInfo) *TheDrawFontFile

func ParseFont

func ParseFont(file fs.File) (*TheDrawFontFile, error)

func (*TheDrawFontFile) GetAllFonts

func (tdff *TheDrawFontFile) GetAllFonts() []string

func (*TheDrawFontFile) GetFont

func (tdff *TheDrawFontFile) GetFont(f string) *TheDrawFont

func (*TheDrawFontFile) ParseFont

func (tdff *TheDrawFontFile) ParseFont(r binstruct.Reader, tdf *TheDrawFont) error

func (*TheDrawFontFile) ReadFonts

func (tdff *TheDrawFontFile) ReadFonts(r binstruct.Reader) error

func (*TheDrawFontFile) String

func (tdff *TheDrawFontFile) String() string

type TheDrawFontHeader

type TheDrawFontHeader struct {
}

type TheDrawFontMetaData

type TheDrawFontMetaData struct {
	Namelen  uint8  `bin:"len:1"`
	FontName string `bin:"len:12"`

	FontType      uint8    `bin:"len:1"` //outl block color
	FontSpacing   uint8    `bin:"len:1"`
	FontBlockSize uint16   `bin:"len:2"`
	CharList      []uint16 `bin:"len:94,[len:2]"`
	FontMaxHeight uint8    `bin:"-"`
	FontMaxWidth  uint8    `bin:"-"`
	// contains filtered or unexported fields
}

type TheDrawFontString

type TheDrawFontString struct {
	Text    string
	Font    *TheDrawFont
	Chars   []*TheDrawFontCharacter
	Output  strings.Builder
	Options *TheDrawFontStringOptions
}

func NewTheDrawFontString

func NewTheDrawFontString(font string) *TheDrawFontString

func NewTheDrawFontStringFont

func NewTheDrawFontStringFont(font *TheDrawFont) *TheDrawFontString

func NewTheDrawFontStringFontInfo

func NewTheDrawFontStringFontInfo(fontInfo *FontInfo) *TheDrawFontString

func (*TheDrawFontString) GetPadding

func (tdfs *TheDrawFontString) GetPadding() uint8

func (*TheDrawFontString) LoadFont

func (tdfs *TheDrawFontString) LoadFont(s string)

func (*TheDrawFontString) LoadFontFontInfo

func (tdfs *TheDrawFontString) LoadFontFontInfo(fi *FontInfo)

func (*TheDrawFontString) PrintRow

func (tdfs *TheDrawFontString) PrintRow(row int)

func (*TheDrawFontString) PrintString

func (tdfs *TheDrawFontString) PrintString(s string)

func (*TheDrawFontString) RenderString

func (tdfs *TheDrawFontString) RenderString(s string) string

type TheDrawFontStringOptions

type TheDrawFontStringOptions struct {
	Justify                              TheDrawFontAlignment
	Width, LineWidth                     uint16
	SpaceWidth, Padding, Height, Spacing uint8
	NoColor                              bool
}

func NewTheDrawFontStringOptions

func NewTheDrawFontStringOptions(font *TheDrawFont) *TheDrawFontStringOptions

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL