phax / ph-pdf-layout

Java library for creating fluid page layouts with Apache PDFBox. Supporting multi-page tables, different page layouts etc.
Apache License 2.0
64 stars 11 forks source link

font Weight #24

Closed MahmoudBM6 closed 2 years ago

MahmoudBM6 commented 2 years ago

I m working with your dependencies, I have a table with titles etc ... The issue is that I wanted to set the PreloadFont of the title REGULAR and the text is REGULAR.MEDIUM but after the investigation that I did I couldn't find REGULAR.MEDIUM there's only REGULAR and REGULAR_BOLD there's no medium or light. So can we solve this problem.

phax commented 2 years ago

You need to know, that PDF ships with 14 fonts out of the box. These are the ones, for which the constants in PreloadFont have been created. The "regular" term in this class has nothing to do with font weight or so - for this "regular font face", only medium, bold, italic and bold italic are provided.

If you need more fine grained fonts, I suggest you look at https://github.com/phax/ph-pdf-layout/blob/master/src/test/java/com/helger/pdflayout/element/text/PLTextTest.java#L194 - it uses "OpenSans" which comes with a lot more different font weights.

To use the "opensans" font, you need to add a dependency in your pom.xml:

    <dependency>
      <groupId>com.helger.font</groupId>
      <artifactId>ph-fonts-open-sans</artifactId>
      <version>4.2.0</version>
    </dependency>

Other fonts are available at https://github.com/phax/ph-fonts

MahmoudBM6 commented 2 years ago

Thank you so much.