Jasper report can not load Japanese text with some fonts

Jaspersoft Community 'Read-Only' as of July 8, 2022

Transition to New TIBCO Community Just Weeks Away

You can still search, review wiki content, and review discussions in read-only mode. Please email community@tibco.com with questions or issues requiring TIBCO review or response.

I need print PDF report from Java application (Spring boot) which is can show Japanese characters and when change font, it has to show correctly font. My app using jasperreports-fonts-6.10.0.jar and setting in jasperreports_extension.properties is setting as below :

net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
net.sf.jasperreports.extension.registry.factory.fonts=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory
# font.xml place
net.sf.jasperreports.extension.simple.font.families.myfont=fonts/fonts.xml

and in fonts/fonts.xml, is setting as below :

 ....
<fontFamily name="Meiryo UI">
    <normal>fonts/Meiryo UI.ttf</normal>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
    <exportFonts>
    </exportFonts>
</fontFamily>
<fontFamily name="Tahoma">
    <normal>fonts/tahoma.ttf</normal>
    <bold>fonts/tahomabd.ttf</bold>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
<fontFamily name="MS UI Gothic">
    <normal>fonts/msgothic.ttc</normal>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
</fontFamily>
<fontFamily name="Times New Roman">
    <normal>fonts/times.ttf</normal>
    <pdfEncoding>Identity-H</pdfEncoding>
    <pdfEmbedded>true</pdfEmbedded>
</fontFamily>

and in Java code :

myReport.getDefaultStyle().setPdfFontName(newfontReport); // newfontReport is setting in DB

All of above fonts are existing in resource of web app. But it only show japansese text and englist text correctly in report with "Meiryo UI". Other fonts (ex : "Times New Roman"), it show englist text parts only , japansese text parts are invisiblity. Have got any one can be show me why ?

hungncv.apt's picture
Joined: Nov 24 2013 - 11:08pm
Last seen: 2 years 4 months ago

1 Answer:

You can create a font set extension to include fonts that are for english and japanese. The font set can be exported to a jar file which can be placed on the JR server under web-inf\lib dir. Detailed information regarding font extension is available in the TIBCO JasperSoft Studio guide. 

vchiem's picture
31488
Joined: May 1 2017 - 5:33pm
Last seen: 2 days 23 hours ago
Feedback