
를 사용하여 새 계열을 정의할 수 있습니까 fontspec
? 다음을 시도했지만 ...
- 글꼴을 교체하는 대신 글꼴에 라이트 버전이 없으면 오류가 발생합니다
\bfseries
. 즉, 대체가 없습니다. - 내 은(
\ltseries
는) 에 의해 비활성화되지 않았습니다\mdseries
.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Source Sans Pro}
% http://www.google.com/fonts/specimen/Source+Sans+Pro
\newcommand{\ltseries}{%
\addfontfeatures{UprightFont={* Light},ItalicFont={* Light Italic}}%
}
\begin{document}
\ltseries
Light
\mdseries
Regular
\bfseries
Bold
\end{document}
발견된 경우\fontseries 및 \fontshape에 가능한 값하지만 새로운 계열을 정의하는 방법은 알려주지 않습니다. 게다가 이것은 LaTeX용이고 NFSS입니다. 저는 XeTeX를 fontspec
.
답변1
공식 인터페이스가 없습니다. 이 방법으로 수행할 수 있습니다(예: eu1lmr.fd와 같은 xelatex 구문 검사의 경우 lualatex-syntax입니다). 종종 새 패밀리가 생성되므로 로컬 글꼴 변경 \addfontfeatures
이나 로컬 과 함께 작동하지 않는다는 점에 유의해야 합니다 .\fontspec
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Source Sans Pro}
\normalfont
\makeatletter
\DeclareFontShape{\f@encoding}{\f@family}{l}{n}%
{<-> name:sourcesanspro-light:script=latn;+trep;+tlig;
}{}
\DeclareFontShape{\f@encoding}{\f@family}{l}{it}%
{<-> name:sourcesanspro-lightit:script=latn;+trep;+tlig;
}{}
\makeatother
\DeclareRobustCommand{\ltseries}{%
\fontseries{l}\selectfont}
\begin{document}
\ltseries
Light
\mdseries
Regular
\bfseries
Bold
\normalfont
{\addfontfeatures{Ligatures=NoCommon} abc \ltseries abc}
\end{document}
답변2
최신 버전 fontspec
(작성 당시 v2.5a)에는공식 인터페이스새 글꼴 모양을 선언하려면 다음 FontFace
옵션을 사용하여 새 NFSS 글꼴을 정의할 수 있습니다.
\documentclass{article}
\usepackage{fontspec}
\setsansfont[
FontFace = {lt}{n}{SourceSansPro-Light},
FontFace = {lt}{it}{SourceSansPro-LightIt},
]{Source Sans Pro}
\DeclareRobustCommand{\ltseries}{\fontseries{lt}\selectfont}
\DeclareTextFontCommand{\textsi}{\sishape}
\begin{document}
\ltseries
Light \textit{Italic} (not available)
\mdseries
Regular \textit{Italic}
\bfseries
Bold \textit{Italic}
\sffamily
\ltseries
Light \textit{Italic}
\mdseries
Regular \textit{Italic}
\bfseries
Bold \textit{Italic}
\end{document}
를 사용하는 것보다 훨씬 편합니다 \DeclareFontShape
. 이 예에서는 \textlt
다른 답변에 누락된 정의도 추가했습니다.
답변3
Ulrikes의 답변은 \DeclareFontShape
XeTeX 방식으로 변경한 후 잘 작동합니다. 다음과 같습니다.
\documentclass{article}
\usepackage{fontspec}
\setsansfont{Source Sans Pro}
% http://www.google.com/fonts/specimen/Source+Sans+Pro
\begingroup % \DeclareFontShape acts globally
\makeatletter
\sffamily
\DeclareFontShape{\f@encoding}{\f@family}{l}{n}%
{<-> "[SourceSansPro-Light]:mapping=tex-text"
}{}
\DeclareFontShape{\f@encoding}{\f@family}{l}{it}%
{<-> "[SourceSansPro-LightIt]:mapping=tex-text"
}{}
\endgroup % removes the effects of \sffamily and \makeatletter
\DeclareRobustCommand{\ltseries}{%
\fontseries{l}\selectfont}
\makeatother
\begin{document}
\ltseries
Light (not available)
\mdseries
Regular
\bfseries
Bold
\sffamily
\ltseries
Light
\mdseries
Regular
\bfseries
Bold
\end{document}
올바른 성을 갖도록 하기 위해서는 이전 \sffamily
이 \DeclareFontShape
필요합니다 . \f@family
문서 시작 부분에 이 있으므로 \normalfont
여기 \sffamily
에서는 문서의 글꼴이 변경되지 않습니다.