Skip to content

Instantly share code, notes, and snippets.

@hajimehoshi
Created February 18, 2018 14:50
Show Gist options
  • Save hajimehoshi/72e6982596f6ed2e6333dd778a87f752 to your computer and use it in GitHub Desktop.
Save hajimehoshi/72e6982596f6ed2e6333dd778a87f752 to your computer and use it in GitHub Desktop.
Red Text
package main
import (
"image/color"
"github.com/golang/freetype/truetype"
"github.com/hajimehoshi/ebiten"
"github.com/hajimehoshi/ebiten/text"
"golang.org/x/image/font"
"golang.org/x/image/font/gofont/goregular"
)
var regularFont font.Face
func init() {
tt, err := truetype.Parse(goregular.TTF)
if err != nil {
panic(err)
}
regularFont = truetype.NewFace(tt, &truetype.Options{
Size: 24,
DPI: 72,
Hinting: font.HintingFull,
})
if err != nil {
panic(err)
}
}
func update(screen *ebiten.Image) error {
screen.Fill(color.White)
text.Draw(screen, "dead", regularFont, 32, 32, color.RGBA{0x80, 0, 0, 0xff})
return nil
}
func main() {
if err := ebiten.Run(update, 640, 480, 1, "Font Test"); err != nil {
panic(err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment