libero Posted May 9, 2017 Share Posted May 9, 2017 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 More sharing options...
elizam Posted May 10, 2017 Share Posted May 10, 2017 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. Link to comment Share on other sites More sharing options...
libero Posted May 10, 2017 Author Share Posted May 10, 2017 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 More sharing options...
libero Posted May 11, 2017 Author Share Posted May 11, 2017 Hello,No one else an idea?libero Link to comment Share on other sites More sharing options...
cutebluangel Posted October 26, 2017 Share Posted October 26, 2017 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now