서버로 사용하는 linux 에 폰트를 설치하는 이유는 gd library 로 image 를 생성하거나 tcpdf 로 pdf 생성, confluence 의 macro 나 chart 에 한글 표시 등에 필요하기 때문입니다.


font 설치

먼저 폰트를 관리하는 유틸리티인 fontconfig패키지를 설치합니다.


RHEL/CentOS

sudo yum install fontconfig
BASH

Ubuntu

sudo apt install fontconfig
BASH


설치할 폰트는 /usr/share/fonts/ 에 복사해 주면 되며 다음 예제는 네이버 나눔 폰트를 다운로드 받은 후에 /usr/share/fonts/nanum 에 압축을 풀어 줍니다.

나눔 폰트 설치

curl -o nanumfont.zip http://cdn.naver.com/naver/NanumFont/fontfiles/NanumFont_TTF_ALL.zip 
sudo unzip -d /usr/share/fonts/nanum nanumfont.zip
BASH


폰트 캐시(font cache) 갱신

fc-cache 명령어는 시스템에 있는 폰트를 읽어서 cache 정보를 만드는 유틸리티입니다. 강제로 재생성하는 옵션인 -f 와 상세 정보를 보는 -v 옵션을 사용해서 캐시 정보를 갱신합니다.


폰트 캐시

sudo fc-cache -f -v

/usr/share/fonts: caching, new cache contents: 0 fonts, 2 dirs
/usr/share/fonts/nanum: caching, new cache contents: 8 fonts, 0 dirs
/usr/share/fonts/truetype: caching, new cache contents: 0 fonts, 1 dirs
/usr/share/fonts/truetype/dejavu: caching, new cache contents: 6 fonts, 0 dirs
/usr/local/share/fonts: caching, new cache contents: 0 fonts, 0 dirs
/home/lesstif/.local/share/fonts: skipping, no such directory
/home/lesstif/.fonts: skipping, no such directory
/var/cache/fontconfig: cleaning cache directory
/home/lesstif/.cache/fontconfig: not cleaning non-existent cache directory
/home/lesstif/.fontconfig: not cleaning non-existent cache directory
fc-cache: succeeded
BASH


사용 가능한 폰트 목록 보기

fc-list 명령어로 시스템에서 사용 가능한 폰트 목록을 볼 수 있습니다.


fc-lsit

fc-list | grep -i nanum

/usr/share/fonts/nanum/NanumGothicExtraBold.ttf: NanumGothic,나눔고딕,NanumGothicExtraBold,나눔고딕 ExtraBold:style=ExtraBold,Regular,Bold
/usr/share/fonts/nanum/NanumMyeongjoExtraBold.ttf: NanumMyeongjo,나눔명조,NanumMyeongjoExtraBold,나눔명조 ExtraBold:style=ExtraBold,Regular
/usr/share/fonts/nanum/NanumGothicBold.ttf: NanumGothic,나눔고딕:style=Bold
/usr/share/fonts/nanum/NanumMyeongjo.ttf: NanumMyeongjo,나눔명조:style=Regular
/usr/share/fonts/nanum/NanumGothic.ttf: NanumGothic,나눔고딕:style=Regular
/usr/share/fonts/nanum/NanumMyeongjoBold.ttf: NanumMyeongjo,나눔명조:style=Bold
/usr/share/fonts/nanum/NanumBrush.ttf: Nanum Brush Script,나눔손글씨 붓:style=Regular
/usr/share/fonts/nanum/NanumPen.ttf: Nanum Pen Script,나눔손글씨 펜:style=Regular

BASH


같이 보기