giu icon indicating copy to clipboard operation
giu copied to clipboard

[bug]g.Context.FontAtlas.SetDefaultFontSize can't invoke before g.NewMasterWindow

Open fyw2020 opened this issue 2 years ago • 3 comments

What happend?

g.Context is nil

panic: runtime error: invalid memory address or nil pointer dereference

Code example

main.go

package main

import ( g "github.com/AllenDang/giu" )

func loop() { g.SingleWindow().Layout( g.Style().To( g.Label("test"), ), ) } func main() { g.Context.FontAtlas.SetDefaultFontSize(12) wnd := g.NewMasterWindow("test", 1024, 768, g.MasterWindowFlagsMaximized) wnd.Run(loop) }

To Reproduce

  1. Run my demo
  2. will see the crash...

Version

master

OS

windows

fyw2020 avatar Dec 11 '22 07:12 fyw2020

While the help message say to do so.

// SetDefaultFontSize sets the default font size. Invoke this before MasterWindow.NewMasterWindow(..).

fyw2020 avatar Dec 11 '22 07:12 fyw2020

You're right - something is borken inside font atlas right now... SetDefaultFontSize doesn't work anyhow :smile:

gucio321 avatar Dec 22 '22 11:12 gucio321

ok, I see - context is nil because it is created in NewMasterWindow. THe problem is that init font stuff happens there as well. Need to add extra logic in SetDefaultFontSize.

gucio321 avatar May 09 '23 16:05 gucio321