Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I wanted to use Monaco.ttf with IntelliJ. Unfortunately it doesn't show up.

I also noticed that the Monaco font doesn't appear in the list of fonts got from awt:

java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()

I installed Monaco.ttf in /usr/share/fonts/truetype/osx

I also tried to copy it in /usr/lib/jvm/java-6-sun/jre/lib/fonts and even tried to manually update the /usr/lib/jvm/java-6-sun/jre/lib/fonts/fonts.dir file

I restarted the jvm at each try, but the fonts is not visible from the sun jdk.

All other applications see that font (even eclipse, which is in java but uses the SWT library)

Does anybody know how to make jdk see additional fonts?

share|improve this question
add comment

4 Answers 4

up vote 2 down vote accepted

The problem is with the Monaco font itself, it doesn't seem to have appropriate metadata and is a hacky port, so Java doesn't recognize it. Probably you can find some other version of this TTF file which will work better or try to fix it yourself using FontForge.

See also my comment in the IntelliJ IDEA issue tracker.

share|improve this answer
add comment

Have you tried calling:

java.awt.GraphicsEnvironment.getAllFonts()

It seems that the Java font system is kinda messed up:

http://www.sabi.co.uk/Notes/linuxFonts.html#fontSwJava

You may have to work around issues with finding the fonts. But if eclipse can see the font, then there is no reason why your application can not. You can even choose to look at the eclipse code to see how they've done it.

http://java.sun.com/products/java-media/2D/reference/faqs/#Font_and_Text_questions

share|improve this answer
    
I tried getAllFonts() as well, "Monaco" is not there. Actually I don't know which method is invoked by intellij, but nevertheless there are some (a lot of) fonts visible in awt apps but not all of them. Thanks for the references –  ithkuil Jan 20 '11 at 19:24
    
FYI - your second link is now broken. –  Duncan Mar 27 at 8:25
add comment

You need to run the mkfontscale and mkfontdir utilities in this order, in order to update the fonts.dir file.

Enter the /usr/lib/jvm/java-6-sun/jre/lib/fonts directory from your terminal and run

sudo mkfontscale
sudo mkfontdir

mkfontscale creates the fonts.scale file which mkfontdir can use to create fonts.dir.

share|improve this answer
    
mkfontdir created file containing only "0". I guess it doesn't work for ttf fonts. Anyway I manually edited the fonts.dir file with "Monaco.ttf -b&h-monaco-medium-r-normal--0-0-0-0-p-0-iso8859-1" and updated the count, but the font didn't appear. –  ithkuil Jan 20 '11 at 19:30
    
See my update that helps create fonts.dir for Truetype fonts. –  user4124 Jan 26 '11 at 13:57
add comment

Update your font cache

sudo fc-cache -f -v
share|improve this answer
    
Unfortunately it doesn't help. I didn't add the Monaco font right now. The font cache is updated and native applications can see the fonts without problems; it's just java (AWT) that cannot see it, and I'm wondering how to add it. –  ithkuil Jan 20 '11 at 19:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.