有没有办法为特定编码或语言指定特定字体?
使用默认字体时,所有内容都有正确的形状,但使用garamondx
西里尔字母时,即使不使用我的 hack,也没有正确的形状。问题是garamondx
缺少西里尔字母,还是其软件包没有妥善处理这种缺陷?
注意:MWEgaramondx
需要literaturnaya
TUG getnonfreefonts 脚本。(其他字体可能也一样。)
\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[russian,american]{babel}
\usepackage{garamondx}
%%% The hack
\DeclareFontSubstitution{T2A}{tli}{m}{n}
\begin{document}
This should be Garamond.
The following should be Literaturnaya:
\begin{otherlanguage}{russian}
\textbf{Русский язык} \ensuremath{\leftarrow} (should be bold)
\emph{восточнославянских} \ensuremath{\leftarrow} (should be italic)
\emph{\textbf{русского народа}} \ensuremath{\leftarrow} (should be bold italic).
\end{otherlanguage}
\end{document}
答案1
这是一份工作\DeclareFontFamilySubstitution
:
\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,american]{babel}
\usepackage{garamondx}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\rmdefault}{tli}%
} % some packages could set \rmdefault at begin document
\begin{document}
This should be Garamond.
The following should be Literaturnaya:
\begin{otherlanguage}{russian}
\textbf{Русский язык} \ensuremath{\leftarrow} (should be bold)
\emph{восточнославянских} \ensuremath{\leftarrow} (should be italic)
\emph{\textbf{русского народа}} \ensuremath{\leftarrow} (should be bold italic).
\end{otherlanguage}
\end{document}
使用一些显示当前字体的黑魔法,只是为了完全确保我们得到了预期的字体。
\documentclass{article}
\usepackage[T2A,T1]{fontenc}
\usepackage[russian,american]{babel}
\usepackage{garamondx}
\AtBeginDocument{%
\DeclareFontFamilySubstitution{T2A}{\rmdefault}{tli}%
} % some packages could set \rmdefault at begin document
\newcommand{\?}{%
\space
\begingroup\edef\x{\endgroup
{%
\noexpand\ttfamily\noexpand\upshape
\noexpand\string\the\font=\fontname\font
}%
}\x
}
\begin{document}
This should be Garamond.
The following should be Literaturnaya:
\begin{otherlanguage}{russian}
\textbf{Русский язык\?}
\emph{восточнославянских\?}
\emph{\textbf{русского народа}\?}
\end{otherlanguage}
\end{document}
注意:请参阅编辑历史以了解使用该包的先前解决方案substitutefont
,现已宣布过时。