metanorma / metanorma-iso

Metanorma processor for ISO standards
BSD 2-Clause "Simplified" License
13 stars 5 forks source link

PDF: Custom charset when using "FreeSerif" font uses Italics instead of Regular #1072

Closed ronaldtse closed 8 months ago

ronaldtse commented 8 months ago

From:

Screenshot 2023-12-22 at 10 33 39 AM Screenshot 2023-12-22 at 10 33 45 AM
:fonts: D050000L;TeXGyreTermes;STIX Two Math;FreeSerif;FreeSans
:presentation-metadata-custom-charset-font: dingbats:"D050000L",agl:"TeXGyreTermes",math:"STIX Two Math",serif:"FreeSerif",sans:"FreeSans"
  - name: registersans
    entity: "[custom-charset: sans]#®#"
    code: 342

  - name: registerserif
    entity: "[custom-charset: serif]#®#"
    code: 322
Intelligent2013 commented 8 months ago

Very strange issue. No italic in In XSL-FO:

<fo:table-cell display-align="before" padding-left="1mm" padding-right="1mm" padding-top="0.5mm" border="0.5pt solid black" text-align="left">
    <fo:block role="SKIP">
        <fo:inline font-family="FreeSans">™</fo:inline>
    </fo:block>
</fo:table-cell>

Glyph in PDF renders as italic (blue T icon): image

Intelligent2013 commented 8 months ago

The issue in FOP font config generation. The FreeSans italic font file name is FreeSansOblique.ttf (vs. FreeSerifItalic.ttf). mn2pdf doesn't recognize the font as 'italic' by word Oblique in the file name, only Italic:

                <font embed-url="file:/C:/Users/IntlUser/.fontist/fonts/FreeSerifBoldItalic.ttf" kerning="yes" mn_default="false">
                    <font-triplet name="FreeSerif" style="italic" weight="bold"/>
                </font>
                <font embed-url="file:/C:/Users/IntlUser/.fontist/fonts/FreeSerifItalic.ttf" kerning="yes" mn_default="false">
                    <font-triplet name="FreeSerif" style="italic" weight="normal"/>
                </font>
...
                <font embed-url="file:/C:/Users/IntlUser/.fontist/fonts/FreeSansBoldOblique.ttf" kerning="yes" mn_default="false">
                    <font-triplet name="FreeSans" style="normal" weight="bold"/>
                </font>
                <font embed-url="file:/C:/Users/IntlUser/.fontist/fonts/FreeSansOblique.ttf" kerning="yes" mn_default="false">
                    <font-triplet name="FreeSans" style="normal" weight="normal"/>
                </font>

Apache FOP sees the last entry <font-triplet name="FreeSans" style="normal" weight="normal"/>and uses the font FreeSansOblique.ttf for the normal text rendering.

Intelligent2013 commented 8 months ago

Fixed:

image

image

image

ronaldtse commented 8 months ago

Thank you @Intelligent2013 !