android developer
android developer

Reputation: 116020

How to show vectorized text using libgdx?

I'm quite a noob with libGDX for Android (nice OpenGL wrapper that can also work on PC), and I've read some nice examples of how to show images and shapes. However, when I wanted to check out how to show text, I noticed that the only thing I could see that this library supports is BitmapFont, which uses a bitmap for each character. It's ok for some resolutions and font sizes, but it becomes blurry/pixelated for other cases.

Is there any other way to show text using this cool library? Some kind of way to show vector fonts, and also use more popular fonts files extensions other than ".fnt"?

Upvotes: 6

Views: 3621

Answers (2)

P.T.
P.T.

Reputation: 25177

There is a recent entry on the badlogic blog about generating bitmap fonts on the fly from TrueType font files that should address your problems with packaged font files that are ugly when scaled.

When I was new to Android and libGDX I spent some time looking for a vector font solution to draw scalable text via libGDX. I never found anything (not even generic Java or generic Android). Most font solutions I found are built on bitmaps or were very complex rendering systems (that would be hard to adapt to OpenGL). This seems a bit odd to me too, and I haven't found a coherent explanation.

Upvotes: 4

TheWhiteLlama
TheWhiteLlama

Reputation: 1286

I don't think there is a proper ways to do so, because libgdx works on openGL too. OpenGL uses textures for displaying images, so that your device is able to draw images hardware accelerated. I don't use libgdx but probably you can write your own function to draw first your vector-based fonts on a texture and then draw your texture on screen. -> But then it's not vectorized anymore.

Upvotes: 0

Related Questions