mirror of
https://github.com/Crocmagnon/display-epaper.git
synced 2024-11-23 14:38:02 +01:00
22 lines
451 B
Go
22 lines
451 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"github.com/golang/freetype/truetype"
|
||
|
"github.com/llgcode/draw2d"
|
||
|
)
|
||
|
|
||
|
type MyFontCache map[string]*truetype.Font
|
||
|
|
||
|
func (fc MyFontCache) Store(fd draw2d.FontData, font *truetype.Font) {
|
||
|
fc[fd.Name] = font
|
||
|
}
|
||
|
|
||
|
func (fc MyFontCache) Load(fd draw2d.FontData) (*truetype.Font, error) {
|
||
|
font, stored := fc[fd.Name]
|
||
|
if !stored {
|
||
|
return nil, fmt.Errorf("font %s is not stored in font cache", fd.Name)
|
||
|
}
|
||
|
return font, nil
|
||
|
}
|