Skip to content

Commit

Permalink
Simplify font loading code by using MustAsset
Browse files Browse the repository at this point in the history
Use `MustAsset` function in order to simplify the font loading code section.
  • Loading branch information
HeavyWombat committed Feb 15, 2021
1 parent 5638dd1 commit d958508
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions internal/img/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,18 +68,12 @@ type Scaffold struct {
}

func NewImageCreator() Scaffold {
var loadFont = func(assetName string) *truetype.Font {
bytes, _ := Asset(assetName)
font, _ := truetype.Parse(bytes)
return font
}

f := 2.0

fontRegular := loadFont("Hack-Regular.ttf")
fontBold := loadFont("Hack-Bold.ttf")
fontItalic := loadFont("Hack-Italic.ttf")
fontBoldItalic := loadFont("Hack-BoldItalic.ttf")
fontRegular, _ := truetype.Parse(MustAsset("Hack-Regular.ttf"))
fontBold, _ := truetype.Parse(MustAsset("Hack-Bold.ttf"))
fontItalic, _ := truetype.Parse(MustAsset("Hack-Italic.ttf"))
fontBoldItalic, _ := truetype.Parse(MustAsset("Hack-BoldItalic.ttf"))
fontFaceOptions := &truetype.Options{Size: f * 12, DPI: 144}

cols, rows := term.GetTerminalSize()
Expand Down

0 comments on commit d958508

Please sign in to comment.