Jasper report, load multiple Font Extension

感情迁移 提交于 2020-01-25 07:29:09

问题


i want my Jasper Report to support something like 5 or 6 languages dynamically.

i wish to use the google noto-sans font (www.google.com/get/noto) and google noto, have a single file for each language, (beside the main font file )

should i create a couple of font extensions and add them to my classpath ?

following my previous question How to get non-english support when exporting to PDF?


回答1:


In the jasper report you have

<font fontName="google_noto"/>

Related to this font you can only have 1 font-extension with the family name google_noto (containing the font for normal, bold, italic etc).

You can't switch this font extension dynamically the solution would be:

  1. Use a font that contains all relative language.

  2. Create a different jrxml (reports) for the different language with different fontName and the create font-extension with all the different family names:

    //report in English
    <font fontName="google_noto_en"/>
    //report in Italian        
    <font fontName="google_noto_it"/>
    

A work around would be to indicate fake font, disable errors for missing font and switch the default font as you like before generating report.

net.sf.jasperreports.awt.ignore.missing.font="true"
net.sf.jasperreports.default.font.name="google_en"

This question is about setting properties JRProperties became deprecated, recommended way of replacing

However, I would strong recommend and choose: "1. Use a font that contains all relative language"




回答2:


there is a way to do this...

you can put multiple textbox fields and on individual textbox use single font name which you want to display. the benfit would be if some font is not rendered in google_noto, then that textbox will show nothing(blank) and if that font is rendered in google_noto1 then that textbox will display that text.

I hope it works fine (Y)



来源:https://stackoverflow.com/questions/35631571/jasper-report-load-multiple-font-extension

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!