Jump to content
We've recently updated our Privacy Statement, available here ×

How can I set font name dynamically?


libero

Recommended Posts

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-dynamically)

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

 

Link to comment
Share on other sites

  • Replies 4
  • Created
  • Last Reply

Top Posters In This Topic

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

 

Link to comment
Share on other sites

  • 5 months later...

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.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...