I use jasper reports 6.17.0. I have java application that uses jasper to export reports to PDF files. I set Arial font in my report but there is Helvetica font in exported PDF. I know how to fix it. I can add Arial font in Jasper Soft, export it and add to classpath. It is described on Jasper wiki. I also found solution on stackoverflow. As I wrote I know how to fix it but unfortunately I do not understand it. Jasper wiki title is Custom Font with the Font Extension
. I do not think that Arial is some custom font and I need font extension. As I understand Font Extension mechanism it allows to use custom font and guarantees 100% cross platform compatibility. But I do not need it, I want to use simple Arial and I do not need 100% cross platform compatibility.
In general, PDF files can contain 2 types of font. Embedded PDF fonts include all the actual details for drawing all the font characters while non-embedded fonts just include the name of the font and expect the system to find the font details. Arial font is accessible in Jasper Studio, it is also installed in my OS. Why I had to add it to classpath? As I understand Jasper wants to embed any font used in report. I do not know why jasper do it. As I understand PDF fonts I see two solutions:
- Jasper can export PDF file with non embedded fonts, only font name is set in PDF in this case. I do not know if PDF viewers can use system fonts but I think that they can.
- Jasper can take font from my OS and embeds it. Maybe there is some problem in my java environment that Arial is not accessible from it?
Jasper embeds Helvetica in PDF file even though I didn't add Helvetica font to classpath. I have a lot of jars so it is possible that some other jar contains Helvetica ttf but I checked that jasperreport.jar does not contain it. I do not know where Jasper gets Helvetica font from. Helvetica is one of standard PDF font. I checked that exported PDF files have 1.5 PDF version. According to PDF 1.5 specification:
• PDF prescribes a set of 14 standard fonts that can be used without prior definition. These include four faces each of three Latin text typefaces (Courier, Helvetica*, and Times*), as well as two symbolic fonts (Symbol and ITC Zapf Dingbats® ). These fonts, or suitable substitute fonts with the same metrics, are required to be available in all PDF viewer applications.
• A PDF file can refer by name to fonts that are not embedded in the PDF file. In this case, a viewer application will use those fonts if they are available in the viewer’s environment. This approach suffers from the uncertainties noted above.
As I understand Helvetica is standard PDF font and maybe jasper does not embed it in PDF file, I do not know.
Why does Jasper set Helvetica font in exported PDF even though Arial font is set in Jasper report?