Skip to content

Commit

Permalink
Add panic if font file doesn't exist
Browse files Browse the repository at this point in the history
  • Loading branch information
dusk125 committed Oct 2, 2021
1 parent af03253 commit 4efbc25
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions font.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package pixelui

import (
"fmt"
"image/color"
"log"
"os"
"unsafe"

"github.com/inkyblackness/imgui-go"
Expand Down Expand Up @@ -40,6 +42,9 @@ func (ui *UI) loadDefaultFont() {

// AddTTFFont loads the given font into imgui.
func (ui *UI) AddTTFFont(path string, size float32) {
if _, err := os.Stat(path); os.IsNotExist(err) {
panic(fmt.Sprintf("The font file: %s does not exist", path))
}
ui.fonts.AddFontFromFileTTF(path, size)
ui.loadFont()
}

0 comments on commit 4efbc25

Please sign in to comment.