Skip to content

Commit

Permalink
Merge pull request #36 from mitas1/tffload-fix
Browse files Browse the repository at this point in the history
Fix loadTTF to use bindata file
  • Loading branch information
mskrip authored Jan 19, 2018
2 parents 6c90dfb + 4151a2e commit c78d83a
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (
"image"
"image/color"
_ "image/png"
"io/ioutil"
"os"

"github.com/faiface/pixel"
"github.com/faiface/pixel/imdraw"
Expand Down Expand Up @@ -53,18 +51,15 @@ func (circle *Circle) draw(imd *imdraw.IMDraw, position pixel.Vec) {
}

func loadTTF(path string, size float64) (font.Face, error) {
file, err := os.Open(path)
file, err := Asset(path)
if err != nil {
return nil, err
}
defer file.Close()

bytes, err := ioutil.ReadAll(file)
if err != nil {
return nil, err
}
buf := new(bytes.Buffer)
buf.Write(file)

font, err := truetype.Parse(bytes)
font, err := truetype.Parse(buf.Bytes())
if err != nil {
return nil, err
}
Expand Down

0 comments on commit c78d83a

Please sign in to comment.