Changing the font size in Java

I have my own custom font that works in Java, but I have one problem, the font size seems to remain at 1. I tried font.deriveFont(20.0f); according to my initialization method, but it did not change.

 try { font = Font.createFont(Font.TRUETYPE_FONT, new File("D:/StanJump/mailrays.ttf")); font.deriveFont(20.0f); } catch (Exception ex) {} 

This is my code for creating the font and trying to resize it, but that didn't work. Any help on getting it to work, please?

+4
source share
1 answer

deriveFont returns a link to a new font instance. So you need to assign it back to the font, for example.

 font = font.deriveFont(20.0f); 
+10
source

All Articles