mirror of
https://github.com/KevinMidboe/motdGO.git
synced 2025-10-28 17:20:24 +00:00
readme changes, other default font, go-bindata for default font, little commenting
This commit is contained in:
25
.gitignore
vendored
25
.gitignore
vendored
@@ -1,25 +0,0 @@
|
||||
# Compiled Object files, Static and Dynamic libs (Shared Objects)
|
||||
*.o
|
||||
*.a
|
||||
*.so
|
||||
|
||||
# Folders
|
||||
_obj
|
||||
_test
|
||||
|
||||
# Architecture specific extensions/prefixes
|
||||
*.[568vq]
|
||||
[568vq].out
|
||||
|
||||
*.cgo1.go
|
||||
*.cgo2.c
|
||||
_cgo_defun.c
|
||||
_cgo_gotypes.go
|
||||
_cgo_export.*
|
||||
|
||||
_testmain.go
|
||||
|
||||
*.exe
|
||||
|
||||
tags
|
||||
*.test
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 getwe
|
||||
Copyright (c) 2014 getwe, 2016 probandula
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
|
||||
50
README.md
50
README.md
@@ -1,32 +1,34 @@
|
||||
# figlet4go
|
||||
_______ __ _______ __ _______ .___________. _ _ _______ ______
|
||||
| ____|| | / _____|| | | ____|| || || | / _____| / __ \
|
||||
| |__ | | | | __ | | | |__ `---| |----`| || |_ | | __ | | | |
|
||||
| __| | | | | |_ | | | | __| | | |__ _| | | |_ | | | | |
|
||||
| | | | | |__| | | `----.| |____ | | | | | |__| | | `--' |
|
||||
|__| |__| \______| |_______||_______| |__| |_| \______| \______/
|
||||
# FIGlet for Go
|
||||
|
||||
A port of [figlet](http://www.figlet.org/) to golang.
|
||||
Make it easier to use,add some new feature such as colorized outputs.
|
||||
**Currently in Development.
|
||||
Sould work but will be improved (add demos, better font adding, maybe better performance, more default fonts)**
|
||||
|
||||
A port of [figlet](http://www.figlet.org/) to golang and fork of [getwe/figlet4go](https://github.com/getwe/figlet4go).
|
||||
|
||||

|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
go get -u github.com/probandula/figlet4go
|
||||
```
|
||||
|
||||
## Usage
|
||||
```go
|
||||
// Create the renderer
|
||||
ascii := figlet4go.NewAsciiRender()
|
||||
|
||||
// Optional: Add color to the letters (https://github.com/fatih/color needed)
|
||||
|
||||
### Install
|
||||
|
||||
```
|
||||
go get -u github.com/getwe/figlet4go
|
||||
// Render and print the string
|
||||
renderStr, _ := ascii.Render("Hello World")
|
||||
fmt.Print(renderStr)
|
||||
```
|
||||
|
||||
### Demo
|
||||
## Default font
|
||||
The default font is built into the `bindata.go` file with the tool [go-bindata](https://github.com/jteeuwen/go-bindata).
|
||||
The bash script for building the default font is stored in `tools/` (`go-bindata` must be installed).
|
||||
|
||||
```
|
||||
cd demo/
|
||||
go build
|
||||
./demo -str="golang"
|
||||
#Maybe you have to `brew install figlet` if you need 3D fond in mac osx.
|
||||
```
|
||||
|
||||
see details in `demo/demo.go` .
|
||||
|
||||

|
||||
## Use the demo
|
||||
There are [demo](https://github.com/probandula/figlet4go/blob/master/demo) programs for trying out the library.
|
||||
To run them, `cd` into the `demo/` directory and run `go run [filename]` on any program you want to run.
|
||||
2227
assets/standard.flf
Normal file
2227
assets/standard.flf
Normal file
File diff suppressed because it is too large
Load Diff
235
bindata.go
Normal file
235
bindata.go
Normal file
File diff suppressed because one or more lines are too long
722
buildinfont.go
722
buildinfont.go
@@ -1,722 +0,0 @@
|
||||
package figlet4go
|
||||
|
||||
// Build in source font from starwars.flf
|
||||
const builtInFont = `flf2a$ 7 6 22 15 4
|
||||
starwars.flf by Ryan Youck (youck@cs.uregina.ca) Dec 25/1994
|
||||
I am not responsible for use of this font
|
||||
Based on Big.flf by Glenn Chappell
|
||||
|
||||
$ $@
|
||||
$ $@
|
||||
$ $@
|
||||
$ $@
|
||||
$ $@
|
||||
$ $@
|
||||
$ $@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
|__|$@
|
||||
(__)$@
|
||||
$@@
|
||||
_ _ @
|
||||
( | )@
|
||||
V V @
|
||||
$ @
|
||||
$ @
|
||||
$ @
|
||||
@@
|
||||
_ _ @
|
||||
_| || |_$@
|
||||
|_ __ _|@
|
||||
_| || |_ @
|
||||
|_ __ _|@
|
||||
|_||_| $@
|
||||
@@
|
||||
__,--,_.@
|
||||
/ |@
|
||||
| (----` + "`@" + `
|
||||
\ \ $@
|
||||
.----) | $@
|
||||
|_ __/ $@
|
||||
'--' $@@
|
||||
_ ___$ @
|
||||
/ \ / /$ @
|
||||
( o ) / / $ @
|
||||
\_/ / / _$ @
|
||||
/ / / \ @
|
||||
/ / ( o )@
|
||||
/__/ \_/ @@
|
||||
@
|
||||
___ @
|
||||
( _ ) $@
|
||||
/ _ \/\@
|
||||
| (_> <@
|
||||
\___/\/@
|
||||
$@@
|
||||
__ @
|
||||
(_ )@
|
||||
|/ @
|
||||
$ @
|
||||
$ @
|
||||
$ @
|
||||
@@
|
||||
___@
|
||||
/ /@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
\__\@@
|
||||
___ @
|
||||
\ \ @
|
||||
| |@
|
||||
| |@
|
||||
| |@
|
||||
| |@
|
||||
/__/ @@
|
||||
_ @
|
||||
/\| |/\ @
|
||||
\ ` + "`" + ` ' /$@
|
||||
|_ _|@
|
||||
/ , . \$@
|
||||
\/|_|\/ @
|
||||
@@
|
||||
@
|
||||
_ @
|
||||
_| |_$@
|
||||
|_ _|@
|
||||
|_| $@
|
||||
$ @
|
||||
@@
|
||||
@
|
||||
@
|
||||
$ @
|
||||
$ @
|
||||
__ @
|
||||
(_ )@
|
||||
|/ @@
|
||||
@
|
||||
@
|
||||
______ @
|
||||
|______|@
|
||||
$ @
|
||||
$ @
|
||||
@@
|
||||
@
|
||||
@
|
||||
@
|
||||
$ @
|
||||
__ @
|
||||
(__)@
|
||||
@@
|
||||
___@
|
||||
/ /@
|
||||
/ / @
|
||||
/ /$ @
|
||||
/ /$ @
|
||||
/__/$ @
|
||||
@@
|
||||
___ $@
|
||||
/ _ \ $@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| |_| |$@
|
||||
\___/ $@
|
||||
$@@
|
||||
__ $@
|
||||
/_ |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
|_|$@
|
||||
$@@
|
||||
___ $@
|
||||
|__ \ $@
|
||||
$) |$@
|
||||
/ / $@
|
||||
/ /_ $@
|
||||
|____|$@
|
||||
$@@
|
||||
____ $@
|
||||
|___ \ $@
|
||||
__) |$@
|
||||
|__ < $@
|
||||
___) |$@
|
||||
|____/ $@
|
||||
$@@
|
||||
_ _ $@
|
||||
| || | $@
|
||||
| || |_ $@
|
||||
|__ _|$@
|
||||
| | $@
|
||||
|_| $@
|
||||
$@@
|
||||
_____ $@
|
||||
| ____|$@
|
||||
| |__ $@
|
||||
|___ \ $@
|
||||
___) |$@
|
||||
|____/ $@
|
||||
$@@
|
||||
__ $@
|
||||
/ / $@
|
||||
/ /_ $@
|
||||
| '_ \ $@
|
||||
| (_) |$@
|
||||
\___/ $@
|
||||
$@@
|
||||
______ $@
|
||||
|____ |$@
|
||||
$/ / $@
|
||||
/ / $@
|
||||
/ / $@
|
||||
/_/ $@
|
||||
$@@
|
||||
___ $@
|
||||
/ _ \ $@
|
||||
| (_) |$@
|
||||
> _ < $@
|
||||
| (_) |$@
|
||||
\___/ $@
|
||||
$@@
|
||||
___ $@
|
||||
/ _ \ $@
|
||||
| (_) |$@
|
||||
\__, |$@
|
||||
/ / $@
|
||||
/_/ $@
|
||||
$@@
|
||||
@
|
||||
_ @
|
||||
(_)@
|
||||
$ @
|
||||
_ @
|
||||
(_)@
|
||||
@@
|
||||
@
|
||||
_ @
|
||||
(_)@
|
||||
$ @
|
||||
_ @
|
||||
( )@
|
||||
|/ @@
|
||||
___@
|
||||
/ /@
|
||||
/ /$@
|
||||
< <$ @
|
||||
\ \$@
|
||||
\__\@
|
||||
@@
|
||||
@
|
||||
______ @
|
||||
|______|@
|
||||
______ @
|
||||
|______|@
|
||||
@
|
||||
@@
|
||||
___ @
|
||||
\ \$ @
|
||||
\ \ @
|
||||
> >@
|
||||
/ / @
|
||||
/__/$ @
|
||||
@@
|
||||
______ $@
|
||||
| \ $@
|
||||
` + "`" + `----) |$@
|
||||
/ / $@
|
||||
|__| $@
|
||||
__ $@
|
||||
(__) $@@
|
||||
____ @
|
||||
/ __ \ @
|
||||
/ / _` + "`" + ` |@
|
||||
| | (_| |@
|
||||
\ \__,_|@
|
||||
\____/ @
|
||||
@@
|
||||
___ $ @
|
||||
/ \ $ @
|
||||
/ ^ \$ @
|
||||
/ /_\ \$ @
|
||||
/ _____ \$ @
|
||||
/__/ \__\$@
|
||||
$@@
|
||||
.______ $@
|
||||
| _ \ $@
|
||||
| |_) |$@
|
||||
| _ < $@
|
||||
| |_) |$@
|
||||
|______/ $@
|
||||
$@@
|
||||
______$@
|
||||
/ |@
|
||||
| ,----'@
|
||||
| | $@
|
||||
| ` + "`" + `----.@
|
||||
\______|@
|
||||
$@@
|
||||
_______ $@
|
||||
| \$@
|
||||
| .--. |@
|
||||
| | | |@
|
||||
| '--' |@
|
||||
|_______/$@
|
||||
$@@
|
||||
_______ @
|
||||
| ____|@
|
||||
| |__ $@
|
||||
| __| $@
|
||||
| |____ @
|
||||
|_______|@
|
||||
@@
|
||||
_______ @
|
||||
| ____|@
|
||||
| |__ $@
|
||||
| __| $@
|
||||
| | $ @
|
||||
|__| @
|
||||
@@
|
||||
_______ @
|
||||
/ _____|@
|
||||
| | __ $@
|
||||
| | |_ |$@
|
||||
| |__| |$@
|
||||
\______|$@
|
||||
$@@
|
||||
__ __ $@
|
||||
| | | |$@
|
||||
| |__| |$@
|
||||
| __ |$@
|
||||
| | | |$@
|
||||
|__| |__|$@
|
||||
$@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
|__|$@
|
||||
$@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
.--. | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
__ ___$@
|
||||
| |/ /$@
|
||||
| ' / $@
|
||||
| < $@
|
||||
| . \ $@
|
||||
|__|\__\$@
|
||||
$@@
|
||||
__ $@
|
||||
| | $@
|
||||
| | $@
|
||||
| | $@
|
||||
| ` + "`" + `----.@
|
||||
|_______|@
|
||||
$@@
|
||||
.___ ___.$@
|
||||
| \/ |$@
|
||||
| \ / |$@
|
||||
| |\/| |$@
|
||||
| | | |$@
|
||||
|__| |__|$@
|
||||
$@@
|
||||
.__ __.$@
|
||||
| \ | |$@
|
||||
| \| |$@
|
||||
| . ` + "`" + ` |$@
|
||||
| |\ |$@
|
||||
|__| \__|$@
|
||||
$@@
|
||||
______ $@
|
||||
/ __ \ $@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
.______ $@
|
||||
| _ \ $@
|
||||
| |_) |$@
|
||||
| ___/ $@
|
||||
| | $ @
|
||||
| _| $ @
|
||||
$ @@
|
||||
______ $ @
|
||||
/ __ \ $ @
|
||||
| | | | $ @
|
||||
| | | | $ @
|
||||
| ` + "`" + `--' '--. @
|
||||
\_____\_____\@
|
||||
$ @@
|
||||
.______ $ @
|
||||
| _ \ $ @
|
||||
| |_) | $ @
|
||||
| / $ @
|
||||
| |\ \----.@
|
||||
| _| ` + "`" + `._____|@
|
||||
$@@
|
||||
_______.@
|
||||
/ |@
|
||||
| (----` + "`" + `@
|
||||
\ \ $@
|
||||
.----) | $@
|
||||
|_______/ $@
|
||||
$@@
|
||||
.___________.@
|
||||
| |@
|
||||
` + "`" + `---| |----` + "`" + `@
|
||||
| | $ @
|
||||
| | $ @
|
||||
|__| $ @
|
||||
$ @@
|
||||
__ __ $@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
____ ____$@
|
||||
\ \ / /$@
|
||||
\ \/ /$ @
|
||||
\ /$ @
|
||||
\ /$ @
|
||||
\__/$ @
|
||||
$ @@
|
||||
____ __ ____$@
|
||||
\ \ / \ / /$@
|
||||
\ \/ \/ /$ @
|
||||
\ /$ @
|
||||
\ /\ /$ @
|
||||
\__/ \__/$ @
|
||||
$ @@
|
||||
___ ___$@
|
||||
\ \ / /$@
|
||||
\ V / $@
|
||||
> < $@
|
||||
/ . \ $@
|
||||
/__/ \__\$@
|
||||
$@@
|
||||
____ ____$@
|
||||
\ \ / /$@
|
||||
\ \/ /$ @
|
||||
\_ _/$ @
|
||||
| |$ @
|
||||
|__|$ @
|
||||
$ @@
|
||||
________ $@
|
||||
| / $@
|
||||
` + "`" + `---/ / $@
|
||||
/ / $@
|
||||
/ /----.@
|
||||
/________|@
|
||||
$@@
|
||||
____ @
|
||||
| |@
|
||||
| |-` + "`" + `@
|
||||
| | $@
|
||||
| | $@
|
||||
| |-.@
|
||||
|____|@@
|
||||
___ @
|
||||
\ \ $ @
|
||||
\ \$ @
|
||||
\ \$ @
|
||||
\ \$@
|
||||
\__\@
|
||||
@@
|
||||
____ @
|
||||
| |@
|
||||
` + "`" + `-| |@
|
||||
| |@
|
||||
| |@
|
||||
.-| |@
|
||||
|____|@@
|
||||
___ @
|
||||
/ \ @
|
||||
/--^--\@
|
||||
$@
|
||||
$@
|
||||
$@
|
||||
$@@
|
||||
@
|
||||
@
|
||||
@
|
||||
$ @
|
||||
$ @
|
||||
______ @
|
||||
|______|@@
|
||||
__ @
|
||||
( _)@
|
||||
\| @
|
||||
$ @
|
||||
$ @
|
||||
$ @
|
||||
@@
|
||||
___ $ @
|
||||
/ \ $ @
|
||||
/ ^ \$ @
|
||||
/ /_\ \$ @
|
||||
/ _____ \$ @
|
||||
/__/ \__\$@
|
||||
$@@
|
||||
.______ $@
|
||||
| _ \ $@
|
||||
| |_) |$@
|
||||
| _ < $@
|
||||
| |_) |$@
|
||||
|______/ $@
|
||||
$@@
|
||||
______$@
|
||||
/ |@
|
||||
| ,----'@
|
||||
| | $@
|
||||
| ` + "`" + `----.@
|
||||
\______|@
|
||||
$@@
|
||||
_______ $@
|
||||
| \$@
|
||||
| .--. |@
|
||||
| | | |@
|
||||
| '--' |@
|
||||
|_______/$@
|
||||
$@@
|
||||
_______ @
|
||||
| ____|@
|
||||
| |__ $@
|
||||
| __| $@
|
||||
| |____ @
|
||||
|_______|@
|
||||
@@
|
||||
_______ @
|
||||
| ____|@
|
||||
| |__ $@
|
||||
| __| $@
|
||||
| | $ @
|
||||
|__| @
|
||||
@@
|
||||
_______ @
|
||||
/ _____|@
|
||||
| | __ $@
|
||||
| | |_ |$@
|
||||
| |__| |$@
|
||||
\______|$@
|
||||
$@@
|
||||
__ __ $@
|
||||
| | | |$@
|
||||
| |__| |$@
|
||||
| __ |$@
|
||||
| | | |$@
|
||||
|__| |__|$@
|
||||
$@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
|__|$@
|
||||
$@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
.--. | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
__ ___$@
|
||||
| |/ /$@
|
||||
| ' / $@
|
||||
| < $@
|
||||
| . \ $@
|
||||
|__|\__\$@
|
||||
$@@
|
||||
__ $@
|
||||
| | $@
|
||||
| | $@
|
||||
| | $@
|
||||
| ` + "`" + `----.@
|
||||
|_______|@
|
||||
$@@
|
||||
.___ ___.$@
|
||||
| \/ |$@
|
||||
| \ / |$@
|
||||
| |\/| |$@
|
||||
| | | |$@
|
||||
|__| |__|$@
|
||||
$@@
|
||||
.__ __.$@
|
||||
| \ | |$@
|
||||
| \| |$@
|
||||
| . ` + "`" + ` |$@
|
||||
| |\ |$@
|
||||
|__| \__|$@
|
||||
$@@
|
||||
______ $@
|
||||
/ __ \ $@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
.______ $@
|
||||
| _ \ $@
|
||||
| |_) |$@
|
||||
| ___/ $@
|
||||
| | $ @
|
||||
| _| $ @
|
||||
$ @@
|
||||
______ $ @
|
||||
/ __ \ $ @
|
||||
| | | | $ @
|
||||
| | | | $ @
|
||||
| ` + "`" + `--' '--. @
|
||||
\_____\_____\@
|
||||
$ @@
|
||||
.______ $ @
|
||||
| _ \ $ @
|
||||
| |_) | $ @
|
||||
| / $ @
|
||||
| |\ \----.@
|
||||
| _| ` + "`" + `._____|@
|
||||
$@@
|
||||
_______.@
|
||||
/ |@
|
||||
| (----` + "`" + `@
|
||||
\ \ $@
|
||||
.----) | $@
|
||||
|_______/ $@
|
||||
$@@
|
||||
.___________.@
|
||||
| |@
|
||||
` + "`" + `---| |----` + "`" + `@
|
||||
| | $ @
|
||||
| | $ @
|
||||
|__| $ @
|
||||
$ @@
|
||||
__ __ $@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| | | |$@
|
||||
| ` + "`" + `--' |$@
|
||||
\______/ $@
|
||||
$@@
|
||||
____ ____$@
|
||||
\ \ / /$@
|
||||
\ \/ /$ @
|
||||
\ /$ @
|
||||
\ /$ @
|
||||
\__/$ @
|
||||
$ @@
|
||||
____ __ ____$@
|
||||
\ \ / \ / /$@
|
||||
\ \/ \/ /$ @
|
||||
\ /$ @
|
||||
\ /\ /$ @
|
||||
\__/ \__/$ @
|
||||
$ @@
|
||||
___ ___$@
|
||||
\ \ / /$@
|
||||
\ V / $@
|
||||
> < $@
|
||||
/ . \ $@
|
||||
/__/ \__\$@
|
||||
$@@
|
||||
____ ____$@
|
||||
\ \ / /$@
|
||||
\ \/ /$ @
|
||||
\_ _/$ @
|
||||
| |$ @
|
||||
|__|$ @
|
||||
$ @@
|
||||
________ $@
|
||||
| / $@
|
||||
` + "`" + `---/ / $@
|
||||
/ / $@
|
||||
/ /----.@
|
||||
/________|@
|
||||
$@@
|
||||
___@
|
||||
/ /@
|
||||
| |$@
|
||||
/ /$ @
|
||||
\ \$ @
|
||||
| |$@
|
||||
\__\@@
|
||||
__ $@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
| |$@
|
||||
|__|$@@
|
||||
___ @
|
||||
\ \$ @
|
||||
| | @
|
||||
\ \@
|
||||
/ /@
|
||||
| | @
|
||||
/__/$ @@
|
||||
__ _ @
|
||||
/ \/ |@
|
||||
|_/\__/ @
|
||||
$ @
|
||||
$ @
|
||||
$ @
|
||||
@@
|
||||
_ _ @
|
||||
(_)_(_) @
|
||||
/ \ @
|
||||
/ _ \ @
|
||||
/ ___ \ @
|
||||
/_/ \_\@
|
||||
@@
|
||||
_ _ @
|
||||
(_)_(_)@
|
||||
/ _ \ @
|
||||
| | | |@
|
||||
| |_| |@
|
||||
\___/ @
|
||||
@@
|
||||
_ _ @
|
||||
(_) (_)@
|
||||
| | | |@
|
||||
| | | |@
|
||||
| |_| |@
|
||||
\___/ @
|
||||
@@
|
||||
_ _ @
|
||||
(_) (_)@
|
||||
__ _ @
|
||||
/ _` + "`" + ` |@
|
||||
| (_| |@
|
||||
\__,_|@
|
||||
@@
|
||||
_ _ @
|
||||
(_) (_)@
|
||||
___ @
|
||||
/ _ \ @
|
||||
| (_) |@
|
||||
\___/ @
|
||||
@@
|
||||
_ _ @
|
||||
(_) (_)@
|
||||
_ _ @
|
||||
| | | |@
|
||||
| |_| |@
|
||||
\__,_|@
|
||||
@@
|
||||
___ @
|
||||
/ _ \ @
|
||||
| | ) |@
|
||||
| |< < @
|
||||
| | ) |@
|
||||
| ||_/ @
|
||||
|_| @@`
|
||||
1
demo/colored.go
Normal file
1
demo/colored.go
Normal file
@@ -0,0 +1 @@
|
||||
package main
|
||||
22
demo/default.go
Normal file
22
demo/default.go
Normal file
@@ -0,0 +1,22 @@
|
||||
// Print a simple string with the 'standard' figlet font
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/probandula/figlet4go"
|
||||
)
|
||||
|
||||
// String to be printed
|
||||
const str string = "Default"
|
||||
|
||||
func main() {
|
||||
// Create the renderer
|
||||
ascii := figlet4go.NewAsciiRender()
|
||||
|
||||
// Render the string
|
||||
renderStr, _ := ascii.Render(str)
|
||||
|
||||
// Print the string
|
||||
fmt.Print(renderStr)
|
||||
}
|
||||
49
demo/demo.go
49
demo/demo.go
@@ -1,49 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"github.com/fatih/color"
|
||||
"github.com/getwe/figlet4go"
|
||||
)
|
||||
|
||||
var flag_str = flag.String("str", "golang", "input string")
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
str := *flag_str
|
||||
ascii := figlet4go.NewAsciiRender()
|
||||
// most simple Usage
|
||||
renderStr, _ := ascii.Render(str)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
// change the font color
|
||||
colors := [...]color.Attribute{
|
||||
color.FgMagenta,
|
||||
color.FgYellow,
|
||||
color.FgBlue,
|
||||
color.FgCyan,
|
||||
color.FgRed,
|
||||
color.FgWhite,
|
||||
}
|
||||
options := figlet4go.NewRenderOptions()
|
||||
options.FontColor = make([]color.Attribute, len(str))
|
||||
for i := range options.FontColor {
|
||||
options.FontColor[i] = colors[i%len(colors)]
|
||||
}
|
||||
renderStr, _ = ascii.RenderOpts(str, options)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
// change the font
|
||||
options.FontName = "larry3d"
|
||||
// except the default font,others need to be load from disk
|
||||
// here is the font :
|
||||
// ftp://ftp.figlet.org/pub/figlet/fonts/contributed.tar.gz
|
||||
// ftp://ftp.figlet.org/pub/figlet/fonts/international.tar.gz
|
||||
// download and extract to the disk,then specify the file path to load
|
||||
ascii.LoadFont("/usr/local/Cellar/figlet/2.2.5/share/figlet/fonts/")
|
||||
|
||||
renderStr, _ = ascii.RenderOpts(str, options)
|
||||
fmt.Println(renderStr)
|
||||
|
||||
}
|
||||
5
demo/otherfont.go
Normal file
5
demo/otherfont.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
||||
21
font.go
21
font.go
@@ -9,20 +9,22 @@ import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Represents a single font
|
||||
type font struct {
|
||||
hardblank string
|
||||
height int
|
||||
fontSlice []string
|
||||
}
|
||||
|
||||
// Holds the fonts
|
||||
type fontManager struct {
|
||||
// font library
|
||||
// Font libraries
|
||||
fontLib map[string]*font
|
||||
|
||||
// font name to path
|
||||
// Font name to path
|
||||
fontList map[string]string
|
||||
}
|
||||
|
||||
// Create new fontmanager
|
||||
func newFontManager() *fontManager {
|
||||
this := &fontManager{}
|
||||
|
||||
@@ -33,7 +35,7 @@ func newFontManager() *fontManager {
|
||||
return this
|
||||
}
|
||||
|
||||
// walk through the path, load all the *.flf font file
|
||||
// Load all font *.flf files in the fontPath recursivly
|
||||
func (this *fontManager) loadFont(fontPath string) error {
|
||||
|
||||
return filepath.Walk(fontPath, func(path string, info os.FileInfo, err error) error {
|
||||
@@ -51,8 +53,14 @@ func (this *fontManager) loadFont(fontPath string) error {
|
||||
})
|
||||
}
|
||||
|
||||
// Load the default font
|
||||
func (this *fontManager) loadBuildInFont() error {
|
||||
font, err := this.parseFontContent(builtInFont)
|
||||
fontStr, err := Asset("standard.flf")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
font, err := this.parseFontContent(string(fontStr))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -60,6 +68,7 @@ func (this *fontManager) loadBuildInFont() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Load a font from disk
|
||||
func (this *fontManager) loadDiskFont(fontName string) error {
|
||||
|
||||
fontFilePath, ok := this.fontList[fontName]
|
||||
@@ -82,6 +91,7 @@ func (this *fontManager) loadDiskFont(fontName string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Parse a font from a content string
|
||||
func (this *fontManager) parseFontContent(cont string) (*font, error) {
|
||||
lines := strings.Split(cont, "\n")
|
||||
if len(lines) < 1 {
|
||||
@@ -113,6 +123,7 @@ func (this *fontManager) parseFontContent(cont string) (*font, error) {
|
||||
return font, nil
|
||||
}
|
||||
|
||||
// Get a font by name
|
||||
func (this *fontManager) getFont(fontName string) (*font, error) {
|
||||
font, ok := this.fontLib[fontName]
|
||||
if !ok {
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 87 KiB |
BIN
screenshot/figlet4go.png
Normal file
BIN
screenshot/figlet4go.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.0 KiB |
4
tools/build-default-font.sh
Executable file
4
tools/build-default-font.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build the bindata.go file with the default font in it
|
||||
cd ../assets
|
||||
go-bindata -o ../bindata.go -pkg figlet4go ./
|
||||
Reference in New Issue
Block a user