7
1

More than 5 years have passed since last update.

SATySFi 用のフォントライブラリを作ってみた

Posted at

新世紀に相応しい組版処理ソフトウェアであるところの SATySFi であるが、現在の所、フォントを追加するためには fonts.satysfi-hash を手動でいじらねばならず、少々手間なので簡易パッケージマネージャー Satyrographos とフォントライブラリ SATySFi-fonts-theano を作ってみた。

インストール方法

まず、SATySFi がビルドできるようになっていることを要求する。

SATySFi の依存ライブラリとOPAM

既に SATySFi をインストールをしている読者はこの節を飛ばしてほしい。

Ubuntu (含 WSL)の場合は以下のようになる。この節は zr-tex8r/make-satysfi.sh を参考にした。

$ sudo apt -y update
$ sudo apt -y install build-essential git m4 unzip curl ruby

$ yes '' | sh <(curl -sL https://raw.githubusercontent.com/ocaml/opam/master/shell/install.sh)

OPAM のインストール後には、OPAM を設定せねばならない。また、ここでは OCaml 4.06.0 をインストールすることにする。筆者の環境では OCaml 4.07.1 でも動くが、SATySFi の README.md には 4.06.0 が指定されているので、ここではそれに従う。

# 普通の Ubuntu はこちら
$ opam init --auto-setup --comp 4.06.0
# WSL はこちら
$ opam init --auto-setup --comp 4.06.0 --disable-sandboxing

OPAM のインストール後はシェルに環境変数を設定する。

$ eval $(opam env)

Satyrographos と SATySFi

以下の様に、SATySFi と Satyrographos をインストールする。

$ opam repository add satysfi-external https://github.com/gfngfn/satysfi-external-repo.git
$ opam repository add satyrographos https://github.com/na4zagin3/satyrographos-repo.git
$ opam update

$ opam install -y satysfi
$ opam install -y satyrographos

$ satyrographos install

この時、以下の様なエラーが出ることがある。Satyrographos は ~/.satysfi/dist に変更を加えるので、mv ~/.satysfi ~/.satysfi.old として、~/.satysfi を一旦消してほしい。

$ satyrographos install
opam dir: /home/<username>/.opam/4.06.0/share
Directory /home/<username>/.satysfi/dist is not managed by Satyrographos.
Please remove /home/<username>/.satysfi/dist first.
$ mv ~/.satysfi ~/.satysfi.old
$ satyrographos install

SATySFi-fonts-theano

以上で SATySFi-fonts-theano をインストールする準備が整った。以下の様にインストールできる。

$ opam install satysfi-fonts-theano
$ satyrographos install

これにより、フォントが ~/.satysfi/dist/fonts にコピーされ、適切なエントリが ~/.satysfi/dist/hash/fonts.satysfi-hash に書き込まれる。

利用法

SATySFi-fonts-theano は以下のフォントを含んでいる。

SATySFi フォント名 フォントファイル名
TheanoDidot TheanoDidot-Regular.otf
TheanoModern TheanoModern-Regular.otf
TheanoOldStyle TheanoOldStyle-Regular.otf

例えば、SATySFi 0.0.3 において TheanoOldStyle を利用したい場合は、以下の以下の様にフォントを指定すればよい。

let-inline ctx \greek it = 
  let ctx =
    ctx |> set-font Latin (`TheanoOldStyle`, 1., 0.)
      |> set-font OtherScript (`TheanoOldStyle`, 1., 0.)
  in
  read-inline ctx it

用例を以下に掲げる。

フォント用例

7
1
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
7
1