asciidoctor生成包含中文的pdf

asciidoctor生成pdf时中文出现方框的原因是因为默认主题的字体不支持中文,所以需要自定义一套模板,在模板中选择使用支持中文的字体即可

  • basci-theme.yml
extends: base
page:
  layout: portrait
  margin: [0.75in, 1in, 0.75in, 1in]
  size: Letter
font:
  catalog:
    merge: false # set value to true to merge catalog with theme you're extending
    Chinese:
      normal: simsun.ttc
      italic: simsun.ttc
      bold: simsun.ttc
      bold_italic: simsun.ttc
base:
  font-color: #333333
  font-family: Chinese
  font-size: 12
  line-height-length: 17
  line-height: $base-line-height-length / $base-font-size
vertical-spacing: $base-line-height-length
heading:
  font-color: #262626
  font-size: 17
  font-style: bold
  line-height: 1.2
  margin-bottom: $vertical-spacing
link:
  font-color: #002FA7
outline-list:
  indent: $base-font-size * 1.5
footer:
  height: $base-line-height-length * 2.5
  line-height: 1
  recto:
    right:
      content: '{page-number}'
  verso:
    left:
      content: $footer-recto-right-content

  • 生成pdf文件

asciidoctor-pdf -a pdf-theme=basic-theme.yml -a pdf-fontsdir=path/to/fonts document.adoc