我catcode
在这答案是激活一些 Devanagari 脚本的字符。我想将 Devanagari 脚本的字符重新定义为活动字符,以产生不同的脚本,即 IPA(国际音标)。如果不解释 Devanagari 中的正字法惯例,这个问题就不完整。如果我说得太长,请原谅我。
天城文使用变音符号来表示跟在辅音后面的元音。例如,如果我们想写“pa”(比如在 '帕在天城文中,如果要用“rdon”来表示“p”,则用辅音符号表示“p”,用元音变音符号表示“a”。例如,प + ा = पा,如果前面没有辅音,则使用全元音符号。(例如A喜欢,我nto)。有趣的是,如果元音 'अ' 前面有一个与单词 r 中的元音发音相似的辅音,则没有单独的变音符号来表示元音你n, s你n. 根据规则,每个符号默认都有一个“अ”元音。如果我们想表示元音的缺失,则每个辅音都会附加一个不同的变音符号。它看起来像्例如,如果“p”音是不是后面跟着任意元音,写为प्。因此,为了同时保持正字法惯例和语音,我需要为一个天城文活动字符添加两个 IPA 字符。
我必须解释这一点,因为现在问题会更加清楚。我想将梵文音译成国际音标。在该文字中,元音 अ 表示为ə符号,catcode
如下图所示。在写辅音定义时,我默认添加了“ə”符号。我发现最难的部分是我能否做出्这个变音符号像其他的一样是‘active’,并以这样一种方式定义它,即消除前面辅音定义中的默认元音字符‘ə’?
\makeatletter
%CONSONANTS
\catcode`\क=\active
\protected\def क{\bgroup\doulo k\futurelet\tmp\viramacheck}
\catcode`\ख=\active
\protected\def ख{\bgroup\doulo kʰ\futurelet\tmp\viramacheck}
\catcode`\ग=\active
\protected\def ग{\bgroup\doulo g\futurelet\tmp\viramacheck}
\catcode`\घ=\active
\protected\def घ{\bgroup\doulo gʱ\futurelet\tmp\viramacheck}
\catcode`\ङ=\active
\protected\def ङ{\bgroup\doulo ŋ\futurelet\tmp\viramacheck}
\catcode`\च=\active
\protected\def च{\bgroup\doulo t͡ʃ\futurelet\tmp\viramacheck}
\catcode`\छ=\active
\protected\def छ{\bgroup\doulo t͡ʃʰ\futurelet\tmp\viramacheck}
\catcode`\ज=\active
\protected\def ज{\bgroup\doulo d͡ʒ\futurelet\tmp\viramacheck}
\catcode`\झ=\active
\protected\def झ{\bgroup\doulo d͡ʒʱ\futurelet\tmp\viramacheck}
\catcode`\ञ=\active
\protected\def ञ{\bgroup\doulo ɲ\futurelet\tmp\viramacheck}
\catcode`\ट=\active
\protected\def ट{\bgroup\doulo ʈ\futurelet\tmp\viramacheck}
\catcode`\ठ=\active
\protected\def ठ{\bgroup\doulo ʈʰ\futurelet\tmp\viramacheck}
\catcode`\ड=\active
\protected\def ड{\bgroup\doulo ɖ\futurelet\tmp\viramacheck}
\catcode`\ढ=\active
\protected\def ढ{\bgroup\doulo ɖʱ\futurelet\tmp\viramacheck}
\catcode`\ण=\active
\protected\def ण{\bgroup\doulo ɳ\futurelet\tmp\viramacheck}
\catcode`\त=\active
\protected\def त{\bgroup\doulo t̪\futurelet\tmp\viramacheck}
\catcode`\थ=\active
\protected\def थ{\bgroup\doulo t̪ʰ\futurelet\tmp\viramacheck}
\catcode`\द=\active
\protected\def द{\bgroup\doulo d̪\futurelet\tmp\viramacheck}
\catcode`\ध=\active
\protected\def ध{\bgroup\doulo d̪ʱ\futurelet\tmp\viramacheck}
\catcode`\न=\active
\protected\def न{\bgroup\doulo n̪\futurelet\tmp\viramacheck}
\catcode`\प=\active
\protected\def प{\bgroup\doulo p\futurelet\tmp\viramacheck}
\catcode`\फ=\active
\protected\def फ{\bgroup\doulo pʰ\futurelet\tmp\viramacheck}
\catcode`\ब=\active
\protected\def ब{\bgroup\doulo b\futurelet\tmp\viramacheck}
\catcode`\भ=\active
\protected\def भ{\bgroup\doulo bʱ\futurelet\tmp\viramacheck}
\catcode`\म=\active
\protected\def म{\bgroup\doulo m\futurelet\tmp\viramacheck}
\catcode`\य=\active
\protected\def य{\bgroup\doulo j\futurelet\tmp\viramacheck}
\catcode`\र=\active
\protected\def र{\bgroup\doulo ɾ\futurelet\tmp\viramacheck}
\catcode`\ल=\active
\protected\def ल{\bgroup\doulo l\futurelet\tmp\viramacheck}
\catcode`\व=\active
\protected\def व{\bgroup\doulo w\futurelet\tmp\viramacheck}
\catcode`\श=\active
\protected\def श{\bgroup\doulo ʃ\futurelet\tmp\viramacheck}
\catcode`\ष=\active
\protected\def ष{\bgroup\doulo ʂ\futurelet\tmp\viramacheck}
\catcode`\स=\active
\protected\def स{\bgroup\doulo s\futurelet\tmp\viramacheck}
\catcode`\ह=\active
\protected\def ह{\bgroup\doulo h\futurelet\tmp\viramacheck}
\catcode`\ळ=\active
\protected\def ळ{\bgroup\doulo ɭ\futurelet\tmp\viramacheck}
%VOWELS
\catcode`\अ=\active
\protected\def अ{\bgroup\doulo ə}
\catcode`\ा=\active
\protected\def ा{\bgroup\doulo a}
\catcode`\आ=\active
\protected\def आ{\bgroup\doulo a}
\catcode`\ि=\active
\protected\def ि{\bgroup\doulo i}
\catcode`\इ=\active
\protected\def इ{\bgroup\doulo i}
\catcode`\ी=\active
\protected\def ी{\bgroup\doulo iː}
\catcode`\ई=\active
\protected\def ई{\bgroup\doulo iː}
\catcode`\ु=\active
\protected\def ु{\bgroup\doulo u}
\catcode`\उ=\active
\protected\def उ{\bgroup\doulo u}
\catcode`\ू=\active
\protected\def ू{\bgroup\doulo uː}
\catcode`\ऊ=\active
\protected\def ऊ{\bgroup\doulo uː}
\catcode`\े=\active
\protected\def े{\bgroup\doulo e}
\catcode`\ए=\active
\protected\def ए{\bgroup\doulo e}
\catcode`\ै=\active
\protected\def ै{\bgroup\doulo ə͡i}
\catcode`\ऐ=\active
\protected\def ऐ{\bgroup\doulo ə͡i}
\catcode`\ो=\active
\protected\def ो{\bgroup\doulo o}
\catcode`\ओ=\active
\protected\def ओ{\bgroup\doulo o}
\catcode`\ौ=\active
\protected\def ौ{\bgroup\doulo ə͡u}
\catcode`\औ=\active
\protected\def औ{\bgroup\doulo ə͡u}
\catcode`\ं=\active
\protected\def ं{\bgroup\doulo ũ}
\protected\def\viramacheck{\ifx\tmp ् \egroup\expandafter\@gobble\else ə\egroup\fi}
\makeatother
这里我使用了 David Carlisle 给出的定义。现在如果我输入 -
\begin{document}
शरद् कमळ् बघ्\\
अभय् नमन् कर्\\
मगन् लव्कर् पळ्\\
\end{document}
输出是
这正是我所期望的。干得好!但现在梵文脚本中也有很多其他元音。在提供的代码中,您可以检查元音(注释后%VOWELS
)。当出现带有其他元音的单词时,就会出现问题。让我们看一个例子 -
\begin{document}
सूर्यनमस्कार\\
मी सकाळी उठून् एक् तास् धाव्तो\\
रात्री पेलाभर् दूध् प्यावे\\
\end{document}
具体表现为 -
这不是正确的方法。当出现元音时,默认的“ə”应该消失。在元音的定义中应该有一个额外的规则,可以删除viramacheck
我们定义的“ə”。它应该是这样的。(我用不同的键盘手动输入了它。)-
答案1
如果我理解正确的话你想要类似的东西
其中 क 会提前考虑是否添加 ə,具体取决于后面是否跟着 virama 组合字符。
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Nirmala UI}
\newfontfamily\ipafont{Arial}
\makeatletter
\catcode`\क=\active
\protected\defक{\bgroup\ipafont k\futurelet\tmp\viramacheck}
\protected\def\viramacheck{\ifx\tmp ् \egroup\expandafter\@gobble\else ə\egroup\fi}
\makeatother
\begin{document}
क
क्
\end{document}