所以我尝试调整这个答案:https://tex.stackexchange.com/a/370469/75284到所有有问题的窄字距邻居1
,并添加了第二组字距调整对,这些对指定了 之前字符的字距调整1
。 之前的第一组用于指定 之后的字距调整1
。
但是,在我的代码中:
– 同时拥有两个命令组会导致 PDF 中只有第二组字距调整有效(屏幕截图和 MWE)
– 删除第 2 组会导致第 1 组仍然有效,但这只是完成了一半……
我怎样才能让这两个组(即双方)1
都生效?
% -*- program: lualatex -*-
\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\newcommand\defkern{-200}
\directlua{fonts.handlers.otf.addfeature{
name = "ktest",
type = "kern",
data = {
["1"] = {% group 1: after the "1"
["."] = \defkern,
["0"] = \defkern,
["1"] = \defkern,
["2"] = \defkern,
["3"] = \defkern,
["4"] = \defkern,
["5"] = \defkern,
["6"] = \defkern,
["7"] = \defkern,
["8"] = \defkern,
["9"] = \defkern,
},
% group 2: preceeding the "1"
["."] = {["1"] = \defkern},
["0"] = {["1"] = \defkern},
["1"] = {["1"] = \defkern},
["2"] = {["1"] = \defkern},
["3"] = {["1"] = \defkern},
["4"] = {["1"] = \defkern},
["5"] = {["1"] = \defkern},
["6"] = {["1"] = \defkern},
["7"] = {["1"] = \defkern},
["8"] = {["1"] = \defkern},
["9"] = {["1"] = \defkern},
}
}
}
\setmainfont[RawFeature=+ktest]{Arial}
\begin{document}
\obeylines
11111
88888
% testing group 1
10 11 12 13 14 15 16 17 18 19 1.
% testing group 2
01 11 21 31 41 51 61 71 81 91 .1
\end{document}
答案1
您有两次“1”+“1”对,第二次设置会覆盖您的第一组:
\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Ligatures=TeX}
\def\defkern{-300}
\directlua{fonts.handlers.otf.addfeature{
name = "ktest",
type = "kern",
data = {
["1"] = {% group 1: after the "1"
["."] = \defkern,
["0"] = \defkern,
["1"] = \defkern,
["2"] = \defkern,
["3"] = \defkern,
["4"] = \defkern,
["5"] = \defkern,
["6"] = \defkern,
["7"] = \defkern,
["8"] = \defkern,
["9"] = \defkern,
},
% group 2: preceeding the "1"
["."] = {["1"] = \defkern},
["0"] = {["1"] = \defkern},
% ["1"] = {["1"] = \defkern},
["2"] = {["1"] = \defkern},
["3"] = {["1"] = \defkern},
["4"] = {["1"] = \defkern},
["5"] = {["1"] = \defkern},
["6"] = {["1"] = \defkern},
["7"] = {["1"] = \defkern},
["8"] = {["1"] = \defkern},
["9"] = {["1"] = \defkern},
}
}
}
\setmainfont[RawFeature=+ktest]{Arial}
\begin{document}
\obeylines
11111
88888
10 11 12 13 14 15 16 17 18 19 1.
% testing group 2
01 11 21 31 41 51 61 71 81 91 .1
\end{document}