mirror of
				https://github.com/KevinMidboe/motdGOi.git
				synced 2025-10-29 17:50:24 +00:00 
			
		
		
		
	Merge pull request #1 from sqshq/master
Add a public interface to load bindata fonts in addition to the built-in ones
This commit is contained in:
		@@ -122,14 +122,26 @@ func (fm *fontManager) loadBuildInFont() error {
 | 
				
			|||||||
		if err != nil {
 | 
							if err != nil {
 | 
				
			||||||
			return err
 | 
								return err
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
							// Load the font
 | 
				
			||||||
 | 
							err = fm.loadBindataFont(fontStr, name)
 | 
				
			||||||
 | 
							if err != nil {
 | 
				
			||||||
 | 
								return err
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						return nil
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Load a bindata font
 | 
				
			||||||
 | 
					func (fm *fontManager) loadBindataFont(fontBinary []byte, fontName string) error {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	// Get the font
 | 
						// Get the font
 | 
				
			||||||
		font, err := parseFontContent(string(fontStr))
 | 
						font, err := parseFontContent(string(fontBinary))
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		return err
 | 
							return err
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Register the font object in the fontLib
 | 
						// Register the font object in the fontLib
 | 
				
			||||||
		fm.fontLib[name] = font
 | 
						fm.fontLib[fontName] = font
 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -39,6 +39,11 @@ func (ar *AsciiRender) LoadFont(fontPath string) error {
 | 
				
			|||||||
	return ar.fontMgr.loadFontList(fontPath)
 | 
						return ar.fontMgr.loadFontList(fontPath)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// LoadBinDataFont loads provided font binary
 | 
				
			||||||
 | 
					func (ar *AsciiRender) LoadBindataFont(fontBinary []byte, fontName string) error {
 | 
				
			||||||
 | 
						return ar.fontMgr.loadBindataFont(fontBinary, fontName)
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Render renders a string with the default options
 | 
					// Render renders a string with the default options
 | 
				
			||||||
// Calls the RenderOpts method with a new RenderOptions object
 | 
					// Calls the RenderOpts method with a new RenderOptions object
 | 
				
			||||||
func (ar *AsciiRender) Render(str string) (string, error) {
 | 
					func (ar *AsciiRender) Render(str string) (string, error) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user