diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-04-27 19:34:38 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-04-27 19:34:38 +0900 |
| commit | 0c1be8adcc4773ceb6927b4f38d62539077f8cc8 (patch) | |
| tree | d46da59f87659e95fd5fa443deb33ab367f0e643 | |
| parent | 83754f16833766420cdca1f8527177dbc4b6ace1 (diff) | |
| download | term-banner-0c1be8adcc4773ceb6927b4f38d62539077f8cc8.tar.gz term-banner-0c1be8adcc4773ceb6927b4f38d62539077f8cc8.tar.zst term-banner-0c1be8adcc4773ceb6927b4f38d62539077f8cc8.zip | |
support gothic font
| -rw-r--r-- | README.md | 6 | ||||
| -rw-r--r-- | assets/misaki_gothic_2nd.png | bin | 0 -> 54790 bytes | |||
| -rw-r--r-- | main.go | 27 |
3 files changed, 25 insertions, 8 deletions
@@ -24,6 +24,12 @@ Multiple arguments are displayed in multiple lines. $ ./term-banner foo bar baz ``` +Switch font by `-f`: + +``` +$ ./term-banner -f gothic 'あいうえお' +``` + # Requirements diff --git a/assets/misaki_gothic_2nd.png b/assets/misaki_gothic_2nd.png Binary files differnew file mode 100644 index 0000000..2c80332 --- /dev/null +++ b/assets/misaki_gothic_2nd.png @@ -2,9 +2,9 @@ package main import ( "embed" + "flag" "image/png" "log" - "os" "github.com/gdamore/tcell/v2" "golang.org/x/text/encoding" @@ -204,7 +204,7 @@ func calcSquareSizeAndOffset(r *Renderer, banner Banner) (int, int, []int, int) squareW := scrW / gridWidthMax squareH := scrH / gridHeight if squareW > squareH*8 { - squareW = squareH*8 + squareW = squareH * 8 } if squareH > squareW { squareH = squareW @@ -348,14 +348,25 @@ func prepareFont(fileHW, fileFW string) (*Font, error) { } func main() { - if len(os.Args) <= 1 { + var fontType = flag.String("f", "mincho", "Font (mincho or gothic)") + flag.Parse() + var fontFileHW string + var fontFileFW string + if *fontType == "mincho" { + fontFileHW = "assets/misaki_gothic_2nd_4x8.png" + fontFileFW = "assets/misaki_mincho.png" + } else if *fontType == "gothic" { + fontFileHW = "assets/misaki_gothic_2nd_4x8.png" + fontFileFW = "assets/misaki_gothic_2nd.png" + } else { + log.Fatalf("Unknown font: %s", *fontType) + } + + if flag.NArg() == 0 { return } - font, err := prepareFont( - "assets/misaki_gothic_2nd_4x8.png", - "assets/misaki_mincho.png", - ) + font, err := prepareFont(fontFileHW, fontFileFW) if err != nil { log.Fatalf("%+v", err) } @@ -369,7 +380,7 @@ func main() { } defer r.Fini() - banner, err := NewBanner(os.Args[1:]) + banner, err := NewBanner(flag.Args()) if err != nil { log.Fatalf("%+v", err) } |
