How can I set font name dynamically?

0

Hello,

I have a simple question but I fear there is no simple answer. I just want to set the font for a text field dynamically.

The content of the text field comes from the database and can include everthing. (Chinese or other characters or unicode).

I would like set the font name of the text field in a scriptlet methode. But it does not work. (see http://community.jaspersoft.com/questions/538566/problems-setfontname-dy...)

I want to use the method Font.canDisplayUpTo(...) to find the right font and then set it dynamically.

I know the font extensions, the conditional styles and the styled text features, but I could not solve my problem yet.

Has anyone an idea or a similar problem ever solved?

 

Thanks for any hint.

libero

 

libero's picture
79
Joined: Jul 23 2009 - 5:55am
Last seen: 1 year 6 months ago

4 Answers:

0

you might be able to use font sets.  i forget exactly which version they were introduced, 6.1 or 6.2 maybe.  they let you set up multiple font families as a set and say which font is used for which language.

elizam's picture
4668
Joined: Mar 5 2012 - 9:19am
Last seen: 1 week 5 days ago
0

Hello elizam,

thanks for your answer.

Do you mean the feature "font extensions"?

I know this feature but I don't want set a font for a special language (like Chinese). I want change the font name in the textfield depends on the content of the  textfield.

libero

 

libero's picture
79
Joined: Jul 23 2009 - 5:55am
Last seen: 1 year 6 months ago
0

Hello,

No one else an idea?

libero

 

 

libero's picture
79
Joined: Jul 23 2009 - 5:55am
Last seen: 1 year 6 months ago
0

We implemented something before using Conditional Styles. The condition was ReportUtils.hasChineseCharacters(<field>), where ReportUtils.hasChineseCharacters is a custom made Java function that is imported to the template. If it has, it uses the Chinese font, if it doesn't it uses the English font.

Down side is, we have to make a conditional style for each field that needs this.

cutebluangel's picture
Joined: Sep 23 2012 - 8:45pm
Last seen: 11 months 1 day ago
Feedback
randomness