Unable to use a font - XSL-FO

Here should go questions about transforming XML with XSLT and FOP.
InspectorSpacetime
Posts: 38
Joined: Thu Jul 29, 2021 12:02 pm

Unable to use a font - XSL-FO

Post 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?
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unable to use a font - XSL-FO

Post 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
InspectorSpacetime
Posts: 38
Joined: Thu Jul 29, 2021 12:02 pm

Re: Unable to use a font - XSL-FO

Post 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.
InspectorSpacetime
Posts: 38
Joined: Thu Jul 29, 2021 12:02 pm

Re: Unable to use a font - XSL-FO

Post 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.
julien_lacour
Posts: 495
Joined: Wed Oct 16, 2019 3:47 pm

Re: Unable to use a font - XSL-FO

Post 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.
TMiles
Posts: 9
Joined: Fri Jan 20, 2023 1:05 am

Re: Unable to use a font - XSL-FO

Post 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.
Post Reply