Skip to content
Permalink
Browse files

change font

  • Loading branch information...
HenrySlawniak committed Sep 5, 2018
1 parent 5944d04 commit 19b95a1323b1a1d27fa4ba1bac9ba120a473503c
Showing with 10,294 additions and 19 deletions.
  1. +2 −1 Gopkg.lock
  2. +4 −0 Gopkg.toml
  3. BIN IBMPlexMono-Regular.ttf
  4. +14 −9 contactsheet.go
  5. +0 −9 main.go
  6. +10,274 −0 vendor/golang.org/x/image/font/gofont/gomono/data.go

Some generated files are not rendered by default. Learn more.

@@ -36,3 +36,7 @@
[prune]
go-tests = true
unused-packages = true

[[constraint]]
branch = "master"
name = "golang.org/x/image"
Binary file not shown.
@@ -25,6 +25,8 @@ import (
"fmt"
"github.com/go-playground/log"
"github.com/golang/freetype"
"github.com/golang/freetype/truetype"
"golang.org/x/image/font/gofont/gomono"
"image"
"image/color"
"image/draw"
@@ -45,8 +47,17 @@ const (
var (
text = image.Black
bg = image.NewUniform(color.RGBA{0xE0, 0xEB, 0xF5, 0xff})
font *truetype.Font
)

func init() {
var err error
font, err = freetype.ParseFont(gomono.TTF)
if err != nil {
log.Panic(err)
}
}

func generateContactSheet(vid *Video, numFrames int) {
var FrameWidth int
var FrameHeight int
@@ -89,12 +100,6 @@ func generateContactSheet(vid *Video, numFrames int) {

sheet := image.NewRGBA(image.Rect(0, 0, sheetWidth, sheetHeight))

font, err := freetype.ParseFont(fontBytes)
if err != nil {
log.Error(err)
return
}

draw.Draw(sheet, sheet.Bounds(), bg, image.ZP, draw.Src)
c := freetype.NewContext()
c.SetDPI(FontDPI)
@@ -106,7 +111,7 @@ func generateContactSheet(vid *Video, numFrames int) {

pt := freetype.Pt(10, 10+int(c.PointToFixed(FontSize)>>6))
for _, s := range vid.Filename {
_, err = c.DrawString(string(s), pt)
_, err := c.DrawString(string(s), pt)
if err != nil {
log.Error(err)
return
@@ -116,7 +121,7 @@ func generateContactSheet(vid *Video, numFrames int) {

pt = freetype.Pt(10, 20+FontSize+int(c.PointToFixed((FontSize))>>6))
for _, s := range "SHA1: " + vid.SHA1.Hex() {
_, err = c.DrawString(string(s), pt)
_, err := c.DrawString(string(s), pt)
if err != nil {
log.Error(err)
return
@@ -126,7 +131,7 @@ func generateContactSheet(vid *Video, numFrames int) {

pt = freetype.Pt(10, 60+FontSize+int(c.PointToFixed((FontSize))>>6))
for _, s := range fmt.Sprintf("Duration: %s, Dimmensions: %dx%d", stampToString(vid.Duration), vid.Width, vid.Height) {
_, err = c.DrawString(string(s), pt)
_, err := c.DrawString(string(s), pt)
if err != nil {
log.Error(err)
return
@@ -35,9 +35,7 @@ import (
var (
numFrames = flag.Int("frames", 12, "The number of frames to generate")
writeInfo = flag.Bool("write-info", true, "Write info JSON to file")
fontFile = flag.String("font-file", "IBMPlexMono-Regular.ttf", "The ttf font file to use")
frameWidth = flag.Int("frame-width", 854, "The width to generate thumbnails at")
fontBytes []byte
)

func init() {
@@ -54,13 +52,6 @@ func main() {
return
}

fontBytes, err = ioutil.ReadFile(*fontFile)
if err != nil {
log.Error("Error loading font")
log.Error(err)
return
}

for _, a := range os.Args[1:] {
if FileExists(a) {
f, err := os.Open(a)

0 comments on commit 19b95a1

Please sign in to comment.
You can’t perform that action at this time.