Hello, dear.
Given:
public static Font FONT = new Font("Arial", Font.PLAIN, 400);
taking into account the fact that the font and size may vary in runtime.
public static String TEXT = "SomeString";
taking into account the fact that the string may vary in runtime.
Need to:
Create a BufferedImage with sizes that match the size of the drawn line with the specified font.
The imag is created in a stream, only the above is known to the stream.
Now I am doing this with a crutch:
finalImage = new BufferedImage( (int) ( Config.FONT.getSize() * (Config.TEXT.length()) * 1.5 ), Config.FONT.getSize() * 2, BufferedImage.TYPE_INT_ARGB );
There is an option to learn the string bounds, knowing the context, but the context has not yet been created ...
I would like to see the options, how else can you find out the width of the string.
Thanks in advance!