From 1331f3b5642f521236fcb1ec21ee43d5b76c0b91 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sun, 14 Apr 2019 22:30:40 +0200
Subject: Move commands under cmd/
---
bdf-preview/main.go | 93 -----------------------------------------------------
1 file changed, 93 deletions(-)
delete mode 100644 bdf-preview/main.go
(limited to 'bdf-preview')
diff --git a/bdf-preview/main.go b/bdf-preview/main.go
deleted file mode 100644
index b1f2045..0000000
--- a/bdf-preview/main.go
+++ /dev/null
@@ -1,93 +0,0 @@
-package main
-
-import (
- "html/template"
- "image"
- "image/draw"
- "image/png"
- "log"
- "net/http"
- "os"
-
- "janouch.name/sklad/bdf"
-)
-
-type fontItem struct {
- Font *bdf.Font
- Preview image.Image
-}
-
-var fonts = map[string]fontItem{}
-
-var tmpl = template.Must(template.New("list").Parse(`
-
-
-
-
- Name |
- Preview |
-
-{{range $k, $v := . }}
-
- {{$k}} |
- |
-
-{{end}}
-
-
-`))
-
-func handle(w http.ResponseWriter, r *http.Request) {
- if err := r.ParseForm(); err != nil {
- http.Error(w, err.Error(), 500)
- return
- }
-
- name := r.FormValue("name")
- if name == "" {
- w.Header().Set("Content-Type", "text/html")
- tmpl.Execute(w, fonts)
- return
- }
-
- item, ok := fonts[name]
- if !ok {
- http.Error(w, "No such font.", 400)
- return
- }
-
- w.Header().Set("Content-Type", "image/png")
- if err := png.Encode(w, item.Preview); err != nil {
- http.Error(w, err.Error(), 500)
- return
- }
-}
-
-func main() {
- for _, filename := range os.Args[1:] {
- fi, err := os.Open(filename)
- if err != nil {
- log.Fatalln(err)
- }
- font, err := bdf.NewFromBDF(fi)
- if err != nil {
- log.Fatalf("%s: %s\n", filename, err)
- }
- if err := fi.Close(); err != nil {
- log.Fatalln(err)
- }
-
- r, _ := font.BoundString(font.Name)
- super := r.Inset(-3)
-
- img := image.NewRGBA(super)
- draw.Draw(img, super, image.White, image.ZP, draw.Src)
- font.DrawString(img, image.ZP, font.Name)
-
- fonts[filename] = fontItem{Font: font, Preview: img}
- }
-
- log.Println("Starting server")
- http.HandleFunc("/", handle)
- log.Fatal(http.ListenAndServe(":8080", nil))
-}
--
cgit v1.2.3-70-g09d2