cutebluangel Posted March 23, 2018 Share Posted March 23, 2018 I have coded a report that utilizes the system font Times New Roman.I did not include any font jars but is relying on the idea that Jasper Reports should be able to utilize system fonts.I used the viewer to view the preview in Jasper Studio, the fonts correctly renders.When I tried exporting it to PDF, the Font Properties of the generated output shows that it utilized the following font:Helvetica Type: Type1 Encoding: Ansi Actual Font: Arial Actual Font Type: TrueTypeThis is very far from the Times New Roman that I was expecting.I also tried generating the report via a simple java program and set the logging to trace for the jasperreports class files.A portion of the log file is pasted in https://pastebin.com/SnTptaHS.It seems to show that it used java.awtFont using family = Times New Roman (lines 2-7 and lot of other lines). My test font set which is called Test Font seems to be replaced by font with family = Dialog (lines 18-24 and lines 13-36), which honestly, I expect parts of the reports set to the non-existing font set to go bonkers since I did not put the font extension jar in the class file.So I'm wondering why it still used Helvetica which is the default PDF font. O.S. Windows 10Jasper Reports version: 6.4.3 Link to comment Share on other sites More sharing options...
Friendly User Posted March 27, 2018 Share Posted March 27, 2018 Try to use the deprecated property called pdfFontName in advanced section and select Times Roman there. It defaults to Helvetica. It is highly recommended though not to rely on system fonts and use font extension JAR's instead for a guaranteed result Link to comment Share on other sites More sharing options...
cutebluangel Posted March 27, 2018 Author Share Posted March 27, 2018 Do you mean the Times-Roman Standard Type 1 font? I suppose for this case and other Standard Type 1 PDF fonts it is workable. But what if it is fonts like Calibri or Comics Sans? We have no other way to utilize these system fonts than to include in font jars and link to the project classpath that generates my jasper reports? Link to comment Share on other sites More sharing options...
Solution Friendly User Posted March 27, 2018 Solution Share Posted March 27, 2018 You can do that but you'll need to register extra fonts with the iText library. iText is used when exporting to PDF and it doesn't pay attention to the fontName unless the font can be found in the font extension. Considering the amount of effort it takes to register a font with iText or to create a font extension, I'd go with a Font Extension since it's much more streamlined. You can do that right in the studio. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now