Page 1 of 1

Unable to use a font - XSL-FO

Posted: Thu Aug 12, 2021 2:41 pm
by InspectorSpacetime
Hello,

I'm trying to use a custom TTF font in my PDF publication, but for some reason I just can't get it to work.

The font is installed in the Windows/Fonts folder as usual, and all other programs (Word, etc) are able to find and use it just fine, but when I'm trying to specify my XSL files to use it in my publication, it just doesn't work.

I have checked that the fop.xconf file has <auto-detect/> enabled, so I guess FOP should be able to find the font? I have tried it both with and without the font-mappings.xml file to no avail.

Any help here?

Re: Unable to use a font - XSL-FO

Posted: Fri Aug 13, 2021 9:22 am
by julien_lacour
Hello,

Is your custom style-sheet working with a Windows default font (like Calibri)?
How do you extend the DITA Map PDF - based on XSL-FO transformation? Are you using a custom plugin?
Are other modifications from the same style-sheet working fine?

Regards,
Julien

Re: Unable to use a font - XSL-FO

Posted: Fri Aug 13, 2021 9:58 am
by InspectorSpacetime
Hello!

Yes, I am able to use most (I'd say 95%) of the other fonts in the Windows/Fonts folder just fine. All other modifications in the custom stylesheet work as well.

I'm using a custom plugin with the XSL-FO transformation to PDF.

Re: Unable to use a font - XSL-FO

Posted: Fri Aug 13, 2021 4:46 pm
by InspectorSpacetime
Actually I solved this one!

I had to install the font by right-clicking and selecting "Install for all users".

Just dragging the font to the Fonts folder or using the "basic" install function was not enough in this case.

Re: Unable to use a font - XSL-FO

Posted: Fri Aug 13, 2021 5:30 pm
by julien_lacour
I'm glad you solved the problem, I've found that the font can also be declared in the xconf file together with the <auto-detect> option like this:

Code: Select all

<directory recursive="true">C:\path\to\custom\fonts</directory>
Usually with this option, you do not need to install custom fonts.

Re: Unable to use a font - XSL-FO

Posted: Wed May 24, 2023 4:48 pm
by TMiles
After many many attempts at adjusting the configuration file, this solution worked for me when converting using the Apache FO processor in a Windows 11 environment:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<fop version="1.0">
  <font-base>file:/Users/timmy/Appdata/Local/Microsoft/Windows/Fonts</font-base>
  <source-resolution>120</source-resolution>
  <target-resolution>120</target-resolution>
  <default-page-settings height="11in" width="8.26in"/>
  <renderers>
    <renderer mime="application/pdf">
      <filterList>
        <value>flate</value>
      </filterList>
      <fonts>
        <auto-detect/>
      </fonts>
    </renderer>
  </renderers>
</fop>
I hope this helps the community.