Gdx Freetype in JME?

I noticed this subproject. It probably cannot be used inside jME at it is, but maybe the source code can provide useful hints for including the functionality… any considerations?

Something like this would be really nice in JME, possibly using a TrueTypeFontLoader or similar. Surely this must have been looked at before though or possibly even. I can see there is a reference to sorting out the BitmapFont in the future releases roadmap but that’s about it.

I wouldn’t mind helping out with this if needed.

Edit: I assume something like would create a BitmapFont in the end so the question is, should we wait for or even fix BitmapFont first as I hear it needs sorting out.

Well if that is just generating a bitmap font from a ttf font, you can already do that in the SDK. I guess we could make this an engine plugin so you could use it in game to generate the needed bitmap font.

Not sure the BitmapFont needs a refactoring, it’s more BitmapText. Maybe there has been some mistake in other posts.


Right, I was just looking at the Roadmap for Future Release page.

Fix BitmapFont, must have all the features the current one has, but without the bugs.

There is no issue raised for BitmapText though.

Although, the question is how much of a demand would it be to be able to load fonts during runtime and generate a bitmap font of a specific size.

I think what I would like more is a way to “enhance” the text with things like a border colour and size. Perhaps drop shadows etc.

1 Like

Maybe these kind of effects will be possible with Nifty 2.0. Will we have support for it once it will be released?

@mathiasj This kind of effect is already possible with jme-jfx (java 8 only) via ttf + css

That library loads the TTF font and generates a BitmapText out of it at runtime. The only advantage mentioned is that scaling fonts can look bad… However you can always use a higher resolution font when generating BitmapFont and then resize it to be smaller.

I would imagine a more useful use case would be Asian fonts which can have thousands of glyphs. In that case, you want to rasterize the text dynamically since you may need to generate a lot of textures to represent a single font if you do it offline.

You can, but the result will be sub-optimal. The best result is when you use the font at exactly the same size that is generated. Resizing to smaller resolution will produce (small) scaling artefacts.

In fact, on my game I keep multiple sizes of the same font for achieving the best result.

I like that @david_bernard_31, I will have to have a look at that later. Some nice new additions to JavaFX in 8u40 as well :smile:

That’s really cool! I love the JavaFX css. But I’m kinda scared of integrating jfx because afaik you have to build the engine itself (no java 8 support) and you can’t really use the SDK with it?

no need to build the engine. I use regular 3.0.10 (from maven repository), I don’t use the SDK, but with @normen we provided some “guide” about how to use java 8.0 with SDK.

EDIT: see

Generating a bitmap font from a ttf font would definitely be great if it would be in the engine itself and not in the SDK. Exactly for the reasons mentioned, ala generate a font of exact size + generate a font for a part of thousands of other language letters.

whatever happened to
java.awt.Font myBigFont = someJRERegisteredFont.deriveFont(64f);
as long as its a float, then the returned font is the correct size… 64pt in the example… then you just do the whole “font to bitmap font”? Isn’t that how it goes?

I’m just checking… as that is the understanding of how I would go about the whole resizing the font thing using the .ttf files and Font class and then to Bitmap font… cause all fonts that are registered in the system are understood to be 1pt in size when you get them from the Graphics Environment of the JRE.

    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    Font[] fontsListing = ge.getAllFonts();

So in the example… Font[] is filled with all kinds of fonts currently registered with the GraphicsEnvironment… and they are all arbitrarily 1pt because you can clone a Font for yourself, using the deriveFont method to properly size it to W/E. You just have to remember to specify a float value rather than an int value to connect with the proper method definition.

… right?

Cause otherwise I’ll just help out with that part of the bridge for dynamic translation at runtime for the sdk core next. edit: engine! I meant engine! :grin:

I want to just throw my ttfs in with my project. And dangit, I’ll be writing that then, if we can’t already do it.

edit: -For those wondering about why I’m weirded out about this, just see:
further edit: no this might bore you…If you really want to torture yourself with a video… this really only shows that I’ve had some experience w/ Font * :

PS: where’s the strikethrough?.. I need strikethrough! I haven’t learned it yet! :stuck_out_tongue: