is not a known font / in `initialize': is not a known font. (Prawn::Errors::UnknownFont)

2.4k Views Asked by At

I use the asciidoctor-pdf to convert adoc document to the pdf,but there is always error that "is not a known font",when adding --trace after the command line,the error is

`initialize':  is not a known font. (Prawn::Errors::UnknownFont)
/usr/local/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/font/afm.rb:53:in `initialize':  is not a known font. (Prawn::Errors::UnknownFont)
from /usr/local/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/font.rb:301:in `new'
from /usr/local/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/font.rb:301:in `load'
from /usr/local/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/font.rb:253:in `find_font'
from /usr/local/lib/ruby/gems/2.4.0/gems/prawn-2.2.2/lib/prawn/font.rb:57:in `font'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/prawn_ext/extensions.rb:196:in `font'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:2930:in `theme_font'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:544:in `convert_admonition'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:118:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:70:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `block in content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `map'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/block.rb:110:in `content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:134:in `convert_content_for_block'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:479:in `convert_preamble'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:118:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:70:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `block in content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `map'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/abstract_block.rb:79:in `content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/document.rb:1120:in `content'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:134:in `convert_content_for_block'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:207:in `convert_document'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/lib/asciidoctor-pdf/converter.rb:118:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/document.rb:1060:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1502:in `convert'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `block in convert_file'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `open'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor.rb:1575:in `convert_file'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:108:in `block in invoke!'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:102:in `each'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-1.5.6.1/lib/asciidoctor/cli/invoker.rb:102:in `invoke!'
from /usr/local/lib/ruby/gems/2.4.0/gems/asciidoctor-pdf-1.5.0.alpha.16/bin/asciidoctor-pdf:31:in `<top (required)>'
from /usr/local/bin/asciidoctor-pdf:23:in `load'
from /usr/local/bin/asciidoctor-pdf:23:in `<main>'

basic-theme.yml

enter image description here

Executed command is:

asciidoctor-pdf -a pdf-style=basic-theme.yml -a pdf-fontsdir=/Users/xqd/Desktop/my-awesome-presentation/fonts basic.adoc
1

There are 1 best solutions below

1
On

Had the same issue and I solved it by also adding bold to the font catalog. I assume that the failure is at the heading sections where usually a bold type is required. For good measures add italic and bold_italic as well.

Try out a basic-theme.yml looking like this:

base:
  font_family: KaiGenGothicCN
font:
  catalog:
    KaiGenGothicCN:
      normal: KaiGenGothicCN-Normal.ttf
      bold: KaiGenGothicCN-Bold.ttf
      italic: KaiGenGothicCN-Italic.ttf
      bold_italic: KaiGenGothicCN-Bold-Italic.ttf

Should you still need the fallback fonts due to some errors, add the below section:

    DroidSansFallback:
      normal: droid-sans-fallback.ttf
      italic: droid-sans-fallback.ttf
      bold: droid-sans-fallback.ttf
      bold_italic: droid-sans-fallback.ttf
 fallbacks:
   - DroidSansFallback

For more information consult: