font asset
This commit is contained in:
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user