CID 键控字体的自定义 Lua 功能

CID 键控字体的自定义 Lua 功能

fonts.handlers.otf.addfeatureluaotfload用于创建字体的自定义功能。

字形的 unicode 值可以像 GID 字体一样用于 CID 字体,但有些字体具有可通过内部功能访问的变体字符。CID 可以在自定义功能中单独访问这些字符吗?

(例如天民朝有拉丁语和 CJK 的连字和替代字。在示例中,我将使用更易于获取的来源韩

梅威瑟:

目标是用任何显式 CID 替换任何其他 CID,在本例中为40355 。(这可以通过语言功能轻松解决,但如果字体有替代字形,而这些字形无法单独访问,则这说明了主要问题。)

\documentclass{article}
\pdfvariable compresslevel 0
\pdfvariable objcompresslevel 0
\pagestyle{empty}

\usepackage{luacode}
\begin{luacode}
fonts.handlers.otf.addfeature {
  name = "noff",
  type = "multiple",
  data = {
    ["f_f"] = { "f", "f" },
  }
}
fonts.handlers.otf.addfeature {
  name = "test",
  type = "substitution",
  data = {
    ["A"] = 0x8FF0, -- Unicode code point does not use the alternate.
    ["B"] = "Z", -- GID works for the CID font. Does the alternate have a GID?
    ["C"] = 40355, -- Decimal CID value is treated as decimal Unicode, 鶣.
    [37] = "Y", -- Attempt to turn CID 37 "D" into "Y"
    [38] = 40355, -- Attempt to turn CID 38 "E" into CID of alternate 述
  }
}
\end{luacode}

\usepackage{fontspec}
\setmainfont{SourceHanSansTC-Normal.otf}

\begin{document}

f\hspace{0pt}f

{\addfontfeature{RawFeature=+noff}ff} %% has no expected effect as it uses CID

{\addfontfeature{Language=Chinese Simplified}述} %% glyph to be substituted

{\addfontfeature{RawFeature=+test}A B C D E} %% test the feature

\end{document}

相关内容