OpenPDF
OpenPDF copied to clipboard
Font contructor won't load font anymore (with workaround)
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));
This seems to fix it:
final Font font = fontFactoryImp.getFont("Courier", fontsize, 0);
final PdfPCell c = new PdfPCell(new Phrase(myText, font));
Can you please remove or update the broken Font constructor?
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.
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));
The Problem may be in PdfPCell. Can you share some (minimal) code to demonstrate the problem?
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?
Other thoughts:
- Better documentation of Font and BaseFont.