setmonofont에 사용자 정의 글꼴 모음 할당

setmonofont에 사용자 정의 글꼴 모음 할당

해당 명령을 두 번 작성하는 대신 더 쉬운 방법이 있습니까?

\newfontfamily\codefont[
  Scale=MatchLowercase,
  Path = fonts/]
  {Inconsolata-dz}

\setmonofont[
  Scale=MatchLowercase,
  Path = fonts/]
  {Inconsolata-dz}

같은 것을 염두에 두고 있지만 \setmonofont{\codefont}작동하지 않는 것 같습니다.

답변1

왜 그런 식으로 하고 싶은지 잘 모르겠습니다. 그러나 다음에 해당하는 NFSS 제품군 이름을 지정할 수 있습니다 \codefont.

\newfontfamily\codefont[
  NFSSFamily=Inconsolata,
  Scale=MatchLowercase,
  Path = fonts/
]{Inconsolata-dz}

\renewcommand{\ttdefault}{Inconsolata}

전체 테스트에서는 해당 줄을 사용 Inconsolatazi4하고 주석을 달았습니다 Path.

\documentclass{article}
\usepackage{fontspec}

\newfontfamily\codefont[
  NFSSFamily=Inconsolata,
  Scale=MatchLowercase,
%  Path = fonts/
]{Inconsolatazi4}

\renewcommand{\ttdefault}{Inconsolata}

\begin{document}

This should be Inconsolata: {\codefont Test of mono font}

This should be Inconsolata: \texttt{Test of mono font}

\end{document}

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

답변2

XeLaTeX에서 명령을 사용할 수 \newfontfamily{}[]{}있으며 구문은 다음과 유사합니다.\setmainfont

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Extension=.ttf]{f1}
\newfontfamily{\myone}[Extension=.ttf]{f2}
\newfontfamily{\mytwo}[
    BoldFont = f3_bold.ttf,
    ItalicFont = f3_italic.ttf,
    BoldItalicFont = f3_bold_italic.ttf
    ]{f3.ttf}

\begin{document}

fhsdfhhrth

{\myone gfhjjrjtyjsdjry}

{\mytwo dshthrsht\textbf{rjrtj} rtjjtrjjt \textit{dfhdhsrh} }

gthfrshtr

\end{document}

관련 정보