This must be really simple, but I don't know how to do it. Laugh as long as you can ;-)
How do we specify custom font files to be used for output like drawString? g.SetFont doesn't seem to need the filename, then what does it need?
by custom I am assuming you mean just anything except for the default? Also I am not sure about your intended output format, however I can only tell you about screen components. Sorry.
You can either create creat a Font object specifying the font name size and effects such as bold or itlaic etc. This is recommended if you are going to need to reuse the font for several components.
e.g. Font myFont = new Font("Serif", BOLD, 24);
The just add this object to the component you want to change the font of by using the setFont method of the JComponent class.
e.g.
JLabel myLabel = new JLabel("FREDDY"
myLable.setFont(myFont);
or of course you can create the font object on the fly (better if you only need to use it in one or two places).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.