-
Notifications
You must be signed in to change notification settings - Fork 244
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
text.NewAtlas
crashing application
#123
Comments
If I can get the full source code you're trying to run I'll be more than happy to help you with this one. |
There's really no mystery in reproducing the bug. It's really just calling that line: package main
import (
"github.com/faiface/pixel/pixelgl"
"github.com/faiface/pixel/text"
"golang.org/x/image/font/inconsolata"
)
func main() {
pixelgl.Run(run)
}
func run() {
text.NewAtlas(inconsolata.Regular8x16, text.ASCII)
} |
Hi, sorry for getting back to you so late. I've tested it on my machine and it crashes as well, which is weird. Currently, I don't have the time to investigate it much further, but if you, or anyone else could, it would be great if you guys figured this out. |
Hi, I didn't have time to look into this earlier, but I think I just found the reason for the crash. https://github.com/faiface/pixel/blob/master/text/atlas.go#L63 On the atlas creation, you can see the following code: for r, fg := range fixedMapping {
dr, mask, maskp, _, _ := face.Glyph(fg.dot, r)
draw.Draw(atlasImg, dr, mask, maskp, draw.Src)
} The crash happens on the call to Now, face.Glyph returns an
So, what seems to be happening is that Pixel is just swallowing this The fix might actually be as simple as: for r, fg := range fixedMapping {
if dr, mask, maskp, _, ok := face.Glyph(fg.dot, r); ok {
draw.Draw(atlasImg, dr, mask, maskp, draw.Src)
}
} As I'm not very familiar with the rest of Pixel, I had no clue if this might have unintended issue with other parts of the system. But it seems logical to me that the check shouldn't hurt. Any thoughts, @faiface ? Cheers |
Hey @faiface , any updates on this? Still happening with current HEAD. Thanks! |
Oh, sorry, somehow forgot about this. The fix you suggested might be okay, have you tried it? Doesn't it cause incorrect rendering? If not, would you be so kind as to make a PR? :) (While you're at it, you could also remove this line: https://github.com/faiface/pixel/blob/master/text/atlas.go#L206 probably a forgotten debug print). |
@bfreis I'll try to take a look at this when I have time. |
I just ran into this too and was about to give up until I discovered this issue which at least provides a workaround. I'll try the fix suggested by @bfreis and see if it helps. |
Tested @bfreis's fix and it seems to work fine. Can we merge his commit? |
Good work you guys. Thanks. Getting this in. |
tests and fixes #123, SIGSEGV on text.NewAtlas if glyph absent
Hi,
This line crashes my application:
If I use
basicfont.Face7x13
instead of Inconsolata, it works just fine. The crash looks like this:I'm using the most recent commit, 2ffc7a6
Anybody seen this?
Thanks!
The text was updated successfully, but these errors were encountered: