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] Freeze in the main loop after loading an embedded font file and use it as the default font #820

Closed
scorpheus opened this issue Jul 10, 2024 · 4 comments
Labels
bug Something isn't working

Comments

@scorpheus
Copy link

What happend?

My Goal is to display this kind of emoji "๐Ÿšซ๐Ÿ•’โฑ๏ธ๐Ÿ๐Ÿ“๐ŸŒ๐Ÿ“๐Ÿš€โžก๏ธ๐Ÿ‘‰๐Ÿ’จ๐ŸŽฎ๐ŸŽš๏ธโš™๏ธ๐Ÿ”ฉ๐ŸŽ๏ธ๐Ÿ›ž๐Ÿ”ง๐Ÿ”„โ›ฝ๐Ÿ”‹๐Ÿšฅ๐Ÿ› ๏ธ๐Ÿ›‘๐ŸŒก๏ธ๐Ÿ†๐Ÿ”ข๐ŸŽกโ†–๏ธโ†—๏ธโœ…โŒยฐC|/#_")

I load an embedded file, set as default, and in the main loop, the app freeze.
It works in debug in vscode but not in release

version used:
github.com/AllenDang/cimgui-go v0.0.0-20240611070805-39b5aa2438db
github.com/AllenDang/giu v0.8.1

Code example

main.go
//go:embed seguiemj.ttf
var embeddedFonts embed.FS

func loadFonts() {
	// Load font
	fontPath := "seguiemj.ttf"
	fontSize := float32(15)

	fontData, err := embeddedFonts.ReadFile(fontPath)
	if err != nil {
		log.Fatalf("Failed to read embedded font file: %v", err)
	}
	giu.Context.FontAtlas.AddFontFromBytes(fontPath, fontData, fontSize)

	giu.Context.FontAtlas.SetDefaultFont(fontPath, fontSize)
}

To Reproduce

call loadFonts before wnd.Run(loop) (not in debug)
it should freeze

Version

(latest)

OS

windows 10, go version go1.22.0 windows/amd64

@scorpheus scorpheus added the bug Something isn't working label Jul 10, 2024
@gucio321
Copy link
Collaborator

@scorpheus its always the problem unfortunately, but I thinkk its a good time to fix this now ๐Ÿ˜„

Could you please attach your font file or create a github repo with your example project? (it should be easier to debug then)

@scorpheus
Copy link
Author

simple_test.zip
After making this simple test, I saw an old reference to fyne in my project, it was the culprit.
just add widget.BaseWidget from "fyne.io/fyne/v2/widget" and the app freeze.
But only if you load a font.
if you comment loadFonts, the app is not freezing.
if you remove fyne, it works

@gucio321
Copy link
Collaborator

well, unfortunately I can't say why using fyne along with giu doesn't work.
I suppose this is something related to glfw (both fyne and giu may use it) and I suppose doing it at the same time may not be a good idea.

@scorpheus
Copy link
Author

Not a good idea indeed,
Avoid to use fyne and load font at the same time and everything is working ;)

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