Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make RandomAccessFileOrArray to search in all registered directories #168

Closed
SuperPat45 opened this issue Apr 2, 2019 · 3 comments
Closed

Comments

@SuperPat45
Copy link
Contributor

SuperPat45 commented Apr 2, 2019

Using JasperReports with OpenPDF, I can not generate PDF report with embedded arial font:

net.sf.jasperreports.engine.JRRuntimeException: Could not load the following font:
pdfFontName: arialbd.ttf
pdfEncoding: Cp1252
isPdfEmbedded : true
at net.sf.jasperreports.engine.export.JRPdfExporter.getFont(JRPdfExporter.java:2335)

I notice, in the constructor of the com.lowagie.text.Document.RandomAccessFileOrArray class, the line:
File file = new File(filename);
fileName is in my case "arialbd.ttf" and not the full path name?
So It search in the current directory...

Before generating the jasper report, I call this line:
FontFactory.registerDirectories();
To fix my issue, I think the RandomAccessFileOrArray constructor must also search in all registered directories if filename is not a full path name.
In my case, the arialbd.ttf file can be found in C:\windows\fonts.

This kind of modification could not cause any regression.

Or at worst, we need a property to set the default font search folder to use in this class if filename is not a full path name.

@andreasrosdal
Copy link
Contributor

@SuperPat45 Thanks for reporting this. Pull-requests welcome!

@SuperPat45
Copy link
Contributor Author

Done

@andreasrosdal
Copy link
Contributor

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants