Java Reference
In-Depth Information
ately1/72ofaninch.(Othersupportedstylesare
PLAIN
,
ITALIC
,and
ITALIC
com-
bined with
BOLD.
) This object is then installed as the current font.
Thefontnamecanbea
font family name
(suchasArial)ora
font face name
(afont
familynamecombinedwithstyleinformation,suchasArialBold).Whenafontfamily
nameisspecified,the
style
argumentisusedtoselectthemostappropriatefacefrom
thefamily.Whenafontfacenameisspecified,theface'sstyleandthe
style
argument
are merged to locate the best matching font from the same family. For example, when
facename“ArialBold”isspecified withstyle
Font.ITALIC
,AWTlooksforaface
inthe“Arial”familythatisboldanditalic,andmayassociatethefontinstancewiththe
physicalfontface“ArialBoldItalic”. The
style
argumentismergedwiththespeci-
fiedface'sstyle,notaddedorsubtracted.Thismeans,specifyingaboldfaceandabold
style does not double-embolden the font, and specifying a bold face and a plain style
does not lighten the font.
Javasupportslogicalfontsandphysicalfonts.A
logical font
isafontthat'sguaranteed
to be supported on all platforms; pass one of
Font
's predefined
DIALOG
,
DIALOG_INPUT
,
MONOSPACED
,
SANS_SERIF
, and
SERIF String
constants to
Font()
to select a logical font. A
physical font
is a nonlogical font that may or may
not be supported on all platforms. Arial is an example of a widely supported physical
font—it's probably available on all the platforms where Java runs.
Caution
Becarefulwhenspecifyingafontnamebecausenotallfontsareavailable
onallplatforms.I'llshowyoulaterinthischapterhowyoucanidentifyallsupported
font family names.
Finally,thefourthstatementdraws
Hello
inthecurrentcolorandfontwithbaseline
at (
35
,
35
).
Ipreviouslydefined
baseline
asthelineservingasanoriginforthepurposeoflayout.
Thistermisalsodefinedasthelineseparatingafont'sascentfromitsdescent,as
Figure
7-8
illustrates.