asciidocfx / AsciidocFX

Asciidoc Editor and Toolchain written with JavaFX 21 (Build PDF, Epub, Mobi and HTML books, documents and slides)
http://www.asciidocfx.com/
Apache License 2.0
1.91k stars 297 forks source link

PDF fonts are set up incorrectly #337

Open stallio opened 6 years ago

stallio commented 6 years ago

PDF fonts are controlled by the following lines from docbook-config/fo-pdf.xsl:

<xsl:template name="pickfont-sans">
    <xsl:text>Sans-serif,Arial,Arial Unicode MS,Helvetica,serif,Georgia,Times New Roman</xsl:text>
</xsl:template>

<xsl:template name="pickfont-serif">
    <xsl:text>Sans-serif,Arial,Arial Unicode MS,Helvetica,serif,Georgia,Times New Roman</xsl:text>
</xsl:template>

The first issue here is that both templates contain all the same fonts, but the first template should contain only sans-serif fonts and the second should contain only serif fonts.

The second issue is that the fonts are listed in reverse order. They should be listed in order of preference with the absolute fallback (serif or sans-serif) last.

As a result, almost all text in the PDF is rendered in Arial or Helvetica (the fallback for sans-serif).

The templates should look more like this:

<xsl:template name="pickfont-sans">
    <xsl:text>Helvetica,Arial Unicode MS,Arial,Sans-serif</xsl:text>
</xsl:template>

<xsl:template name="pickfont-serif">
    <xsl:text>Times New Roman,Georgia,serif</xsl:text>
</xsl:template>
rahmanusta commented 6 years ago

Hi @stallio, can you make a pull request for that? And can you share a PDF output about how it looks like? Thanks.

stallio commented 6 years ago

Here's a screenshot of a PDF out of the box. All text is in Arial (default sans-serif font on Windows):

screenshot 6323

Here's the same PDF with the fonts fixed as I described above. The heading now correctly uses Times New Roman (a serif font):

screenshot 6324