Genus
Genus

Reputation: 33

Using a custom icon font with asciidoctor-pdf

I have managed to use a custom icon font replacing FontAwesome in AsciiDoc by doing the following.

I have placed my font files in my AsciiDoc root directory:

I have set the following properties in the AsciiDoc document:

:icons: font
:iconfont-remote!:
:iconfont-name: icons

The icon is rendered correctly in the HTML output and in the VS code plugin preview. When creating a pdf from the asciidoc, though, the icon doesn't appear. I use this command to generate the pdf:

bundle exec asciidoctor-pdf book.adoc -o out/book.pdf

And I receive this error (the icon is not renderered):

asciidoctor: WARNING: my-icon is not a valid icon name in the fa icon set

Does asciidoctor-pdf need to be pointed to the custom icon font in some way? I have tried looking for answers in the docs but couldn't find any (as a matter of fact, also making this work with HTML took some experimentation).

Upvotes: 0

Views: 1318

Answers (1)

Kiroul
Kiroul

Reputation: 535

asciidoctor-pdf does not have the same flexibility as asciidoctor for icon fonts, see https://docs.asciidoctor.org/pdf-converter/latest/icons/#font

Icon-based fonts are handled by the prawn-icon gem.

If you want to use one of the available set you will need to set the :icons: and :icon-set: document attributes, at best from the command line so you do not have a conflict with HTML conversion.

asciidoctor-pdf -a icons=font -a icon-set=fas sample.adoc

The fonts available are:

  • fa - Font Awesome 4 (default, deprecated)
  • fas - Font Awesome - Solid
  • fab - Font Awesome - Brands
  • far - Font Awesome - Regular
  • fi - Foundation Icons
  • pf - Payment font (deprecated)

Upvotes: 0

Related Questions