Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Problem with Farsi fonts for dynamic text in iReport

  Asked By: Bailey    Date: Jul 12    Category: Java    Views: 3264
  

in iReport:
I have a dynamic text in my report that gets value with this expression:

Text Field Expression:
(($V{P_PARAM}.equals("1")) ? "FARSI TEXT 1"
:(($V{P_PARAM}.equals("2"))? "FARSI TEXT 2"
)))

But when I run it, Farsi texts are shown as: ?????????

Do you have any suggestion?

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Nicholas Wells     Answered On: Jul 12

Set font to something you want and then put font file with TTF extension to your classpath. I had this problem  yesterday and it solved this way!

 
Answer #2    Answered By: Lily Brown     Answered On: Jul 12

But I don't have problem  with Farsi fonts  in regular text  fields.
I have my fonts in classpath. I have another text fields in this report  with the
same font.I have problem only with dynamic  texts as an "expression".

 
Answer #3    Answered By: Umaiza Hashmi     Answered On: Jul 12

I have a good solution to showing Persian text  to any export (pdf, word, html)

The problem  is some exports like pdf can not resolve Persian fonts  and you can not pass your text to parameter.

You need just convert your text to Unicode by \u0xxxx format and pass it to your parameter instead of original text.

public String toUnicode(String originalText)
{
String outPutText = new String();
boolean asciiText = false;
for(int i = 0; i < originalText.length(); i++)
if(originalText.substring(i, i + 1).compareTo("0") >= 0 && originalText.substring(i, i + 1).compareTo("9") <= 0)
{
int ii = Character.getNumericValue(originalText.charAt(i)) + 1632;
char ch = (char)ii;
outPutText = outPutText + Character.toString(ch);
} else
{
outPutText = outPutText + originalText.charAt(i);
}

return outPutText != null ? outPutText : "";
}

public String toAnsii(String unicodeText)
{
String outPutText = new String();
String wordTmp = new String();
int iii = 0;
int Len = 0;
int unicodeIndex = 0;
int asciiIndex = 0;
char c = '\0';
int i = 0;
do
if(i < unicodeText.length())
{
c = unicodeText.charAt(i);
if(c == '\\')
{
i++;
c = unicodeText.charAt(i);
switch(c)
{
case 117: // 'u'
outPutText = outPutText + (char)Integer.parseInt(unicodeText.substring(i + 1, i + 5).toString(), 16);
i += 5;
break;
}
} else
{
outPutText = outPutText + c;
i++;
}
} else
{
return outPutText != null ? outPutText : "";
}
while(true);
}

I hope can be resolved your problem, but If you feel your problem is remaing, I can send you a sample project.

 
Answer #4    Answered By: Barachias Levi     Answered On: Jul 12

Thank you indeed for your help.
My problem  is resolved in this way.

 
Answer #5    Answered By: Naomi Lee     Answered On: Jul 12

Try this:
In the iReport properties window for the expression, turn on the "PDF Embedded"
and choose the "Identity-H (Unicode with horizontal writing)" for the PDF
Encoding. Set the PDF Font to the ttf font you copied in your classes directory.
hope it works

 
Answer #6    Answered By: Hassan Bagheri     Answered On: Jan 16

I've the same problem
but where should i put this codes?

 
Didn't find what you were looking for? Find more on Problem with Farsi fonts for dynamic text in iReport Or get search suggestion and latest updates.




Tagged: