问题这里,我设法使用 Luatex(plain/Optex)用阿拉伯语书写,但所有数字也都是从右向左书写的(而且是西方数字,而不是阿拉伯数字)。似乎Luabidi 套餐也有同样的问题。
在这种情况下,有没有办法有选择地激活从左到右 + 正确的数字“字体”选择?
\font\dubai={Dubai:script=arabic} at 12pt
\def\setArabic{\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT}
\def\setLatin {\pagedir TLT \bodydir TLT \pardir TLT \textdir TLT}
\def\arabe#1{
\bgroup
\setArabic\dubai #1
\egroup
}
\arabe{ دبي هي المدينة الأكثر اكتظاظاً بالسكان في الإمارات 0123456 ٢٥٦ العربية المتحدة.}
\bye
答案1
一个非常基本的 OpTeX 解决方案:
\ufont\plexarabic={file:ibmplexsansarabic-regular.otf:script=arabic} at 12pt
\def\arabe#1{{
\pagedir TRT \bodydir TRT \pardir TRT \textdir TRT
\plexarabic #1
}}
\directlua{
% Add any characters here that you want to always be LTR
local chars = {
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9",
"٠", "١", "٢", "٣", "٤", "٥", "٦", "٧", "٨", "٩"
}
local _chars = {}
for i, char in ipairs(chars) do
_chars[utf8.codepoint(char)] = true
end
local insert_before = node.insert_before
local copy = node.copy
local fonts = font.fonts
local push_dir = node.new("dir")
push_dir.dir = "+TLT"
local pop_dir = node.new("dir")
pop_dir.dir = "-TLT"
callback.add_to_callback("pre_linebreak_filter", function (head)
local found = false
for n, char, font in node.traverse_glyph(head) do
char = fonts[font].characters[char].unicode
if not found and _chars[char] then
found = true
head = insert_before(head, n, copy(push_dir))
elseif found then
if not _chars[char] then
found = false
head = insert_before(head, n, copy(pop_dir))
end
end
end
return head
end, "test")
}
\arabe{ دبي هي المدينة الأكثر اكتظاظاً بالسكان في الإمارات 0123456 ٢٥٦ العربية المتحدة.}
\bye
真正的比迪烟是一个非常困难的问题;如果您想要一个完整/强大的解决方案,您可能需要切换到 LaTeX 或 ConTeXt。