Reputation: 23
I am writing an application which includes a .ttf file for the fonts of the GUI. Loading the font seems no problem, however when using deriveFont()
method to edit the size the font seems to be distorted (e.g. not on the same line, parts missing from letters, skewing,..).
Why is this? Is there a way round?
Code to load the font:
InputStream is = getClass().getResourceAsStream("/fonts/lg.ttf");
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
leagueGothic = Font.createFont(Font.TRUETYPE_FONT, is);
ge.registerFont(leagueGothic);
And then changing the size with deriveFont()
label.setFont(leagueGothic.deriveFont(Font.PLAIN, scale(50, 'x'));
scale(int, char)
is just a method to change the size proportional to the size of the application window, it returns an int
.
Upvotes: 2
Views: 277