상황

상황

XeLaTeX 질문입니다. 수년간 fontspecXeLaTeX를 사용해 본 후에 물어보는 것은 정말 어리석은 것 같습니다. 나는 항상 해결 방법을 찾았다고 생각합니다. 이번에는 확실한 답변을 원합니다.

상황

서버(컴파일러/빌드 시스템)가 백그라운드에서 실행되어 24시간 내내 버전 제어 저장소에서 문서(다른 작업 포함)를 생성합니다. 문서는 사람이 여러 클라이언트에서 편집합니다. 시스템 글꼴이 어떤 컴퓨터에서도 동일하다고 가정할 수는 없습니다.모든 컴퓨터에서 동일한 두 가지 사항이 있습니다(또는 최소한 그래야 합니다): 1. TeX Live 버전/MikTeX. 2. 저장소 파일.이는 내가 로드하는 모든 글꼴이 다음 중 하나에 있어야 함을 의미합니다.

  1. TeX Live 내장 글꼴(MikTeX와 동일하다고 가정)
  2. 저장소의 글꼴 파일

시스템 글꼴 아님fc-list -f "%{family}\n" | sort -u유닉스 기반 컴퓨터에 나열된대로 .

다음을 사용하여 글꼴 로드fontspec

~ 안에글꼴 사양, 글꼴은 여러 가지 방법으로 로드됩니다.

  1. 확장자를 포함한 파일 이름

예를 들어

\setmainfont{texgyrepagella-regular.otf}
\let\texgyrepagellaregular\normalfont % create semantically relevant macro (name+font) to be consistent with other \newfontfamily macros
  1. 확장자는 없지만 경로 구성 표현식이 매개변수로 제공되는 파일 이름:

예를 들어

\setmainfont{texgyrepagella}[
Path = /Users/will/Fonts/ ,
UprightFont = *-regular ,
BoldFont = *-bold ,]

[...] 를 입력하여 글꼴을 로드하는 것을 피하고 싶습니다. /usr/local/texlive/<YEAR>/글꼴이 같은 위치에 있지 않을 수 있기 때문입니다.

시도

