LWJGL Forum

Programming => OpenGL => Topic started by: BitFracture on April 04, 2013, 21:34:25

Title: TrueTypeFont Lower Case Letter Drawing Failure
Post by: BitFracture on April 04, 2013, 21:34:25
I don't know if it is appropriate to post about Slick, but I am using it with LWJGL and I have a problem drawing TrueTypeFonts.  

When I insert lower-case characters into the string of text to be drawn, the drawing stops before that character is drawn.  So "ASDFG" draws perfectly, but "ASDbCD" will only draw "ASD" and any text will end at spaces as well.  Shifted special characters (Above numbers) work fine, as do numbers.  Just lowercase letters will not work.  

Font loading code:

   public static TrueTypeFont LoadFont(String FileName, int Type, float Size, boolean Antialias)
   {
       TrueTypeFont font = null;
       // load font from a .ttf file
       try
       {
           InputStream inputStream = ResourceLoader.getResourceAsStream(FileName);
           
           Font awtFont = Font.createFont(Font.TRUETYPE_FONT, inputStream);
           awtFont = awtFont.deriveFont(Size); // set font size
           font = new TrueTypeFont(awtFont, Antialias);
       }
       catch (Exception e)
       {
           infoBox("The TrueTypeFont ("+FileName+") could not be loaded.","Font loading error!");
           e.printStackTrace();
       }  
       
       return font;
   }


Font drawing code:

   public static void DrawText(TrueTypeFont Font, int x, int y, String string, ColorRGB color)
   {
       
       Font.drawString(x, y, string, color.toSlick());  //The function toSlick() converts my own color object into the Slick color object
   }


The code comments explain any unusual things.  Please let me know if you see a problem!  I am aware TrueTypeFonts are depreciated, however that is what I want my game to use for my own reasons.  I would like to draw all standard English characters.  Any help is appreciated!

-BitFracture


EDIT:

Thought my imports may help as well.
import java.awt.Font;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

//Library imports
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.DisplayMode;
import static org.lwjgl.opengl.GL11.*;

//Slick loader imports
import org.newdawn.slick.Color;
import org.newdawn.slick.opengl.Texture;
import org.newdawn.slick.opengl.TextureLoader;
import org.newdawn.slick.util.ResourceLoader;

//Custom imports
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import org.newdawn.slick.TrueTypeFont;
Title: Re: TrueTypeFont Lower Case Letter Drawing Failure
Post by: BitFracture on April 08, 2013, 21:11:12
I am quite disappointed that nobody has been able to help me with this problem that is likely not that hard to fix...