减少 Asana-Math (unicode-math) 中字母“f”与其后跟下标之间的间距

减少 Asana-Math (unicode-math) 中字母“f”与其后跟下标之间的间距

继第二部分之后这个答案,我正在尝试对 Asana-Math 做类似的事情:减少字母“f”与其后的下标之间的间距。但是,我的修改版本似乎不起作用:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{luacode}
\begin{luacode*}
  -- First create a table specifying the mathkerns we want to set:
  local mathkerns = {
    ["Asana-Math"] = { -- This should be the PostScript name of the font
      ["f"] = { -- If the character would have a regular name, you could also use the glyphname here
        bottomright = {
          {height=0,kern=-175},
          {height=216,kern=-76},
          {kern=0},
        },
      },
    },
  }
  local function initmathkern(tfmdata)
    local values = mathkerns[tfmdata.properties.psname]
    if not values then return end
    for cp, value in next, values do
      local tcp = type(cp)
      if tcp == 'string' then
        cp = tfmdata.resources.unicodes[cp]
      end
      local char = tfmdata.characters[cp]
      if char then
        local mathkern = char.mathkerns
        if not mathkern then
          mathkern = {}
          char.mathkerns = mathkern
        end
        for corner, v in next, value do
          mathkern[corner] = v
        end
      end
    end
  end
  fonts.constructors.newfeatures'otf'.register{
    name = 'mathkern',
    description = 'Overwrite mathkern values',
    initializers = {
      base = initmathkern,
    },
  }
\end{luacode*}
\setmathfont{Asana-Math.otf}[RawFeature=mathkern]

\begin{document}

\( f_a f_i f_j \)

\( f^a f^i f^j \)

\end{document}

在此处输入图片描述

我是否做错了什么?

答案1

问题在于,在数学模式下,字母“f”不是通常的“f”,而是“MATHEMATICAL ITALIC SMALL F”(U+1D453)。因此,正确的代码应该是:

\documentclass{article}
\usepackage{unicode-math}
\usepackage{luacode}
\begin{luacode}
  -- First create a table specifying the mathkerns we want to set:
  local mathkerns = {
    ["Asana-Math"] = { -- This should be the PostScript name of the font
      [0x1D453] = { -- If the character would have a regular name, you could also use the glyphname here
        bottomright = {
          {height=0,kern=-135},
          -- {height=216,kern=-76},
          -- {kern=0},
        },
      },
    },
  }
  local function initmathkern(tfmdata)
    local values = mathkerns[tfmdata.properties.psname]
    if not values then return end
    for cp, value in next, values do
      local tcp = type(cp)
      if tcp == 'string' then
        cp = tfmdata.resources.unicodes[cp]
      end
      local char = tfmdata.characters[cp]
      if char then
        local mathkern = char.mathkerns
        if not mathkern then
          mathkern = {}
          char.mathkerns = mathkern
        end
        for corner, v in next, value do
          mathkern[corner] = v
        end
      end
    end
  end
  fonts.constructors.newfeatures'otf'.register{
    name = 'mathkern',
    description = 'Overwrite mathkern values',
    initializers = {
      base = initmathkern,
    },
  }
\end{luacode}
\setmathfont{Asana-Math.otf}[RawFeature=mathkern]

\begin{document}

\( f_a f_i f_j \)

\( f^a f^i f^j \)

\end{document}

在此处输入图片描述

相关内容