font asset

This commit is contained in:
Dmitry Sergeev
2026-09-03 13:46:14 +03:00
parent 4742b1a1e5
commit 7dca5f1c3d
6 changed files with 151 additions and 2 deletions
+23
View File
@@ -0,0 +1,23 @@
package assets
import (
_ "embed"
"runtime"
"unsafe"
)
// uiFont contains the player UI font so the executable does not depend on a
// machine-specific font installation.
//
//go:embed fonts/JetBrainsMonoNLNerdFontMono-Regular.ttf
var uiFont []byte
// PinUIFont returns the embedded font data and a release function. ImGui keeps
// the supplied pointer until its font atlas is destroyed, so callers must keep
// the data pinned and invoke release only after destroying the ImGui context.
func PinUIFont() (data uintptr, size int32, release func()) {
pinner := new(runtime.Pinner)
pinner.Pin(&uiFont[0])
return uintptr(unsafe.Pointer(&uiFont[0])), int32(len(uiFont)), pinner.Unpin
}