OpenPDF icon indicating copy to clipboard operation
OpenPDF copied to clipboard

Font contructor won't load font anymore (with workaround)

Open JanBuerger opened this issue 1 year ago • 5 comments

This isn't setting the font to courier anymore, it defaults to LiberationSans : final Font font = new Font(Font.COURIER, fontsize, Font.NORMAL) final PdfPCell c = new PdfPCell(new Phrase(myText, font));

image

This seems to fix it: final Font font = fontFactoryImp.getFont("Courier", fontsize, 0); final PdfPCell c = new PdfPCell(new Phrase(myText, font)); image

Can you please remove or update the broken Font constructor?

JanBuerger avatar Oct 31 '23 14:10 JanBuerger

This is the Font class in OpenPDF: https://github.com/LibrePDF/OpenPDF/blob/master/openpdf/src/main/java/com/lowagie/text/Font.java#L73

Can you please describe how to fix the constructor in this class? Pull requests welcome.

andreasrosdal avatar Dec 01 '23 11:12 andreasrosdal

The Font() constructor is fine. This works as expected:

Font font = new Font(Font.COURIER, Font.DEFAULTSIZE, Font.NORMAL);
document.add(new Phrase("Hello World", font));

grafik

asturio avatar Feb 23 '24 14:02 asturio

The Problem may be in PdfPCell. Can you share some (minimal) code to demonstrate the problem?

asturio avatar Feb 23 '24 14:02 asturio

Things to do here:

  • Check the behavior of both Font creations and compare why Liberation is used in the first example.

@JanBuerger , is the problem solved in any new version of OpenPDF?

asturio avatar Mar 16 '24 19:03 asturio

Other thoughts:

  • Better documentation of Font and BaseFont.

asturio avatar Mar 16 '24 19:03 asturio