Java – jasperreports 5.6: unable to load the following fonts
•
Java
The problem I face is that Jasper reports still can't find the Arial font
I created a simple Maven project with the following structure and included it in my main application Therefore, the main application contains the installed jars in the classpath:
- jasperreports_extension.properties
- fonts
|-> arial
|-> ariali.ttf
|-> arialbi.ttf
|-> arialbd.ttf
|-> arial.ttf
|-> fonts.xml
However, when exporting the report to PDF, I still see the following exceptions
net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font : pdfFontName : Arial pdfEncoding : Identity-H isPdfEmbedded : true
jasperreports_ extension. properties
net.sf.jasperreports.extension.registry.factory.simple.font.families=net.sf.jasperreports.engine.fonts.SimpleFontExtensionsRegistryFactory net.sf.jasperreports.extension.simple.font.families.arial=fonts/fonts.xml
fonts. xml:
<?xml version="1.0" encoding="UTF-8"?>
<fontFamilies>
<fontFamily name="Arial">
<normal>fonts/arial/arial.ttf</normal>
<bold>fonts/arial/arialbd.ttf</bold>
<italic>fonts/arial/ariali.ttf</italic>
<boldItalic>fonts/arial/arialbi.ttf</boldItalic>
<pdfEncoding>Identity-H</pdfEncoding>
<pdfEmbedded>true</pdfEmbedded>
</fontFamily>
</fontFamilies>
Template
<font fontName="Arial" size="8" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
Solution
The problem is the template itself: the < fontname > property is missing at a font label:
Not working:
<font size="12" isBold="true" pdfFontName="Arial"/>
Work:
<font fontName="Arial" size="12" isBold="true" pdfFontName="Arial" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
