Hello Guest

Possible bug in STBTTFontInfo

  • 8 Replies
  • 6203 Views
*

Offline asyx

  • *
  • 23
Possible bug in STBTTFontInfo
« on: September 18, 2015, 15:07:12 »
Hello!

I played around with the TrueType STB bindings a little and tried to port a C example that renders text into a PNG.

So, that works now but I think there's a bug in the STBTTFontInfo.malloc() method.

http://pastebin.com/ZbVC7k4L

Here's my code (working). If you uncomment line 72 and comment line 73, it crashes with

Code: [Select]
Exception in thread "main" java.lang.UnsatisfiedLinkError: org.lwjgl.stb.STBTTFontinfo.offsets()I
on line 72.

At first I thought that it might be a problem with my library path but I then just got the size of the struct via C and created the buffer manually and that works flawlessly.

I'm using the LWJGL version from the snapshot maven repository.

*

Kai

Re: Possible bug in STBTTFontInfo
« Reply #1 on: September 18, 2015, 15:18:07 »
You are likely using an old DLL/shared library of LWJGL. This native function is available in the latest 3.0.0a release and the latest 3.0.0b nightly. In Maven it comes with the `org.lwjgl:lwjgl-natives-<os>` artifact.
Check your -Djava.library.path.
« Last Edit: September 18, 2015, 15:23:15 by Kai »

*

Offline asyx

  • *
  • 23
Re: Possible bug in STBTTFontInfo
« Reply #2 on: September 18, 2015, 15:39:51 »
Cleaned it and repackaged it. Everything but this method works. And the library path works as well. Otherwise, I couldn't use all the other STB stuff I'm using.

*

Kai

Re: Possible bug in STBTTFontInfo
« Reply #3 on: September 18, 2015, 17:21:47 »
Otherwise, I couldn't use all the other STB stuff I'm using.
Not necessarily. Could have been that the native interface of the structs changed with one build version which added that "offset" function.
My theory is that you are linking against an old version of the LWJGL3 native/shared library. ;)

*

Offline asyx

  • *
  • 23
Re: Possible bug in STBTTFontInfo
« Reply #4 on: September 18, 2015, 17:40:27 »
But wouldn't maven do that for me? Like, I unpacked the native libraries from the jar that I got together with the lwjgl.jar. I mean, maven should prevent f*ckups like that, right?

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Possible bug in STBTTFontInfo
« Reply #5 on: September 18, 2015, 17:46:23 »
Thanks asyx, this is a bug in LWJGL. It happens because STBTTFontInfo.malloc() is the first native LWJGL method you call and the library is not properly initialized (because this particular struct is opaque = has no public fields). It will be fixed in the next nightly build.

In the meantime, a workaround is to call LWJGLUtil.initialize() before STBTTFontInfo.malloc().

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Possible bug in STBTTFontInfo
« Reply #6 on: September 19, 2015, 21:53:14 »
This should be fixed in the latest nightly build (3.0.0b #28).

Re: Possible bug in STBTTFontInfo
« Reply #7 on: September 20, 2015, 06:45:17 »
@spasi 3.0.0b build 28 does not include the glfw natives, leading to errors during initialization.

*

Offline spasi

  • *****
  • 2261
    • WebHotelier
Re: Possible bug in STBTTFontInfo
« Reply #8 on: September 20, 2015, 07:18:15 »
Thanks, fixed in build #29.