TheMathemagicians/sevenkeys/figlet/figlet.go

61 lines
1.1 KiB
Go
Raw Normal View History

2024-06-10 12:32:45 +00:00
package figlet
import (
2024-06-10 15:34:16 +00:00
"os"
"path/filepath"
2024-06-10 12:32:45 +00:00
"sevenkeys/constants"
2024-06-10 15:34:16 +00:00
"sevenkeys/logic"
2024-06-10 12:32:45 +00:00
"github.com/lukesampson/figlet/figletlib"
)
2024-06-10 15:34:16 +00:00
var (
FigletFontSlant *figletlib.Font
FigletFontTerm *figletlib.Font
)
func ReadFigletFonts() {
cwd, err := os.Getwd()
logic.Check(err)
fontsdir := filepath.Join(cwd, "fonts")
FigletFontSlant, err = figletlib.GetFontByName(fontsdir, "slant")
logic.Check(err)
FigletFontTerm, err = figletlib.GetFontByName(fontsdir, "term")
logic.Check(err)
}
func PrintMsgSlant(msg, alignment string) {
figletlib.PrintMsg(msg,
FigletFontSlant,
200,
FigletFontSlant.Settings(),
alignment)
}
func PrintMsgTerm(msg, alignment string) {
figletlib.PrintMsg(msg,
FigletFontTerm,
200,
FigletFontTerm.Settings(),
alignment)
}
2024-06-10 12:32:45 +00:00
func SprintMsgSlant(msg, alignment string) string {
return figletlib.SprintMsg(msg,
2024-06-10 15:34:16 +00:00
FigletFontSlant,
2024-06-10 12:32:45 +00:00
constants.WindowWidth,
2024-06-10 15:34:16 +00:00
FigletFontSlant.Settings(),
2024-06-10 12:32:45 +00:00
alignment)
}
func SprintMsgTerm(msg, alignment string) string {
return figletlib.SprintMsg(msg,
2024-06-10 15:34:16 +00:00
FigletFontTerm,
2024-06-10 12:32:45 +00:00
constants.WindowWidth,
2024-06-10 15:34:16 +00:00
FigletFontTerm.Settings(),
2024-06-10 12:32:45 +00:00
alignment)
}