TrueType Fonts

E

Esteban

Hello,

I'm trying to have my Linux Java use the truetype fonts I've imported from
Windows. These are ok, because I can use them with OpenOffice but when I
do component.setFont(new Font("Comic Sans MS", Font.BOLD, 12)) nothing
happens in Linux as in Windows... it works !

What can I do ?

Thank you.
 
B

bOOyah

I'm trying to have my Linux Java use the truetype fonts I've imported from
Windows. These are ok, because I can use them with OpenOffice but when I
do component.setFont(new Font("Comic Sans MS", Font.BOLD, 12)) nothing
happens in Linux as in Windows... it works !

What can I do ?

On Linux, the fonts used by the JRE aren't the same as the fonts used
by the XFree system. Just because you have made your Windows TTFs
available to Linux users doesn't mean you have simultaneously made
them available to your Java apps.

You need to put all the TrueType fonts you want to use into your "jre
\lib\fonts" directory.

Alternatively you could move the existing JRE fonts directory out of
the way and symlink to your XFree TrueType directory. That way any
new TTFs you add to Linux will also be available to your Java apps.

prompt# cd <JRE_HOME>/jre/lib
prompt# cp ./fonts/* /usr/X11R6/lib/X11/fonts/truetype
prompt# mv fonts fonts.orig
prompt# ln -s /usr/X11R6/lib/X11/fonts/truetype fonts

(My TTFs are stored in /usr/X11R6/lib/X11/fonts/truetype).

Remember, you will have to repeat this step when you install a new
JRE.

Hope this helps.
 
B

bOOyah

Oh ok, thank you for your answer !

No problems!

One more thing to be aware of:
I don't know what Linux distro you are using. If it is a very recent
one it probably uses the fontconfig package to manage fonts in XFree;
(Mandrake 9.1 and Redhat 9 (8 too?)) for example. If your distro has
a directory called /etc/fonts then you are probably in this camp.

However, earlier Linuxes didn't use fontconfig, so you might have to
recreate the fonts.scale and fonts.dir files in your X11 truetype
fonts directory after you have copied the JRE TTFs into it.
Otherwise they won't be "detected" by XFree.

prompt# cd /usr/X11R6/lib/X11/fonts/truetype
prompt# ttmkfdir > fonts.dir
prompt# cp fonts.dir fonts.scale

That should do it (I'm working from memory here).

Hope this helps again!
 

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

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top