在`initialize'中不是已知的字体:不是已知的字体。 (虾::错误:: UnknownFont)

时间:2017-12-22 09:06:11

标签: ruby fonts asciidoctor asciidoctor-pdf

我使用asciidoctor-pdf将adoc文档转换为pdf,但在命令行后添加--trace时,总是会出现“不是已知字体”的错误,错误是

`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>'

基本-theme.yml

enter image description here

执行的命令是:

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

1 个答案:

答案 0 :(得分:2)

有同样的问题,我也通过将bold添加到字体目录中来解决它。我假设失败发生在标题部分,通常需要粗体。为了获得良好的衡量标准,还要添加italicbold_italic

尝试basic-theme.yml看起来像这样:

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

如果由于某些错误仍然需要后备字体,请添加以下部分:

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

有关详细信息,请参阅: