jME-TrueTypeFont Rendering Library

1.) Yes. When Java was first introduced the char type was based on Unicode 88 and they did not change this when Unicode 2.0 came out. In order to support the additional codepoints in Unicode 2.0 Java uses surrogate pairs, two chars.

In a True Type Font file characters are looked up via their Unicode code point. You could just use a char for this as the int value of a char is its Unicode codepoint, but that leaves out the additional characters supported by Unicode 2.0.

In order to support this jME-TrueTypeFont loads the string into a StringBuilder and uses the StringBuilder.codepointAt method which supports Unicode 2.0 by looking for surrogate pairs and returning the appropriate Unicode 2.0 code point.

2.) jME-TrueTypeFont uses one texture for each instance. The default maximum resolution is 2048x2048, but you can change this to whatever you want so long as the graphics card supports it.

1 Like

Okay, nice that part 1.) is handled so well. I think we should inject some of that ā€œnew codeā€ into BitmapText too - since the glyphs itself are stored in an IntMap already.

About the second thing ā€¦ Iā€™ve crossed the border that my gfx card sets (usually 8k x 8k for not-so-old middle-class card) with full set of the ā€œHanazonoā€-derived font quite quickly. That uses almost all known Kanji (Chinese glyphs). Even when packing them into the four channels (R = one set of glyphs, G = next set of glyphs, B = next set of glyphs, A = next set of glyphs) you need the second texture quite quickly. Especially if you use 44 pixels high glyphs (needed if you want the Kanji to be rendered in different styles like ā€œboldā€ and ā€œitalicā€ or just to get the higher resolution for headlines etc.).

Iā€™m sure Iā€™ll work a solution for ultra large character sets at some point in the future, but for now I guess thatā€™s not supported. jME-TrueTypeFont will load characters up until it can no longer grow the texture to fit more characters. At 44 pixels high and a 2k texture thatā€™s at least 2,166 characters.

I say at least because jME-TTF packs characters diffidently than the SDKs built-in bitmap font creator. The built-in creator spaces characters evenly along each line, each character gets the same amount of space in the atlas regardless of whether itā€™s an ā€˜Iā€™ or ā€˜Gā€™. jME-TTF can fit more characters in the same space because each character is given an amount of space based on the width of the character so an ā€˜Iā€™ takes up less space in the atlas than a ā€˜Gā€™.

Thatā€™s how it should be. I use the BMFont.exe from AngelCode. I have, however, implemented my own glyph-packing which respects the width and even the height (sorts all glyphs by their height in descending order, then places them in lines that suit their height).

jME-TrueTypeFont couldnā€™t really sort all glyphs by height when creating the atlas since glyphs are being added to the atlas on an as needed basis rather than all at once. I would say if you absolutely need every single glyph in a giant font with thousands of glyphs then jME-TrueTypeFont might not be the best solution, stick with BitmapFont.

@Tryder so this jme-lemur-dynamo thing is a lemur version that uses your truetype-font?

Is there a repo somewhere, or just the google drive version?

That and a few other things like combo boxes and on the fly creation of gradient backgrounds with rounded corners and borders. Anyway, yeah just the one on Google Drive.

1 Like

It seems that jME TrueType 3D still uses library with GPL. Maybe somebody have found any solutions about not using library with GPL license? ^^

1 Like

I did find this potential replacement option and Tryder said heā€™d look into it, Iā€™m sure he has his own priorities though.

https://code.google.com/archive/p/jmescher/2

2 Likes

Iā€™ll get around to it

1 Like

jME-TrueTypeFont has been updated to version 1.28 which fixes a bug where some Android devices would throw a VerifyError upon loading a font. Apparently some Android devices still look for java.awt.font even if itā€™s in an if statement that wonā€™t test true. Separating it out into a separate class that is only loaded when run on desktop solved the issue.

For anyone using LemurDynamo it has also seen a few updates and now stands at Beta 15. Fixed a few issues with layers, an issue where fontā€™s wouldnā€™t keep the alpha setting set through setAlpha() if setText() was called afterwards and updated the shader for GradientBackgroundComponents for better support of Android devices that donā€™t support high precision floating point variables, though if they donā€™t support high precision and do support standard derivatives there may still be an issue compiling the shader due to a problem with jMEā€™s GLRenderer where it inserts precision mediump float; above the extension declaration.

If youā€™re using LemurDynamo on Android devices you can either disable anti-aliasing by setting GuiGlobals.getInstance().derivativeSupported = false or modify GLRenderer in the core package as per my other thread: [SOLVED] Unable to Use GLSL Extensions in Fragment Shader - #2 by Tryder

3 Likes

Okay I finally got around to looking into this and the jmescher library, which is licensed under the New BSD license, depends upon the javax.vecmath library which is licensed under, you guessed it, GPL.

1 Like

Which means jmescher is mis-licensed, I guess. If javax.vecmath is GPL and not LGPL then jmescher must be GPL also.

1 Like

Maybe because it is with classpath exception?

First, Stallman has always been against the classpath exception.

Second, if they are importing the classes then they get no classpath exception, anyway. No more so than a C app would get a ā€œdynamic libraryā€ exception. Thatā€™s what LGPL is for. If tiā€™s not LGPL then you canā€™t use it without also being GPL. Period.

1 Like

https://www.gnu.org/software/classpath/license.html

" When GNU Classpath is used unmodified as the
core class library for a virtual machine, compiler for the java languge,
or for a program written in the java programming language it does not
affect the licensing for distributing those programs directly."

1 Like

Ah, Big C Classpath and not little C classpath.

javax.vecmath is not part of the GNU Classpath libraries as far as I know. Nor do I understand how that would work.

ā€¦So these two things are completely unrelated.

1 Like

jmescher isnā€™t distributed with the dependent library, does that make a difference?

Yes I think that means jmesherā€™s lib is licensed incorrectly.

But, Iā€™m not ready to lose hope yetā€¦ with a casual look over the source, Iā€™m only seeing a few classes from javax.vecmath being used andā€¦ Iā€™m thinking they probably ainā€™t all that tough to replace:

import javax.vecmath.Point2d;
import javax.vecmath.Point3d;
import javax.vecmath.Vector2d;
import javax.vecmath.Color3f;

Looks like some easily torn out and replaced piss ant classes to me. Iā€™m going to try replacing that entire dependency (with jMEā€™s versions for some :stuck_out_tongue: ) this weekend if nobody else does it first.

Or we could see if the author will do it to fix the license issue. :slight_smile: New BSD is forkable in any caseā€¦

1 Like

javax.vecmath license.txt says itā€™s GPLv2 with classpath exception.