Skip to content

Instantly share code, notes, and snippets.

@sanmai
Created July 11, 2016 07:57
Show Gist options
  • Save sanmai/65650f199b7bd75f92968849929314e5 to your computer and use it in GitHub Desktop.
Save sanmai/65650f199b7bd75f92968849929314e5 to your computer and use it in GitHub Desktop.
Adds label to an image
package main
import (
"image"
"image/color"
"image/png"
"os"
"golang.org/x/image/font"
"golang.org/x/image/font/basicfont"
"golang.org/x/image/math/fixed"
)
func main() {
img := image.NewRGBA(image.Rect(0, 0, 320, 240))
x, y := 100, 100
point := fixed.Point26_6{fixed.Int26_6(x * 64), fixed.Int26_6(y * 64)}
d := &font.Drawer{
Dst: img,
Src: image.NewUniform(color.Black),
Face: basicfont.Face7x13,
Dot: point,
}
d.DrawString("Test 123")
png.Encode(os.Stdout, img)
}
@jaredchu
Copy link

Face7x13 is a fixed font, how to increase the font size?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment