I added a new font for my project in java. However upon rendering it the text size is always at 1 it appears. The text basically appears as just a few little lines. I tried this with multiple fonts and they all did it. This is my code.
public static void intializeFonts(){
try{
File font = new File("C:/The Woods/Fonts/script.ttf");
Font scriptFontU = Font.createFont(Font.TRUETYPE_FONT, font);
Font scriptFont = scriptFontU.deriveFont(20);
script = new TrueTypeFont(scriptFont, false);
} catch(Exception e){
System.out.println("Error Loading Font");
}
}
This is also what I am using to render it if this helps.
g.setFont(Fonts.script);
g.drawString("Weight: "+ItemContainer.getWeight()+"lbs", 30, 600);
Any help would be great. Thank You.
When you call
scriptFontU.deriveFont(20), you are callingFont.deriveFont(int). In this function, the first argument is an integer representing a style. Instead, you want to callFont.deriveFont(float), which takes a size and leaves the style unchanged. You can do this by callingscriptFontU.deriveFont(20.0), or equivalent; or callFont.deriveFont(int, float)asscriptFontU.deriveFont(Font.PLAIN, 20.0)to make it unambiguous.