diff options
author | Nick White <git@njw.name> | 2019-10-31 17:57:41 +0000 |
---|---|---|
committer | Nick White <git@njw.name> | 2019-10-31 17:57:41 +0000 |
commit | 64983a29e380a04eaf1b730e54cfe6f3399809f1 (patch) | |
tree | 587cf646b8b2dc19dd300a7b58257d85f6f674b4 /cmd/fonttobytes | |
parent | b9aeada4e573643985d6df03f672f2c2fec169d8 (diff) |
Add capability to embed font files into tool
Diffstat (limited to 'cmd/fonttobytes')
-rw-r--r-- | cmd/fonttobytes/main.go | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmd/fonttobytes/main.go b/cmd/fonttobytes/main.go new file mode 100644 index 0000000..9db47e4 --- /dev/null +++ b/cmd/fonttobytes/main.go @@ -0,0 +1,32 @@ +package main + +import ( + "flag" + "fmt" + "io/ioutil" + "log" + "strings" +) + +func main() { + flag.Usage = func() { + fmt.Fprintln(flag.CommandLine.Output(), "Usage: fonttobytes font.ttf") + flag.PrintDefaults() + } + flag.Parse() + + if flag.NArg() != 1 { + flag.Usage() + return + } + + b, err := ioutil.ReadFile(flag.Arg(0)) + if err != nil { + log.Fatalln(err) + } + s := fmt.Sprintf("%v", b) + s1 := strings.Replace(s, "[", "{", -1) + s2 := strings.Replace(s1, "]", "}", -1) + s3 := strings.Replace(s2, " ", ", ", -1) + fmt.Printf("[]byte%s\n", s3) +} |