\documentclass{article}
\usepackage{fontspec}
\setmonofont{Inconsolata}
\newcommand\escapedlog[1]{\par\ttfamily #1\par}
\begin{document}
Keep it simple.
\escapedlog{Hello}
\end{document}

로그 출력(오류)

나는 여기서 무슨 일이 일어나고 있는지 알고 있다고 생각합니다. fontspec시스템 글꼴 목록만 확인 중입니다 fc-list -f "%{family}\n" | sort -u.

kpathsea: Running mktextfm inconsolata
mktextfm: Running mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input inconsolata
This is METAFONT, Version 2.7182818 (TeX Live 2015) (preloaded base=mf)


kpathsea: Running mktexmf inconsolata
! I can't find file `inconsolata'.
<*> ...our; mag:=1; nonstopmode; input inconsolata

Please type another input file name
! Emergency stop.
<*> ...our; mag:=1; nonstopmode; input inconsolata

Transcript written on mfput.log.
grep: inconsolata.log: No such file or directory
mktextfm: `mf-nowin -progname=mf \mode:=ljfour; mag:=1; nonstopmode; input inconsolata' failed to make inconsolata.tfm.
kpathsea: Appending font creation commands to missfont.log.


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! fontspec error: "font-not-found"
!
! The font "inconsolata" cannot be found.
!
! See the fontspec documentation for further information.
!
! For immediate help type H <return>.
!...............................................

l.3 \setmonofont{inconsolata}

?

전통적인 패키지

이 목록에 따르면 해당 글꼴이 설치되어 있어야 합니다.

TeX live에는 어떤 글꼴 패키지가 설치되어 있습니까?

답변1

글꼴이 XeTeX에서 검색한 디렉터리에 있는 한 명시적인 경로를 제공할 필요가 없습니다. 관련 (의사) 환경 변수는 다음과 같습니다.

% TrueType outline fonts.
TTFONTS = .;$TEXMF/fonts/{truetype,opentype}//;$OSFONTDIR//

% OpenType outline fonts.
OPENTYPEFONTS = .;$TEXMF/fonts/{opentype,truetype}//;$OSFONTDIR//

사용자는 환경에서 변수를 설정할 수 있지만 OSFONTDIR설정은 OPENTYPEFONTS연결된 라이브러리에서 수행되는 작업이므로 사용자가 수행 합니다 TTFFONTS.kpsexetex~ 아니다설정해야 합니다. xetex시작하자마자 자동으로 설정됩니다.

운영 체제에 따라 시스템이 현재 TeX 배포판의 글꼴을 인식하도록 할 수 있습니다. TeX Live 설치 가이드에 설명된 대로 대부분의 GNU/Linux 시스템에서 실행할 수 있습니다.

cp $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
fc-cache -fsv

슈퍼유저 권한( sudo또는 이와 유사한 권한)이 있으면 TeX Live OpenType 및 TrueType 글꼴을 OS에서 사용할 수 있습니다.

첫 번째 명령은 연간 TeX Live 릴리스 후에 로드되어야 하며, 두 번째 명령은 tlmgr. 저는 GNU/Linux 박스에서 그 일을 합니다.

\testpath다음은 충분 하다는 것을 교차 확인하기 위해 패밀리가 정의된 예입니다 \testkpse.

\documentclass{article}
\usepackage{fontspec}

\newfontfamily{\testkpse}{Inconsolatazi4}[
  Extension=.otf,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
]

\newfontfamily{\testpath}{Inconsolatazi4}[
  Extension=.otf,
  Path=/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/,
  UprightFont=*-Regular,
  BoldFont=*-Bold,
]

\newfontfamily{\testfc}{Inconsolatazi4}

\begin{document}
\pagestyle{empty}

{\testkpse Inconsolata \bfseries Bold}

{\testpath Inconsolata \bfseries Bold}

{\testfc Inconsolata \bfseries Bold}

\end{document}

이 예제를 다음과 같이 실행해 보세요.

xelatex -output-driver="xdvipdfmx -vv" test

터미널에 다음 정보가 표시됩니다

<FONTMAP:/usr/local/texlive/2016/texmf-var/fonts/map/pdftex/updmap/pdftex.map><FONTMAP:/usr/local/texlive/2016/texmf-var/fonts/map/dvipdfmx/updmap/kanjix.map><FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/map/dvipdfmx/ckx.map>No dvi filename specified, reading standard input.
stdin -> incons.pdf
DVI Comment:  XeTeX output 2016.06.09:1437
<AGL:texglyphlist.txt><AGL:pdfglyphlist.txt><AGL:glyphlist.txt>[1</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]<NATIVE-FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf/0/H/65536/0/0>
pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf".
(CID:Inconsolatazi4-Regular)
pdf_font>> Type0 font "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf/0/H/65536/0/0,0>.
></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]<NATIVE-FONTMAP:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf/0/H/65536/0/0>
pdf_font>> Input encoding "Identity-H" requires at least 2 bytes.
pdf_font>> The -m <00> option will be assumed for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf".
(CID:Inconsolatazi4-Bold)
pdf_font>> Type0 font "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf" cmap_id=<Identity-H,0> opened at font_id=</usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf/0/H/65536/0/0,1>.
></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]></usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/[email protected]>]
otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf"...

otf_cmap>> Creating ToUnicode CMap for "/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf"...
(CID:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf[CIDFontType0])(CID:/usr/local/texlive/2016/texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf[CIDFontType0])

각 경우에 올바른 글꼴이 선택되었음을 보여줍니다.

여기에 이미지 설명을 입력하세요

답변2

사용

 \setmonofont{Inconsolatazi4}

또는

 \setmonofont[
   BoldFont=Inconsolatazi4-Bold.otf]{Inconsolatazi4-Regular.otf}

기본적으로 글꼴 파일 검색에 fontconfig사용되는 는 xetex/xelatexTeX 글꼴 디렉터리를 검색하지 않습니다. 그러나 전체 이름을 가진 글꼴을 찾는 이유인 을 xetex/xelatex사용하십시오 . kpsewhich이러한 파일을 시스템 글꼴 디렉토리에 넣거나 fontconfig. 그런 다음 상징적 이름을 사용할 수 있습니다.

관련 정보