aboutsummaryrefslogtreecommitdiff
path: root/sklad/db.go
diff options
context:
space:
mode:
Diffstat (limited to 'sklad/db.go')
-rw-r--r--sklad/db.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/sklad/db.go b/sklad/db.go
index aae695f..def18a5 100644
--- a/sklad/db.go
+++ b/sklad/db.go
@@ -7,6 +7,8 @@ import (
"os"
"strings"
"time"
+
+ "janouch.name/sklad/bdf"
)
type Series struct {
@@ -46,6 +48,9 @@ type Database struct {
Prefix string // prefix for all container IDs
Series []*Series // all known series
Containers []*Container // all known containers
+
+ BDFPath string // path to bitmap font file
+ BDFScale int // integer scaling for the bitmap font
}
var (
@@ -57,6 +62,8 @@ var (
indexSeries = map[string]*Series{}
indexContainer = map[ContainerId]*Container{}
indexChildren = map[ContainerId][]*Container{}
+
+ labelFont *bdf.Font
)
// TODO: Some functions to add, remove and change things in the database.
@@ -192,6 +199,20 @@ func loadDatabase() error {
}
}
+ // Prepare label printing.
+ if db.BDFScale <= 0 {
+ db.BDFScale = 1
+ }
+
+ if f, err := os.Open(db.BDFPath); err != nil {
+ return fmt.Errorf("cannot load label font: %s", err)
+ } else {
+ defer f.Close()
+ if labelFont, err = bdf.NewFromBDF(f); err != nil {
+ return fmt.Errorf("cannot load label font: %s", err)
+ }
+ }
+
// Open database log file for appending.
if dbLog, err = os.OpenFile(dbPath+".log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644); err != nil {