Slick2D blurry fonts

Could this be because of the ColorEffect I’m applying to the UnicodeFont?

My code:


	public static UnicodeFont deriveUnicodeFont(String name, int size)
			throws SlickException
	{
		try
		{
			java.awt.Font original = java.awt.Font.createFont(
					java.awt.Font.PLAIN, new File("./cache/fonts/" + name
							+ ".ttf"));

			UnicodeFont derived = new UnicodeFont(original, size, false, false);

			derived.getEffects().add(new ColorEffect(java.awt.Color.white));
		        derived.addAsciiGlyphs();
		        derived.loadGlyphs();

			return derived;
		}
		catch (FontFormatException e)
		{
			e.printStackTrace();
		}
		catch (IOException e)
		{
			e.printStackTrace();
		}

		return null;
	}

Or does it have something to do with how Slick creates the Image for each character? Thanks for your help in advance!

Explain your problem a bit more? Maybe with images?

(My guess is you are scaling them using linear scaling, and you want nearest-neighbour scaling instead…?)

Also, don’t use File to access resources if you plan to include them in the JAR later. Instead, use the ResourceLoader from Slick.

Thanks for your reply, let me take a quick screenshot

#1:

#2:

Also thanks for the tip!

I see the font perfect lol

EDIT: I think its more of a illusion, trying drawing the string on a completely black or white screen, I think it will look perfect, probably the textures causing the illusion

I think that the ‘blurriness’ is coming from the fact that it seems like you have a ‘Shadow’ on your font. Typically this causes a ‘blurring’ behind the letters, but with certain color combinations/sizes, it can make the text look blurry as well.

Well, If I don’t add the ColorEffect to the font, the font simply will not draw… What should I do about that?

Do you mean the anti-aliasing looks too smooth? What are you trying to get it to look like?

I’d suggest using AngelCodeFont (create in TWL Font Tool and export as TEXT) if you don’t need unicode font support, and save multiple sizes that you’ll need. If you really need unicode fonts with different anti-aliasing, maybe try TWL as a GUI library.

I’ll take the AngelCodeFont approach… Thank you so much for your help!

You could also try applying the font size to the java.awt.font before creating the unicode font. That usually helps a bit.

Nitram

Can TWL do Unicode fonts? I think it can only do bitmap fonts, same as the AngelCodeFont in Slick. Of course, the bitmap font can have Unicode glyphs, but won’t have combining characters or on the-fly glyph rendering.

FreeType, used in the TWL Theme Editor and the BMFont tool, usually makes for the most crisp output. AWT, used in Hiero and UnicodeFont, is usually blurry at small sizes. The BMFont tool can do supersampling, which makes for nice antialiased glyphs (via FreeType). I posted some info here.