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

Is the Text tutorial outdated? #8

Open
otoomey opened this issue Jun 12, 2017 · 2 comments
Open

Is the Text tutorial outdated? #8

otoomey opened this issue Jun 12, 2017 · 2 comments
Assignees
Labels

Comments

@otoomey
Copy link

otoomey commented Jun 12, 2017

I have been using your tutorials to learn and they are very helpful, so thank you very much for writing them.

I was wondering if there exists a better way for using Fonts in LWJGL, by using the STB bindings in Build #49?

Will you be making a tutorial for NanoVG

@SilverTiger
Copy link
Owner

Thanks for reading the tutorial!

Yes, you are right. It is not recommended to use AWT, and I want to remove that dependency (see issue #4). When this is done I will update the tutorial and put the AWT stuff to the appendix section. But right now I hadn't the time to fully implement Fonts with STB, but basically you have to do the following to create a bitmap with the glyphs:

stbtt_PackBegin(packContext, bitmap, imageWidth, imageHeight, 0, 1);
stbtt_PackFontRange(packContext, fontBuffer, 0, fontHeight, 32, chardata);
stbtt_PackEnd(packContext);

After that you can get the glyphs by calling stbtt_GetPackedQuad(chardata, imageWidth, imageHeight, i, xpos, ypos, quad, true); which will give you a STBTTAlignedQuad containing the vertex and texture coordinates. This demo may help you implementing it.

I will change the Font class to use STB if I have time, after that I'm thinking of doing some advanced tutorials like using NanoVG or creating audio with OpenAL.

@SilverTiger SilverTiger self-assigned this Jun 12, 2017
@Speiger
Copy link

Speiger commented Jul 7, 2020

I personally would not get rid of this tutorial because some people might want to write their own UI engine and will have this good resource no longer left to learn from.

Also the step of "Swing" could be outsourced to a different program and then have a loader that just converts the texture and a text file into a proper text Loader not requiring Swing or AWT.

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

No branches or pull requests

3 participants