Docker/Alpine Linux/LaTeX에서 Noto 글꼴의 극단적 인 글꼴 사용

Why


  • 조판 처리 시스템에는 $\LaTeX$를 사용하고 싶다.
  • 보기 쉽도록 일본어 극단 글꼴을 사용하고 싶습니다.
  • Docker 컨테이너를 사용하여 환경 구축의 번거 로움에서 열어야합니다.
  • 타케타 컨테이너의 이미지 크기를 줄이고 싶습니다.

  • How



  • Docker 컨테이너 위의 Alpine Linux:3.10Tex Live 2019Google Noto Font CJK

  • What



    Apline : 3.10에 Tex Live 2019 및 noto font jp를 설치하는 Dockerfile 만들기



    Dockerfile
    # Copyrighe (cnstall GNU libc ()) 2016 Kaito Udagawa
    # Copyright (c) 2015 Vlad
    # Copyright (c) 2016-2019 3846masa
    # Copyright (c) 2019 solareenlo
    # Released under the MIT license
    # https://opensource.org/licenses/MIT
    
    # FROM frolvlad/alpine-glibc
    FROM alpine:3.10
    
    ENV LANG=C.UTF-8
    ENV PATH /usr/local/texlive/2019/bin/x86_64-linux:$PATH
    
    # Reference: https://github.com/frol/docker-alpine-glibc
    # Here we install GNU libc (aka glibc) and set C.UTF-8 locale as default.
    RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && \
        ALPINE_GLIBC_PACKAGE_VERSION="2.29-r0" && \
        ALPINE_GLIBC_BASE_PACKAGE_FILENAME="glibc-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
        ALPINE_GLIBC_BIN_PACKAGE_FILENAME="glibc-bin-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
        ALPINE_GLIBC_I18N_PACKAGE_FILENAME="glibc-i18n-$ALPINE_GLIBC_PACKAGE_VERSION.apk" && \
        apk add --no-cache --virtual=.build-dependencies wget ca-certificates && \
        echo \
            "-----BEGIN PUBLIC KEY-----\
            MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEApZ2u1KJKUu/fW4A25y9m\
            y70AGEa/J3Wi5ibNVGNn1gT1r0VfgeWd0pUybS4UmcHdiNzxJPgoWQhV2SSW1JYu\
            tOqKZF5QSN6X937PTUpNBjUvLtTQ1ve1fp39uf/lEXPpFpOPL88LKnDBgbh7wkCp\
            m2KzLVGChf83MS0ShL6G9EQIAUxLm99VpgRjwqTQ/KfzGtpke1wqws4au0Ab4qPY\
            KXvMLSPLUp7cfulWvhmZSegr5AdhNw5KNizPqCJT8ZrGvgHypXyiFvvAH5YRtSsc\
            Zvo9GI2e2MaZyo9/lvb+LbLEJZKEQckqRj4P26gmASrZEPStwc+yqy1ShHLA0j6m\
            1QIDAQAB\
            -----END PUBLIC KEY-----" | sed 's/   */\n/g' > "/etc/apk/keys/sgerrand.rsa.pub" && \
        wget \
            "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_BASE_URL/$ALPINE_GLIBC_PACKAGE_VERSION/$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
        apk add --no-cache \
            "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME" && \
        \
        rm "/etc/apk/keys/sgerrand.rsa.pub" && \
        /usr/glibc-compat/bin/localedef --force --inputfile POSIX --charmap UTF-8 "$LANG" || true && \
        echo "export LANG=$LANG" > /etc/profile.d/locale.sh && \
        \
        apk del glibc-i18n && \
        \
        rm "/root/.wget-hsts" && \
        apk del .build-dependencies && \
        rm \
            "$ALPINE_GLIBC_BASE_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_BIN_PACKAGE_FILENAME" \
            "$ALPINE_GLIBC_I18N_PACKAGE_FILENAME"
    
    # Reference: https://github.com/Paperist/docker-alpine-texlive-ja
    # install texlive
    RUN apk add --no-cache perl fontconfig-dev freetype-dev && \
        apk add --no-cache --virtual .fetch-deps wget xz tar && \
        mkdir /tmp/install-tl-unx && \
        wget -qO - ftp://tug.org/historic/systems/texlive/2019/install-tl-unx.tar.gz | \
        tar -xz -C /tmp/install-tl-unx --strip-components=1 && \
        printf "%s\n" \
          "selected_scheme scheme-basic" \
          "option_doc 0" \
          "option_src 0" \
          > /tmp/install-tl-unx/texlive.profile && \
        /tmp/install-tl-unx/install-tl \
          --profile=/tmp/install-tl-unx/texlive.profile && \
        tlmgr install \
          collection-basic\
          collection-latex \
          collection-latexrecommended\
          collection-latexextra \
          collection-fontsrecommended\
          collection-langjapanese \
          latexmk \
          dvipdfmx && \
        (tlmgr install xetex || exit 0) && \
        rm -fr /tmp/install-tl-unx && \
        apk del .fetch-deps
    
    # References: https://gist.github.com/e10101/a4e833120f8a66a22cd581241cc79ed0
    #           : https://qiita.com/zr_tex8r/items/9dfeafecca2d091abd02
    #           : https://github.com/googlefonts/noto-cjk
    # install noto font jp
    # フォントをインストールする場所は以下で探し, /fonts/以下は自由なディレクトリが可能.
    # $ kpsewhich -var-value=TEXMFLOCAL
    RUN mkdir -p /usr/local/texlive/texmf-local/fonts/opentype/google && \
        cd /usr/local/texlive/texmf-local/fonts/opentype/google/ && \
        # 以下はgoogle noto font cjkのjpフォントだけをインストールしている.
        wget https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Black.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Bold.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-DemiLight.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Light.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Medium.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Regular.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSansJP-Thin.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-Black.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-Bold.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-ExtraLight.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-Light.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-Medium.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-Regular.otf \
             https://github.com/googlefonts/noto-cjk/raw/master/NotoSerifJP-SemiBold.otf && \
        mktexlsr
    # 明朝体・細字(\mcfamily\ltseries)
    # 明朝体・中字(\mcfamily\mdseries)
    # 明朝体・太字(\mcfamily\bfseries)
    # ゴシック体・中字(\gtfamily\mdseries)
    # ゴシック体・太字(\gtfamily\bfseries)
    # ゴシック体・極太(\gtfamily\ebseries)
    # 丸ゴシック体(\mgfamily)
    # 上記の7つのフォントを使うには, `.texファイル`のプリアンブルに以下の2行を追加する.
    # \usepackage[deluxe]{otf}% 多書体設定
    # \usepackage[noto-jp]{pxchfon}% 後に読み込む
    
    WORKDIR /workdir
    
    CMD ["sh"]
    

    Docker 컨테이너 이동


  • ↓의 요령으로 컨테이너에서 latexmk를 움직여 자동으로 tex 파일을 컴파일하여 pdf 파일을 생성한다.
  • Ubuntu18.04LTS/latexmk/docker-compose/zathura를 사용하여 얇은 책 작성

  • Result





    main.tex
    \documentclass[dvipdfmx, uplatex, a5paper, papersize, 9pt]{jsbook}
    \usepackage[deluxe]{otf} % 極太字を使う.
    \usepackage[noto-jp]{pxchfon} % noto font jpを使う.
    
    \begin{document}
    {\gtfamily\ebseries 極太} % ゴシックの極太
    {\gtfamily\bfseries 極太} % ゴシックの太字
    {\gtfamily 極太} % ゴシックの標準
    
    {\mcfamily\bfseries 極太} % 明朝の太字
    {\mcfamily 極太} % 明朝の標準
    {\mcfamily\ltseries 極太} % 明朝の細字
    
    {\mgfamily 極太} % まだ丸文字化は成功していない.
    \end{document}
    

    References


  • vvakame/docker-review
  • googlefonts/noto-cjk
  • e10101/Dockerfile
  • 사용 서체 변경(upLaTeX편)
  • upLaTeX 문서에서 소스 노 명조 / Noto Serif CJK를 쉽게 사용하는 방법 (최신 dvipdfmx 및 pxchfon 사용)
  • 좋은 웹페이지 즐겨찾기