package main
import (
"fmt"
"image/color"
"os"
"github.com/fogleman/gg"
"github.com/golang/freetype/truetype"
"golang.org/x/image/font/gofont/goregular"
)
const (
iconSize = 48
imageWidth = 512
imageHeight = 512
)
func main() {
dc := gg.NewContext(imageWidth, imageHeight)
dc.SetRGB(1, 1, 1)
dc.Clear()
font, err := truetype.Parse(goregular.TTF)
if err != nil {
fmt.Fprintln(os.Stderr, "Error parsing font:", err)
return
}
face := truetype.NewFace(font, &truetype.Options{
Size: iconSize,
})
dc.SetFontFace(face)
dc.SetRGB(0, 0, 0)
dc.DrawStringAnchored("A", imageWidth/2, imageHeight/2, 0.5, 0.5)
strokeColor := color.RGBA{0, 0, 0, 255}
strokeWidth := 2.0
dc.SetStrokeStyle(gg.NewSolidPattern(strokeColor))
dc.SetLineWidth(strokeWidth)
dc.Stroke()
dc.SavePNG("icon.png")
}