LWJGL Forum

Programming => LWJGL Documentation => Topic started by: toyoPon3 on May 06, 2011, 10:06:33

Title: About the TrueTypeFont (additionalchars?)
Post by: toyoPon3 on May 06, 2011, 10:06:33
I wrote the sample program that used TrueTypeFont by referring to the site shown in below.
http://lwjgl.org/wiki/index.php?title=Slick-Util_Library_-_Part_3_-_TrueType_Fonts_for_LWJGL

And I changed some line shown below to draw the Japanese String.
Then, my sample program moved as planned.

Here, I had the question.

Japanese has over 3000 characters.("HIRAGANA","KATAKANA","KANJI")
But, "additionalChars" can't have 3000 characters.
"additionalChars" can have only 256 characters.(I refer to the Javadoc.)

Are there the way that draw the all Japanese characters in "font set"?
Or
are there the way that draw over 257 Japanese characters (remove restriction "256")?
Title: Re: About the TrueTypeFont (additionalchars?)
Post by: kappa on May 06, 2011, 10:36:20
Slick-Util is only a subset of Slick2D, you should grab the full slick.jar instead, it contains additional classes which include UnicodeFont and AngelCodeFont which work pretty similar to TrueTypeFont and might be what you need in this case.

Lastly if you'd like to also see those classes in Slick-Util you should raise a RFE on the slick forums here (http://slick.javaunlimited.net/viewforum.php?f=1).
Title: Re: About the TrueTypeFont (additionalchars?)
Post by: toyoPon3 on May 07, 2011, 02:53:20
Hi, Kappa.

Thank you for your advice.

I changed to "UnicodeFont" from "TrueTypeFont".
Then, my program moved as planned!

This is the sample code for the people who change to "UnicodeFont" from "TrueTypeFont", like me.
(Good case)

Font awtFont = new Font("DialogInput", Font.BOLD, 32);
UnicodeFont uniFont = new UnicodeFont(awtFont),false);

uniFont.addAsciiGlyphs();
uniFont.addGlyphs(0x3040, 0x30FF);           // Setting the unicode Range
uniFont.addGlyphs(JPN_CHAR_STR);             // Setting JPN Font by String

// Setting the Color
uniFont.getEffects().add(new ColorEffect(java.awt.Color.black));
uniFont.getEffects().add(new ColorEffect(java.awt.Color.yellow));
uniFont.getEffects().add(new ColorEffect(java.awt.Color.white));

uniFont.loadGlyphs();


Change the setting order. (Bad case:white is set in first)

// Setting the Color
uniFont.getEffects().add(new ColorEffect(java.awt.Color.white));
uniFont.getEffects().add(new ColorEffect(java.awt.Color.black));
un/Font.getEffects().add(new ColorEffect(java.awt.Color.yellow));


In this case, the string was drawn, but the color of the string was not right.
For example

uniFont.drawString(100, 100, "test", Color.white);

In good case, the string "test" was drawn by Color.white.
But, the string "test" was drawn by Color.yellow in bad cade.

Question:
Dose the setting color order depend on color depth?
I searched this by the google.
but I could not find out.