-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
Using freetype-go as a back end for sdl-ttf #143
Comments
My thoughts on this:
More research is probably warranted. Edit: FWIW, sdl_ttf uses freetype2 as a back-end anyway, and we certainly wouldn't want to have to port that to Go as well, so freetype-go would be the obvious direction to explore in any case. |
I agree that speed should be a pretty big concern in this case. I didn't know that sdl_ttf used freetype2, so that might make the transition easier if freetype-go is performant enough. I'll look into this. |
Okay, it looks like freetype-go is not in any state to serve as our back end, simply because it's too lacking in features. That said, it looks like developers on golang.org/x/exp/shiny want to help improve the library as seen here. "A secondary goal is to drive development of the Freetype Go port - it has some basic functionality but also some long-standing known deficiencies. Writing a quality GUI text editor is again a substantial amount of work, and I don't intend to build one, but I intend that working on shiny will push the Freetype Go library to be good enough to let someone or some team do exactly that, if they had the time and inclination." |
It's been about 11 months since the last post in this discussion. Has golang/freetype gotten any better since then? Is this more feasible now? I'm working on a project using SDL2, and I'm running into problems with glyphs randomly not rendering. I get errors like the following:
So far as I can tell, it's a pretty common problem with SDL2_ttf. The most annoying part is that it seems to happen completely at random. Sometimes it works, and sometimes it doesn't. |
I hadn't followed this discussion but if this issue can't be fixed with SDL2, I'll have a go at writing the code that use the Go freetype library. In the meantime, is it possible for you to share a small runnable code that reproduce the issue? It seems like the only other similar problem I found is in another binding for D lang: http://stackoverflow.com/questions/26956658/sdl-ttf-rendertext-blended-fails-randomly. I added a test file called |
I have not been able to reproduce the problem consistently. It happens a lot, but sometimes it doesn't happen at all. For some bizarre reason, it seems to happen far more often when using the race detector, but even then it doesn't happen sometimes. I think it may have to do with multithreading issues, but I'm not sure. I looked into golang/freetype. It looks pretty clean and easy to use, but the issue is that it renders, not surprisingly, to a Edit: On a side note, I was looking through |
I'm really late to the party but I wanted to reply about the error:
I was having this problem and it was due to using a RWFromMem wrapped around a ttf font I loaded into memory previously. It looks like the resulting RWOps didn't have any references to the byte slice that I used to create the RWOps and it was getting garbage collected and throwing the zero width error later. |
Making an SDL2 implementation for Go would be great, but we probably shouldn't reinvent the wheel when we don't have to. In the case of sdl-ttf, that would be a particularly tough wheel to reinvent. What if we used freetype-go as the back end? I took a quick look at the API and it seems like most of the features we need are in there with a few exceptions (checking ascent/descent, fixed-width detection, etc) that I may have missed. Has anybody else looked into this?
The text was updated successfully, but these errors were encountered: