LWJGL Forum

Programming => OpenGL => Topic started by: ndhb on November 12, 2006, 23:13:03

Title: Yet another glFont
Post by: ndhb on November 12, 2006, 23:13:03
Hi all. There are several libs around but if someone hasn't found them and wants to draw some bitmap fonts in OpenGL:

* I've made a few classes that renders text in orthographic (2D) and perspective (3D).
* It currently only supports loading fonts created with Codehead's Bitmap Font Generator (http://www.codehead.co.uk/cbfg (http://www.codehead.co.uk/cbfg)).
* It's implemented with display lists and at least it's fast enough for my own purposes (creating new text, results in display lists created which can occur a temporary stall).
* There's no support for unicode. To support unicode I'm considering writing a loader for BMFont (http://www.angelcode.com/products/bmfont (http://www.angelcode.com/products/bmfont)).
* You're free to use it for whatever purpose if you include me (ndhb) in the credit.
* There's some generated javadoc that explains how it works (or look at TestFont.java).

Looks like this:
(http://85.235.22.202:8080/dk.nesos.font.01a.png)

Please post if you try it and find any bugs or issues!

Download:
http://85.235.22.202:8080/dk.nesos.font.01a.zip (http://85.235.22.202:8080/dk.nesos.font.01a.zip)

Title: Yet another glFont
Post by: numberR on November 13, 2006, 01:05:48
looks pretty cool!

i was doing dynamic font generation using BufferedImage and Graphics2D so it can generate whatever the text in any languages as long as Java supports them, but of cource, it has some speed issue...
Title: Yet another glFont
Post by: appel on November 13, 2006, 09:13:30
That's awesome work ndhb :)

But one thing though! If you zoom in on the characters that overlay the big blue text you'll notice a black border. This is most likely due to the anti-aliasing. It wouldn't look good on a colored background, like in-game.

You could try to change the clearColor, see what happens.


Isn't there a way around this?
Title: Yet another glFont
Post by: ndhb on November 16, 2006, 16:34:12
The border is due to the blending function I used. Changing the blending "solves" the issue. There are a lot of options and parameters to adjust (BlendFunc, AlphaTest, AlphaFunc, Texture mode, etc.) that can change the appearance of the text. I havn't had much time to experiment but it should be possible to achieve almost any effect (even stencilfun). Here's another screenshot with a different blending function.

(http://85.235.22.202:8080/dk.nesos.font.01b.png)

from the code http://85.235.22.202:8080/dk.nesos.font.01b.zip (http://85.235.22.202:8080/dk.nesos.font.01b.zip)

One of the nice thing about bitmap fonts is the versability, then again it can be hard to achieve the effect you have in mind without a lot of experience with all the different knobs and switches (which I don't really have).
Title: Re: Yet another glFont
Post by: kieselsteini on March 27, 2007, 22:56:29
Hiho. Your font library is pretty cool. But there are at least two things I'll glad to see. First of all your BitmapFileFont loader is only capable of loading fonts from files not from URL oder File objects, so putting font files into a jar is very hard.
Also some setScale(float)/getScale() method for the Font class would be nice. Sure you can do this with glScale() for your own, but only when doing this via drawText3D().

Keep on working man!! After I found you lib, I'm the happiest man here  ;D
Title: Re: Yet another glFont
Post by: ndhb on August 10, 2007, 10:44:33