Korok.io

Font

Fonts are used to render TextComp and text/shape in GUI system. Korok supports font files in TrueType or BMFont format.

Create a font

Suppose that we have font files in project:

                        
➜  tree demo/assets 
assets
├── font.json
├── font.png
└── honokamin.ttf
                        

To create font, use default FontManager:

                        
func (m *MainScene) Load() {
    asset.Font.LoadBitmap("font1", "font.png", "font.json")
    asset.Font.LoadTrueType("font2", "honokamin.ttf")
}
                        

Render Text

A simple use case in GUI system:

                        
font, _ := asset.Font.Get("font1")
gui.SetFont(font)

// draw text
gui.Text(1, gui.Rect{}, "The quick brown fox jumps over the lazy dog", nil)