add a public interface to load bindata fonts in addition to the built in ones

This commit is contained in:
sqshq
2019-02-24 00:57:01 -05:00
parent 47ded4d170
commit 32e4469538
2 changed files with 21 additions and 4 deletions

View File

@@ -122,18 +122,30 @@ func (fm *fontManager) loadBuildInFont() error {
if err != nil {
return err
}
// Get the font
font, err := parseFontContent(string(fontStr))
// Load the font
err = fm.loadBinDataFont(string(fontStr), name)
if err != nil {
return err
}
// Register the font object in the fontLib
fm.fontLib[name] = font
}
return nil
}
// Load a bindata font
func (fm *fontManager) loadBinDataFont(fontStr string, fontName string) error {
// Get the font
font, err := parseFontContent(fontStr)
if err != nil {
return err
}
// Register the font object in the fontLib
fm.fontLib[fontName] = font
return nil
}
// Parse a font from a content string
// Used to load fonts from disk and the builtin fonts
func parseFontContent(cont string) (*font, error) {