Skip to content

Commit

Permalink
Adjustable font width cache
Browse files Browse the repository at this point in the history
  • Loading branch information
aarzilli committed Jul 24, 2018
1 parent d29231f commit 1d42e34
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,20 @@ func FontHeight(f font.Face) int {
}

var fontWidthCache *lru.Cache
var fontWidthCacheSize int

func init() {
fontWidthCacheSize = 256
fontWidthCache, _ = lru.New(256)
}

func ChangeFontWidthCache(size int) {
if size > fontWidthCacheSize {
fontWidthCacheSize = size
fontWidthCache, _ = lru.New(fontWidthCacheSize)
}
}

type fontWidthCacheKey struct {
f font.Face
string string
Expand Down

0 comments on commit 1d42e34

Please sign in to comment.