LoginSignup
5
7

More than 3 years have passed since last update.

Asciidoctor-PDFをMacOS Mojaveにセットアップする

Posted at

rbenvでRubyをインストールする

MacOS標準のRuby (v2.3.0) を使いたくないのでrbenvをインストールする。

ここを参考に
【2018年版】macにrbenvを入れてrubyを管理できるようにしちゃう

とりあえずStableバージョンの最新を入れる。

$ ruby --version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]

asciidoctor-pdfをインストールする

こちらを参考にasciidoctor-pdfをインストールする
 asciidoctor-pdfでかっこいいPDFを作る(1)

上のドキュメント通りインストールしてもなぜか出力されたPDFに日本語が表示されない。
どうやら、asciidoctor-pdf-cjkでインストールされるNotoSansフォントのサブセットには日本語フォントが含まれないようだ。

そこで、CJKフォントが含まれるasciidoctor-pdf-cjk-kai_gen_gothicを追加でインストールする。

$ gem install asciidoctor-pdf-cjk-kai_gen_gothic

フォントをインストールする

$ asciidoctor-pdf-cjk-kai_gen_gothic-install

サンプルファイルでPDFを作成する

プロジェクトフォルダを作成し、こちらのサンプルファイルを拝借して保存する。ファイル名は、example01.adoc とする。

テーマファイルを同じフォルダにコピーする

$ cp ~/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/asciidoctor-pdf-cjk-kai_gen_gothic-0.1.1/data/themes/KaiGenGothicJP-theme.yml .

PDFをビルドする

$ asciidoctor-pdf -r asciidoctor-pdf-cjk-kai_gen_gothic example01.adoc -a pdf-style=KaiGenGothicJP-theme.yml -o output.pdf

output.pdfをプレビューする

$ open output.pdf

以下のようなPDFが生成される

AsciidocSample.png

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7