Font Name string

J

Jenny

Hi,

I wrote a line

Font ft = new Font("Times New Roman",Font.BOLD,20);

It works.

Could you tell me why

Font ft = new Font("TimesRoman",Font.BOLD,20);

also work?

I checked the font names. I can only find the font name Times New
Roman on my PC, NOT "TimesRoman".

I use Windows 2000 and Java SDK 1.4.2.

Thanks a lot.
 
T

Thomas G. Marshall

Jenny said:
Hi,

I wrote a line

Font ft = new Font("Times New Roman",Font.BOLD,20);

It works.

Could you tell me why

Font ft = new Font("TimesRoman",Font.BOLD,20);

also work?

I checked the font names. I can only find the font name Times New
Roman on my PC, NOT "TimesRoman".

I use Windows 2000 and Java SDK 1.4.2.

Thanks a lot.

Did you try

Font ft = new Font("DwightSchmidlap",Font.BOLD,20);

? Perhaps there is a default? I dunno...
 
J

Jenny

Thomas G. Marshall said:
Did you try

Font ft = new Font("DwightSchmidlap",Font.BOLD,20);

? Perhaps there is a default? I dunno...

Had it used the default, it would not be BOLD and 20 points. It is not the default.
 
T

Thomas G. Marshall

Jenny said:
"Thomas G. Marshall"


Had it used the default, it would not be BOLD and 20 points. It is
not the default.

No no no. My question is: Is there a default for the /NAME/ ? That's why I
mentioned the test I did. It could see the dwightschmidlap, and substitute
a default name. The rest would be left alone.
 
F

Filip Larsen

Jenny wrote
Font ft = new Font("Times New Roman",Font.BOLD,20);
Font ft = new Font("TimesRoman",Font.BOLD,20);

I checked the font names. I can only find the font name Times New
Roman on my PC, NOT "TimesRoman".

Read the documentation for the Font(String,int,int) constructor and then
try run the following code and look carefully at the output from the two
fonts (look at the "family" value).

public class FontTest {
public static void main(String[] args) {
System.out.println(new java.awt.Font("Times New Roman",Font.BOLD,20));
System.out.println(new java.awt.Font("TimesRoman",Font.BOLD,20));
}
}



Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top