Return imgui font after set

This commit is contained in:
bloeys
2022-02-24 06:59:19 +04:00
parent c311a0981c
commit 577e6250a8

View File

@ -134,17 +134,18 @@ func (i *ImguiInfo) Render(winWidth, winHeight float32, fbWidth, fbHeight int32)
gl.Enable(gl.DEPTH_TEST)
}
func (i *ImguiInfo) SetFontTTF(fontPath string, fontSize float32) {
func (i *ImguiInfo) AddFontTTF(fontPath string, fontSize float32) imgui.Font {
imIO := imgui.CurrentIO()
a := imIO.Fonts()
a.AddFontFromFileTTF(fontPath, fontSize)
f := a.AddFontFromFileTTF(fontPath, fontSize)
image := a.TextureDataAlpha8()
gl.BindTexture(gl.TEXTURE_2D, i.texID)
gl.TexImage2D(gl.TEXTURE_2D, 0, gl.RED, int32(image.Width), int32(image.Height), 0, gl.RED, gl.UNSIGNED_BYTE, image.Pixels)
imIO.Fonts().SetTextureID(imgui.TextureID(i.texID))
return f
}
func NewImGUI() ImguiInfo {