set font location to homedir

This commit is contained in:
Camille Scholtz 2018-12-26 15:35:02 +01:00
parent 1dad89fe67
commit e4b37decfa
4 changed files with 15 additions and 11 deletions

2
bar.go

@ -193,7 +193,7 @@ func (bar *Bar) draw(block *Block) error {
})
// Draw the text.
d.Dot = fixed.P(x, bar.face.Metrics().Ascent.Ceil()+9)
d.Dot = fixed.P(x, 18)
d.DrawString(block.txt)
// Redraw the bar.

@ -41,17 +41,12 @@ func (bar *Bar) initBlock(name, txt string, w int, align rune, xoff int, bg,
block := new(Block)
block.txt = txt
block.x = bar.xsum
block.w = w
block.align = align
block.xoff = xoff
block.bg = bg
block.fg = fg
block.actions = map[string]func(){
"button1": func() {},
"button2": func() {},
@ -59,7 +54,6 @@ func (bar *Bar) initBlock(name, txt string, w int, align rune, xoff int, bg,
"button4": func() {},
"button5": func() {},
}
block.img = bar.img.SubImage(image.Rect(bar.xsum, 0, bar.xsum+w, bar.
h)).(*xgraphics.Image)

@ -226,8 +226,8 @@ func (bar *Bar) windowFun() {
txt = "?"
}
}
if len(txt) > 38 {
txt = txt[0:38] + "..."
if len(txt) > 34 {
txt = txt[0:34] + "..."
}
// Redraw block.

14
main.go

@ -1,9 +1,19 @@
package main
import "time"
import (
"path"
"time"
homedir "github.com/mitchellh/go-homedir"
)
func main() {
bar, err := initBar(0, 0, 1920, 29, "./vendor/font/cure.font")
hd, err := homedir.Dir()
if err != nil {
panic(err)
}
bar, err := initBar(0, 0, 1920, 29, path.Join(hd, ".fonts/plan9/cure.font"))
if err != nil {
panic(err)
}