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

Raylib.load_font segfaults #32

Closed
skinnyjames opened this issue Feb 28, 2024 · 11 comments
Closed

Raylib.load_font segfaults #32

skinnyjames opened this issue Feb 28, 2024 · 11 comments

Comments

@skinnyjames
Copy link

Summary

The font handling within raylib-cr fails, using both v4.2 and v5.0.
I'm on MacOSX.
I have another project in C that uses the raylib apis directly, which works with both 4.2 and 5.

I don't see anything off with the bindings unfortunately, so I wonder if there is something else at play.

Minimal reproducible example

require "raylib-cr"

Raylib.load_font("#{__DIR__}/PTMono.ttf")

Stacktrace

INFO: FILEIO: [/Users/skinnyjames/src/bugs/PTMono.ttf] File loaded successfully
Invalid memory access (signal 11) at address 0x0
[0x107a2fe0b] *Exception::CallStack::print_backtrace:Nil +107 in /Users/skinnyjames/.cache/crystal/crystal-run-test.tmp
[0x107a153bd] ~procProc(Int32, Pointer(LibC::SiginfoT), Pointer(Void), Nil)@/Users/skinnyjames/.asdf/installs/crystal/1.11.2/src/crystal/system/unix/signal.cr:131 +285 in /Users/skinnyjames/.cache/crystal/crystal-run-test.tmp
[0x7ff81242d37d] _sigtramp +29 in /usr/lib/system/libsystem_platform.dylib

Expected

Raylib.load_font doesn't segfault.

Actual

Raylib.load_font segfaults.

@sol-vin
Copy link
Owner

sol-vin commented Feb 28, 2024

Thanks for the issue, however this appears to be an issue with raylib directly rather than my binding, can you attempt to reproduce this with C?

@skinnyjames
Copy link
Author

Thanks for the issue, however this appears to be an issue with raylib directly rather than my binding, can you attempt to reproduce this with C?

Yeah, I'm currently using the same C Raylib apis directly in my other application. I cannot reproduce.

@sol-vin
Copy link
Owner

sol-vin commented Feb 28, 2024

Can you upload the TTF file? I use this in a project and it is still working last I checked.

@skinnyjames
Copy link
Author

skinnyjames commented Feb 28, 2024

Absolutely. Attaching a link to the font used in the issue (github won't let me upload)

https://drive.google.com/file/d/122HnsJMVJFZ34gZ_HUy8mcF3b-qH7msL/view?usp=sharing

Also worth nothing that this is the log trace when using the C apis

Screenshot 2024-02-28 at 8 06 57 AM

It loads the file, and then also loads the font data. raylib-cr seems to have trouble opening the data for me, and seemingly tries to access a NULL pointer.

@skinnyjames
Copy link
Author

I'm a bit confused because everything looks correct for Raylib::Font so I wonder if something else is up.

@sol-vin
Copy link
Owner

sol-vin commented Feb 28, 2024

Something else is up. I can use the font totally fine. You may have unloaded the font too early. I cannot reproduce. :(

@sol-vin
Copy link
Owner

sol-vin commented Feb 28, 2024

Capture

@skinnyjames
Copy link
Author

Something else is up. I can use the font totally fine. You may have unloaded the font too early. I cannot reproduce. :(

Yup, user error. I have to init the window first. 🤦. I think because raylib loads font into the GPU.

@sol-vin
Copy link
Owner

sol-vin commented Feb 28, 2024

Damn I was gonna say that earlier but I wasn't sure. Yeah, anything that uses a texture backing (like font) needs to have init_window.

@sol-vin sol-vin closed this as completed Feb 28, 2024
@skinnyjames
Copy link
Author

Thanks for helping look into this, sorry for the worries. I'll close it.

@skinnyjames
Copy link
Author

@sol-vin btw, curious if this sounds like something you'd like to work with/on?

Working on an agnostic frontend framework, currently using raylib-cr as the backend.

This is a whole component.

console-nigel

And the template is also minimal

{{ template }}
  vblock
    text { :content="output" size="20" background="22,22,22", :color="status"}
    textfield { @change="run_command" size="17" height="100", background="33,33,33" color="255,255,255" }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants