Openpdf: JasperReports - Export PDF - Bold fonts are too thick

Created on 22 Aug 2019  路  6Comments  路  Source: LibrePDF/OpenPDF

Hello,

I'm using Jasperreports and switched from itext to openpdf.
Unfortunately the bold fonts when exporting the report to pdf are too thick.

I've made a sample project to show you: https://github.com/razilein/openpdf-test

When switching between itext and openpdf you can see a huge difference between the bold and italic text.

On the left you can see the exported pdf with openpdf on the right with itext
image

Do you know a workaround or can you fix this please?

bug help wanted

Most helpful comment

Hi, sorry for the delay. Yes, I think your suggestion is the right way to go. As some fonts are present in the style you need, you should use that font (courrier-bold.ttf in normal style), instead of the normal font ("courrier.ttf" in bold style). The second option should only be used if the "bold" font is not present.
Tests and Merge requests welcome :-)

All 6 comments

Hello,
I found the commit responsible for this behaviour:

https://github.com/LibrePDF/OpenPDF/commit/9cf326d21562a90ff86afa5632b5a652f2e2ebdd

There is Unit Test associated to this commit, that is great!
But even with this I can't figure out how to solve the issue.

Lets say, we want a font in bold for example "Courrier"
This is what I understand about this code:

  • getting all fonts that contains "Courrier" int the FontFamillyMap,
  • searching for one that contains "bold" in its name

So at the end we are creating a font with name "courrier-bold" and that will be rendered in Bold.
In the PDF we render the text as Courrier Bold Bold

See: #106 @noavarice

The problem here, is to be able to make a difference between:

  • the font family and its style using the API
  • the real font used at PDF rendering time

This way we would be able to manipulate Courrier Font in Bold style through the API, and use courrier-bold in normal style at render time.

Do you agree?

@asturio I'd like your advice on this one, if you it's possible

Hi, sorry for the delay. Yes, I think your suggestion is the right way to go. As some fonts are present in the style you need, you should use that font (courrier-bold.ttf in normal style), instead of the normal font ("courrier.ttf" in bold style). The second option should only be used if the "bold" font is not present.
Tests and Merge requests welcome :-)

I've created the pullrequest #262

Was this page helpful?
0 / 5 - 0 ratings