3

In my job we have to use an specific font type, is Futura std medium.

I have a JFrame where I write, and I need to do with this font type. I have the OTF document, but I cant find the way to import it in my code.

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1256477
  • 10,763
  • 7
  • 38
  • 62

1 Answers1

7

Did you try to check this answer about OTF in Java :

How to use Custom Font in Java and Use OTF in Java

I think it could help you.

Community
  • 1
  • 1
ChapMic
  • 26,954
  • 1
  • 21
  • 20
  • Thank you very much! it helps a lot! But I have an Exception which I cant understand, my code: InputStream is = this.getClass().getResourceAsStream("/font/futura.otf"); Font fontTitle2 = Font.createFont(Font.TRUETYPE_FONT, is); And the exception: java.awt.FontFormatException: Unsupported sfnt C:\Users\RGOMEZ~1.ING\AppData\Local\Temp\+~JF2701312787789218051.tmp at sun.font.TrueTypeFont.init(Unknown Source) at sun.font.TrueTypeFont.(Unknown Source) at sun.font.FontManager.createFont2D(Unknown Source) at java.awt.Font.(Unknown Source) Thank you in advance – user1256477 May 03 '12 at 13:55
  • You can see an example about how to resolve it : http://forums.devshed.com/java-help-9/adding-a-ttf-font-from-an-inputstream-using-createfont-derivefont-613660.html Could you accept my answer if it helped you ? Thanks. – ChapMic May 03 '12 at 20:33
  • I've found it before, but, I have 2 fonts and it only works with one of them. The other one: nd the exception: java.awt.FontFormatException: Unsupported sfnt C:\Users\RGOMEZ~1.ING\AppData\Local\Temp\+~JF2701312787789218051.tmp – user1256477 May 04 '12 at 06:55