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

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

Open
JanBuerger opened this issue Oct 31, 2023 · 5 comments
Open

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

JanBuerger opened this issue Oct 31, 2023 · 5 comments

Comments

@JanBuerger
Copy link

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 JanBuerger added the bug label Oct 31, 2023
@andreasrosdal
Copy link
Contributor

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.

@asturio
Copy link
Member

asturio commented Feb 23, 2024

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
Copy link
Member

asturio commented Feb 23, 2024

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

@asturio
Copy link
Member

asturio commented Mar 16, 2024

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 asturio added the documentation Docs, JavaDoc label Mar 16, 2024
@asturio
Copy link
Member

asturio commented Mar 16, 2024

Other thoughts:

  • Better documentation of Font and BaseFont.

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

3 participants