This repository has been archived on 2024-08-25. You can view files and clone it, but cannot push or open issues or pull requests.
2017-09-19 04:52:25 +01:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"bytes"
|
|
|
|
"fmt"
|
|
|
|
"go/format"
|
2017-09-19 06:12:03 +01:00
|
|
|
"io/ioutil"
|
|
|
|
"log"
|
2017-09-19 04:52:25 +01:00
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
// This program generates a go file for Comismsh font
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
src, err := ioutil.ReadFile("Comismsh.ttf")
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
buf := new(bytes.Buffer)
|
|
|
|
fmt.Fprint(buf, "// DO NOT EDIT. This file is generated.\n\n")
|
|
|
|
fmt.Fprint(buf, "package captcha\n\n")
|
|
|
|
fmt.Fprint(buf, "// The following is Comismsh TrueType font data.\n")
|
2017-09-19 07:10:49 +01:00
|
|
|
fmt.Fprint(buf, "var ttf = []byte{")
|
2017-09-19 04:52:25 +01:00
|
|
|
for i, x := range src {
|
|
|
|
if i&15 == 0 {
|
|
|
|
buf.WriteByte('\n')
|
|
|
|
}
|
|
|
|
fmt.Fprintf(buf, "%#02x,", x)
|
|
|
|
}
|
|
|
|
fmt.Fprint(buf, "\n}\n")
|
|
|
|
|
|
|
|
dst, err := format.Source(buf.Bytes())
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
if err := ioutil.WriteFile(filepath.Join("../", "font.go"), dst, 0666); err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
2017-09-19 06:12:03 +01:00
|
|
|
}
|