2019-04-06 21:31:11 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"image"
|
2021-06-09 23:16:50 +02:00
|
|
|
"image/color"
|
2019-04-06 21:31:11 +02:00
|
|
|
"image/draw"
|
|
|
|
"image/png"
|
|
|
|
"log"
|
|
|
|
"os"
|
2019-04-13 00:16:58 +02:00
|
|
|
|
|
|
|
"janouch.name/sklad/bdf"
|
2019-04-06 21:31:11 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
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)
|
2021-06-09 23:16:50 +02:00
|
|
|
font.DrawString(img, image.ZP, color.Black, font.Name)
|
2019-04-06 21:31:11 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|