LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.67k stars 631 forks source link

Why is there no freeType? #800

Closed HoneyTorres closed 1 year ago

HoneyTorres commented 1 year ago

Question

let me use stb font or java native font?

Spasi commented 1 year ago

Hey @HoneyTorres,

It would be possible to add the FreeType (and/or HarfBuzz) libraries to LWJGL, but there just hasn't been any interest for it. stb_truetype offers a simple solution, that's easy to integrate and does a good enough job for most applications.

However, if I needed a state-of-the-art solution for my project, I would certainly be looking into licensing the Slug Library.

NekoCaffeine commented 1 year ago

611 freetype & harfbuzz binding

Whether it's good enough depends on the language of your users. In fact HarfBuzz is the only layout engine solution in modern times.

It took me some time to get the implementation under sun.font to work directly with bgfx's rendering pipeline.

Using AWT Font directly is inefficient without a lot of retrofitting. Computing layouts can be expensive, although most languages do not require executing scripts to compute layouts. You may need to implement your own layout caching and layout increment calculation. It takes some black magic to avoid the waste of multiple copies from the AWT to the rendering backend.

Using stb makes things easier and is sufficient to solve the problem most of the time, but it is important to note that it is not a perfect solution.

Illithidek commented 1 year ago

The difference between stb and freetype is that freetype has far more capabilities, it's used by more than a billion devices and supports various edge cases which we will not see on stb(because it was created for simple things). I'll just say that I've managed to link old bindings and it runs much better than stb in my case. https://github.com/mlomb/freetype-jni Maybe it will help.

Spasi commented 1 year ago

Hey @NekoCaffeine and @Illithidek,

Thank you for your input! Hard to say when I'll have time for it, but I'll try to prioritize #611 higher.