Fonts

C

Click

Hi all,

I have a little problem with fonts. In my program, I need to create fonts.
So I use the constructor of the Font object, by doing this:

Font f=new Font(fontName, fontStyle, fontHeight);

But when I change the font name to anything present on my machine (like
"Elephant"), the font created is always the basic system one. If I change
the name to the name of a logical font like "Monospaced", then the correct
font is found.
If I do a getAllFont in the current GraphicEnvironment, I get the correct
list of all the fonts.

Would you know how I can create the font that I want?

Thanks in advance, Francois
 
C

Click

Click said:
I have a little problem with fonts. In my program, I need to create fonts.
So I use the constructor of the Font object, by doing this:

EDIT. I have found out that the problem only occurs in a Label. When I print
text on the screen using the draw function of textLayout, the font is
corectly displayed, meaning that the font is actually created by my new
Font().
I can successfully change the size of the font in the label.
Does anyone know why the Label object does not respond to my "setFont"
command? Is there something special to do to change fonts in a label?

Thanks, Francois
 
R

Roedy Green

But when I change the font name to anything present on my machine (like
"Elephant"), the font created is always the basic system one. If I change
the name to the name of a logical font like "Monospaced", then the correct
font is found.
If I do a getAllFont in the current GraphicEnvironment, I get the correct
list of all the fonts.

see http://mindprod.com/jgloss/font.html
to learn what fonts are supported and their precise spellings.
AWT only supports 5 fonts no matter how many you have installed.
 
R

Roedy Green

Does anyone know why the Label object does not respond to my "setFont"
command? Is there something special to do to change fonts in a label?

no. Just setFont. Write an SSCCE to that we can run to demonstrate
your problem. You are not showing us the part of your program that is
causing the trouble. see http://mindprod.com/jgloss/sscce.html

It is a bit like refusing to submit to a diagnostic blood test, but
instead submitting a artistic rendering of your blood to your
physician.
 

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
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top