Font Metrics

Sometimes it’s necessary to get information about the current drawing font, such as its name, style and size. Several Font methods used to get font information are summarized in Fig. 13.10. Method getStyle returns an integer value representing the current style. The integer value returned is either Font.PLAIN, Font.ITALIC, Font.BOLD or the combination of Font.ITALIC and Font.BOLD. Method getFamily returns the name of the font family to which the current font belongs. The name of the font family is platform specific. Font methods are also available to test the style of the current font, and these too are summarized in Fig. 13.10. Methods isPlain, isBold and isItalic return true if the current font style is plain, bold or italic, ...

Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.