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
Click - 21 Sep 2007 09:21 GMT
> 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
Roedy Green - 22 Sep 2007 00:53 GMT
>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.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Andrew Thompson - 21 Sep 2007 09:30 GMT
...
>Would you know how I can create the font that I want?
I suspect FontShower (or variants - see page for links)
should be able to explain this.
<http://mindprod.com/applet/fontshower.html>

Signature
Andrew Thompson
http://www.athompson.info/andrew/
Roedy Green - 22 Sep 2007 00:51 GMT
>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.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com