SlideShare a Scribd company logo
Working with Fonts
To draw text to the screen, first you need to create an instance of the Font class.

Font objects represent an individual font-that is, its name, style (bold, italic), and point size.

Font names are strings representing the family of the font, for example, "TimesRoman",
"Courier", or "Helvetica".

Font styles are constants defined by the Font class; you can get to them using class
variables-for example, Font.PLAIN, Font.BOLD, or Font.ITALIC.

Finally, the point size is the size of the font, as defined by the font itself; the point size may
or may not be the height of the characters.

To create an individual font object, use these three arguments to the Font class's new
constructor:

Font f = new Font("TimesRoman", Font.BOLD, 24);

This example creates a font object for the TimesRoman BOLD font, in 24 points. Note that
like most Java classes, you have to import the java.awt.Font class before you can use it.

The fonts you have available to you in your applets depend on which fonts are installed on
the system where the applet is running. If you pick a font for your applet and that font isn't
available on the current system, Java will substitute a default font (usually Courier).
Lecture5 oopj

More Related Content

Viewers also liked (10)

DOCX
Lecture3 oopj
Dhairya Joshi
 
PPTX
02 Hidup ini Pilihan
tsabitamuninggar
 
PDF
Wake Up, Girls!の風景解析 と 眺望写真公開リスクへの警鐘
kumarobo
 
DOCX
Makalah sosialisasi dan pembentukan kepribadian sma 1 raha
Operator Warnet Vast Raha
 
PPTX
como cuidar la seguridad delinternet
Nelson Guaranga
 
PDF
Shape based plagiarism detection for flowchart figures in texts
ijcsit
 
PPTX
Vision cascade effect
Srinivason U
 
PPTX
Ppt modul 15
Agustin Puspita Sari
 
PPTX
Pertemuan 8 _uml_activity_diagram
titoagung
 
DOCX
Surat peryataan
Operator Warnet Vast Raha
 
Lecture3 oopj
Dhairya Joshi
 
02 Hidup ini Pilihan
tsabitamuninggar
 
Wake Up, Girls!の風景解析 と 眺望写真公開リスクへの警鐘
kumarobo
 
Makalah sosialisasi dan pembentukan kepribadian sma 1 raha
Operator Warnet Vast Raha
 
como cuidar la seguridad delinternet
Nelson Guaranga
 
Shape based plagiarism detection for flowchart figures in texts
ijcsit
 
Vision cascade effect
Srinivason U
 
Ppt modul 15
Agustin Puspita Sari
 
Pertemuan 8 _uml_activity_diagram
titoagung
 

Similar to Lecture5 oopj (12)

PPT
Working with color and font
myrajendra
 
PPTX
Elem of design unit 7 module 2 investigation of fonts
kateridrex
 
PPSX
Font
karan singh
 
PPT
Client Side Programming with Applet
backdoor
 
PPT
10 typeface basics.fi_xed
Lorraine Stratton
 
PPTX
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
VishnuMenon59
 
PDF
Typograph typing matter which contents colours
mashalkhan0833
 
PPTX
Character Attribute in computer graphics
HariTharshiniBscIT1
 
PPT
Lecture 4 text
Mr SMAK
 
PPT
Lecture 4 text
Mr SMAK
 
PPT
Lecture6 text
Jay Patel
 
PPT
Lecture6 text
Jay Patel
 
Working with color and font
myrajendra
 
Elem of design unit 7 module 2 investigation of fonts
kateridrex
 
Client Side Programming with Applet
backdoor
 
10 typeface basics.fi_xed
Lorraine Stratton
 
Loading viewing/listening to Image and Audio, Fonts, Colors in Java
VishnuMenon59
 
Typograph typing matter which contents colours
mashalkhan0833
 
Character Attribute in computer graphics
HariTharshiniBscIT1
 
Lecture 4 text
Mr SMAK
 
Lecture 4 text
Mr SMAK
 
Lecture6 text
Jay Patel
 
Lecture6 text
Jay Patel
 
Ad

Lecture5 oopj

  • 1. Working with Fonts To draw text to the screen, first you need to create an instance of the Font class. Font objects represent an individual font-that is, its name, style (bold, italic), and point size. Font names are strings representing the family of the font, for example, "TimesRoman", "Courier", or "Helvetica". Font styles are constants defined by the Font class; you can get to them using class variables-for example, Font.PLAIN, Font.BOLD, or Font.ITALIC. Finally, the point size is the size of the font, as defined by the font itself; the point size may or may not be the height of the characters. To create an individual font object, use these three arguments to the Font class's new constructor: Font f = new Font("TimesRoman", Font.BOLD, 24); This example creates a font object for the TimesRoman BOLD font, in 24 points. Note that like most Java classes, you have to import the java.awt.Font class before you can use it. The fonts you have available to you in your applets depend on which fonts are installed on the system where the applet is running. If you pick a font for your applet and that font isn't available on the current system, Java will substitute a default font (usually Courier).