aboutsummaryrefslogtreecommitdiff
path: root/cmd/bdf-sample
diff options
context:
space:
mode:
authorPřemysl Janouch <p@janouch.name>2019-04-14 22:30:40 +0200
committerPřemysl Janouch <p@janouch.name>2019-04-14 22:30:40 +0200
commit1331f3b5642f521236fcb1ec21ee43d5b76c0b91 (patch)
tree1213c2f2014cf0eff5a4a881b02cbebf91a604b8 /cmd/bdf-sample
parent7d9410c6b3a724e3670941f7ec2d00e7966d0b1a (diff)
downloadsklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.tar.gz
sklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.tar.xz
sklad-1331f3b5642f521236fcb1ec21ee43d5b76c0b91.zip
Move commands under cmd/
Diffstat (limited to 'cmd/bdf-sample')
-rw-r--r--cmd/bdf-sample/main.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/cmd/bdf-sample/main.go b/cmd/bdf-sample/main.go
new file mode 100644
index 0000000..1850118
--- /dev/null
+++ b/cmd/bdf-sample/main.go
@@ -0,0 +1,42 @@
+package main
+
+import (
+ "image"
+ "image/draw"
+ "image/png"
+ "log"
+ "os"
+
+ "janouch.name/sklad/bdf"
+)
+
+func main() {
+ fi, err := os.Open(os.Args[1])
+ if err != nil {
+ log.Fatalln(err)
+ }
+ defer fi.Close()
+ font, err := bdf.NewFromBDF(fi)
+ if err != nil {
+ log.Fatalln(err)
+ }
+
+ r, _ := font.BoundString(font.Name)
+ super := r.Inset(-20)
+
+ img := image.NewRGBA(super)
+ draw.Draw(img, super, image.White, image.ZP, draw.Src)
+ font.DrawString(img, image.ZP, font.Name)
+
+ fo, err := os.Create("out.png")
+ if err != nil {
+ log.Fatalln(err)
+ }
+ if err := png.Encode(fo, img); err != nil {
+ fo.Close()
+ log.Fatal(err)
+ }
+ if err := fo.Close(); err != nil {
+ log.Fatal(err)
+ }
+}