OpenType 字型中新增字距調整的自訂字體功能出現問題

OpenType 字型中新增字距調整的自訂字體功能出現問題

fontspec我嘗試在與under一起使用的 OpenType 字體添加一些自訂字距調整lualatex。實際範例使用了這些Brill字體,但由於它們不是 TeX Live 的一部分,所以我Libertinus在下面的範例中使用了這些字體。

我想在帶有變音符號和上標數字的特定字元之間添加一些字距調整。唯一有效的組合是直接使用 unicode 上標數字。一旦我使用\textsuperscript,它被重新定義以realscripts使用正確的數字,則不會應用額外的字距調整。

有什麼辦法可以在使用時達到我想要的效果嗎\textsuperscript

% !TeX TS-program = lualatex
\documentclass{article}

\usepackage{fontspec}
% Values below are for demonstration purposes only
\directlua {
   fonts.handlers.otf.addfeature {
      name = "supkern",
      type = "kern",
      data = {
         ["ī"] = {
            ["¹"] = 500,%
            ["two.sups"] = 500,%
         },
         ["š"] = {%
            ["one.sups"] = 500,%
            ["two.sups"] = 500,%
         },
      },
   }
}
\usepackage[defaultfeatures={RawFeature={+supkern}}]{libertinus} %Brill in real life
\usepackage{realscripts}

\begin{document}
   ī\textsuperscript{12}
   
   ī¹
   
   ī{\addfontfeatures{VerticalPosition=Superior}2}
   
   {\addfontfeatures{RawFeature={+supkern}}ī\addfontfeatures{VerticalPosition=Superior}12}
   
   š\textsuperscript{2}
   
\end{document}

答案1

realscripts 程式碼新增了一個 \addfontfeature 指令。這基本上意味著你有兩種不同的字體。像這樣的東西應該​​可以工作,但是應該添加一些測試,這樣如果字體沒有上標,就不會失敗。查看 realscript 程式碼。

\documentclass{article}

\usepackage{fontspec}
% Values below are for demonstration purposes only
\directlua {
   fonts.handlers.otf.addfeature {
      name = "supkern",
      type = "kern",
      data = {
         ["ī"] = {
            ["¹"] = 500,%
            ["two.sups"] = 500,%
         },
         ["š"] = {%
            ["one.sups"] = 500,%
            ["two.sups"] = 500,%
         },
      },
   }
}
\usepackage[defaultfeatures={RawFeature={+sups,+supkern}}]{libertinus} %Brill in real life
\RenewDocumentCommand\textsuperscript{m}{#1}
\begin{document}
   ī\textsuperscript{12}

ī¹ 
\end{document}

相關內容