特定编码或语言的特定字体

特定编码或语言的特定字体

有没有办法为特定编码或语言指定特定字体?

使用默认字体时,所有内容都有正确的形状,但使用garamondx西里尔字母时,即使不使用我的 hack,也没有正确的形状。问题是garamondx缺少西里尔字母,还是其软件包没有妥善处理这种缺陷?

MWE PDF output

注意:MWEgaramondx需要literaturnayaTUG 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}

enter image description here

使用一些显示当前字体的黑魔法,只是为了完全确保我们得到了预期的字体。

\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}

enter image description here

注意:请参阅编辑历史以了解使用该包的先前解决方案substitutefont,现已宣布过时。

相关内容