lualatex에서 나만의 합자를 어떻게 정의할 수 있나요?

lualatex에서 나만의 합자를 어떻게 정의할 수 있나요?

합자가 작동하지 않는 이유는 무엇입니까?

\documentclass[12pt,a4page]{article}
\usepackage{fontspec}
\setmainfont[FeatureFile=pytanie.fea,
 Path = /usr/share/fonts/dejavu/,
 Extension=.ttf]{DejaVuSerif}
\begin{document}
ambona amarant żółw flaming i filharmonia.

młot
\end{document}

파일pytanie.fea

languagesystem DFLT dflt;
languagesystem latn dflt;
feature liga {
 sub \a \m by \fl;
 sub 0061 by uniF731;
 sub m ł by uni0062;
} liga;

am표준 합자 , f_l유니 a코드 문자 F731.b

답변1

기능 파일 기반 접근 방식이 작동하지 않는 이유를 설명할 수 없습니다. 다행히도 Lua 함수와 두 개의 TeX 측 "래퍼" 매크로( \myligsOn및 로 명명됨 \myligsOff)를 작성하여 글리프 대체를 직접 수행하는 것은 그리 어렵지 않습니다.

DejaVuSerif아래 코드에서는 글꼴을 에서 로 전환했습니다 Garamond Premier Pro. 전자의 위치에 문자 모양이 없는 것 같기 때문입니다 uniF731.

여기에 이미지 설명을 입력하세요

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

%% load fontspec package and specify main font
\usepackage{fontspec}
\setmainfont{Garamond Premier Pro}% -- DejaVuSerif has no glyph at pos. F731

%% Lua-side code 
\usepackage{luacode}
\begin{luacode*}
function myligs ( s )
   s = unicode.utf8.gsub ( s , '(\\?)([%a@]+)' , function( backslash, text )
   -- no substitutions inside (La)TeX macros
       if backslash=='' then 
           text = unicode.utf8.gsub (text, 'mł', 'b' )  
           text = unicode.utf8.gsub (text, 'am', 'fl' )  
           text = unicode.utf8.gsub (text, 'a', '\\char"F731' )  
       end
       return backslash .. text
   end)
   return s
end
\end{luacode*}

%% TeX-side code
\newcommand\myligsOn{\directlua{luatexbase.add_to_callback(
      "process_input_buffer", myligs, "myligs")}}
\newcommand\myligsOff{\directlua{luatexbase.remove_from_callback(
      "process_input_buffer", "myligs")}}

\begin{document}

\myligsOn
\small  % Note: The 'a' in '\small' is *not* being converted to '\char"F731'.
mł am a

\myligsOff
mł am a
\end{document}

관련 정보