본문 바로가기
개발환경

[Env] Install a NerdFont on Ubuntu

by ds31x 2023. 7. 14.

순서

  1. 원하는 Nerd Font 를 다운로드.
  2. 압축을 풀고, 설치할 directory ~/.fonts 로 copy.
    • ~/.local/share/fonts 에 설치해도 된다.
  3. 명령어 fc-cache -fv 를 수행하여 font cache를 rebuild (아래 설명 참조).

관련 Shell Script.

#!/bin/bash

if which fc-cache &> /dev/null ; then
        echo "fc-cache exists"
else
        echo "fc-cache not found"
        sudo apt install fontconfig
fi
echo "Download CaskaydiaCove Nerd Font"

if which wget &> /dev/null ; then
        echo "wget exists"
else
        echo "wget not found"
        sudo apt install wget
fi
wget https://github.com/ryanoasis/nerd-fonts/releases/download/v3.0.2/CascadiaCode.zip

if which unzip &> /dev/null ; then
        echo "unzip exists"
else
        echo "unzip not found"
        sudo apt install unzip
fi

echo "install fonts into ~/.fonts"
unzip CascadiaCode.zip -d ~/.fonts
fc-cache -fv

echo "done!"

fc-cache 명령어는 font 설정 명령어 중 하나로, 새 font를 추가한 이후 캐시(cache)에서 해당 font를 반영하도록 재생성함.

  • fc-cache 가 없는 경우 sudo apt install fontconfig를 실행하면 설치된다.

fa-cache 명령어를 수행한 이후 추가된 새 font 사용이 가능.

위에서 사용된 옵션의 의미는 다음과 같음.

  • -f : force로 강제 실행.
  • -v : 표준 출력 stdout에서 실행정보 출력 (verbose로 기억하면 쉬움)

fcfc-cacheaptapt-cache 의 관계를 생각하면 된다.

fc (font config)의 다른 명령어는 다음과 같음.

  • fc-list : font config에 의해 설정된 모든 font의 list를 출력.
  • fc-match : font 이름 일부등을 인자로 받고 매칭이 되는 font 정보를 출력.
  • fc-cache : font 캐시 관련 명령어. 위에서 설명한 options 외에도 다음과 같은 options를 지원
    • -r : 기존의 캐시를 지우고 새로 갱신한다.
    • -s : font가 설치된 시스템 디렉토리를 scan
    • -V : version출력
  • fc-cat : font config의 캐시로부터 font 정보를 출력함.
  • fc-query : font file의 path를 인자로 넘겨서 해당 font file 정보를 본다.

참고

https://gist.github.com/matthewjberger/7dd7e079f282f8138a9dc3b045ebefa0?permalink_comment_id=3307825#gistcomment-3307825

 

Install a nerd font on ubuntu

Install a nerd font on ubuntu. GitHub Gist: instantly share code, notes, and snippets.

gist.github.com

 

728x90