The java.awt.Font and FontMetrics Class
Graphicsinstance.setFont(particularFont) will set the current Font in the instance Graphicsinstance of the Graphics class to the value particularFont of class Font.
The class Font has an important constructor used as in
Font MyFont = new Font("TimesRoman", Font.PLAIN ,36);
- where one can also use Courier, Helvetica, ZapfDingbats, . . ., Monospaced, Serif, SansSerif, Dialog
- Font.PLAIN, Font.BOLD, Font.ITALIC are possible text styles
FontMetrics fm = getFontMetrics(particularFont); // allows one to find out about the font
- fm.stringWidth("text"); // returns pixel width of string "text"
- fm.getHeight(); // returns total height of highest Font character
- getAscent(),
- getDescent(),
- getLeading(),
Drawstring uses leftmost baseline point as (x,y)