3

So I tried to adapt this answer: https://tex.stackexchange.com/a/370469/75284 to all problematic neighbors of the narrow 1 and added the second group of kerning pairs, the ones that specify the kerning of characters preceding the 1. The first group before that is to specify the kerning after a 1.

But, in my code:

– Having both command groups results in the pdf only having the second group kerning in effect (screenshot and MWE)

– removing group 2 results in group 1 having effect, which is only half the way there ...

How do I get both groups, so both sides of the 1, to take effect?

% -*- 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}

screenshot

lblb
  • 3,454

1 Answers1

5

You have the pair "1" + "1" twice, and the second setting overwrites your first group:

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

enter image description here

Ulrike Fischer
  • 327,261