Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
fyw2020 opened this issue Dec 11, 2022 · 3 comments
Labels
bug Something isn't working

Comments

@fyw2020
Copy link

fyw2020 commented Dec 11, 2022

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 fyw2020 added the bug Something isn't working label Dec 11, 2022
@fyw2020
Copy link
Author

fyw2020 commented Dec 11, 2022

While the help message say to do so.

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

@gucio321
Copy link
Collaborator

gucio321 commented Dec 22, 2022

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

@gucio321
Copy link
Collaborator

gucio321 commented May 9, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants