My tool basically read the PDF and print the pdf's content in JTextArea
. Everything working fine until my PDF contains PH Mirjan fonts for Arabic. My text area shows some junk character as per below.
How do I solve this?
My default font for the text area is Arial Unicode MS. Is there anyway I can configure the text area's font to take? Let say I downloaded PH Mirjan in my local, how to change the text area font to the downloaded one. Any advice or references links is highly appreciated.
EDIT
try (InputStream is = NewJFrame.class.getResourceAsStream("/GE SS Two Bold.otf"))
{
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
font = font.deriveFont(Font.PLAIN, 24f);
jTextArea1.setFont(font);
jTextArea1.setForeground(Color.BLUE);
and its give me this Exception.
Exception
java.awt.FontFormatException: java.nio.BufferUnderflowException at sun.font.TrueTypeFont.init(TrueTypeFont.java:558) at sun.font.TrueTypeFont.(TrueTypeFont.java:191) at sun.font.CFontManager.createFont2D(CFontManager.java:161) at java.awt.Font.(Font.java:614) at java.awt.Font.createFont0(Font.java:968) at java.awt.Font.createFont(Font.java:876)
Any idea why i'm getting this.?