\XeTeXinterchartoks 应用于非 ASCII 字符时会失败

\XeTeXinterchartoks 应用于非 ASCII 字符时会失败

以下代码\XeTeXinterchartoks在应用于非 ASCII 字符时会失败。有什么帮助吗?

\documentclass{article}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{xcolor}
% \usepackage{bidi}
\setmainfont[Script=Arabic]{Amiri}

\chardef\stretchchar="0640

\newXeTeXintercharclass \charclassAen
\newXeTeXintercharclass \charclassBen

\XeTeXcharclass `\A \charclassAen
\XeTeXcharclass `\C \charclassAen

\XeTeXcharclass `\B \charclassBen
\XeTeXcharclass `\D \charclassBen

\newXeTeXintercharclass \charclassAar
\newXeTeXintercharclass \charclassBar

\chardef\Aar="062A % ت
\chardef\Bar="0641 % ف
\chardef\Car="0647 % ه
\chardef\Dar="0649 % ى
\chardef\Ear="064A % ي
\chardef\Far="06CC % ی
\chardef\Gar="FBFE % ﯾ
\chardef\Har="FBFD % ﯽ
\chardef\Iar="FEF0 % ﻰ
\chardef\Jar="FEF3 % ﻳ

\XeTeXcharclass \Aar \charclassAar
\XeTeXcharclass \Bar \charclassAar
\XeTeXcharclass \Car \charclassAar 
\XeTeXcharclass \Dar \charclassAar
\XeTeXcharclass \Ear \charclassAar
\XeTeXcharclass \Far \charclassAar
\XeTeXcharclass \Gar \charclassAar
\XeTeXcharclass \Har \charclassAar
\XeTeXcharclass \Iar \charclassAar
\XeTeXcharclass \Jar \charclassAar

\XeTeXcharclass \Aar \charclassBar
\XeTeXcharclass \Bar \charclassBar
\XeTeXcharclass \Car \charclassBar
\XeTeXcharclass \Dar \charclassBar
\XeTeXcharclass \Ear \charclassBar
\XeTeXcharclass \Far \charclassBar
\XeTeXcharclass \Gar \charclassBar
\XeTeXcharclass \Har \charclassBar
\XeTeXcharclass \Iar \charclassBar
\XeTeXcharclass \Jar \charclassBar

\newcommand \stretchitEN{
    \XeTeXinterchartokenstate 1 %
    \XeTeXinterchartoks \charclassAen \charclassBen = {{\color{red}\stretchchar\stretchchar\stretchchar}}
}

\newcommand \stretchitAR{
    \XeTeXinterchartokenstate 1 %
    \XeTeXinterchartoks \charclassAen \charclassBen = {{\color{red}\stretchchar\stretchchar\stretchchar}}
    \XeTeXinterchartoks \charclassAar \charclassBar = {{\color{red}\stretchchar\stretchchar\stretchchar}}
}

\pagestyle{empty}
\begin{document}
{
\stretchitEN{}
Test is a test. CDTest is a test. Test is a test. ABTest is a test.
Test is a test. CDTest is a test. Test is a test. ABTest is a test.
Test is a test. CDTest is a test. Test is a test. ABTest is a test. 
}

{
\stretchitAR{}
\Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar AB \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar CD \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar
\Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar CD \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar AB \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar
\Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar CD \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar CD \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar
\Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar CD \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar AB \Far\Dar\Far\Aar\Jar\Iar \Har\Ear\Dar\Ear\Aar
}

\end{document}

其输出为:

在此处输入图片描述

答案1

欢迎来到 TSE。:D

你的代码不正确。你不能在两个类中放置相同的字符。你必须针对每种可能的情况制定新规则。

为了向您表明这是您的代码的问题,而不是带有非 ASCII 字符的 \XeTeXinterchartoks 的问题,请将以下几行放入您的代码中,然后查看输出。

\XeTeXcharclass `\B \charclassAen
\XeTeXcharclass `\D \charclassAen
\XeTeXcharclass `\A \charclassBen
\XeTeXcharclass `\C \charclassBen

在此处输入图片描述

相关内容