如何设置新的 RTL 语言以babel
使用新的区域设置ini
文件系统?
例如,考虑尝试建立对古典叙利亚语。我开始babel-ar.ini
将它修改为我认为应该出现的样子(尽管实际上我大多只是猜测)。
然而,存在两个问题:
- 段落方向仍为 LTR。我找不到任何地方可以设置它。
- 字体脚本和语言设置不正确。
下面的 MWE 给出了以下警告:
Package babel Warning: The current font is not a standard family:
(babel) NotoSansSyriac:mode=node;script=syrc;language=SYR;
(babel) Script and Language are not applied. Consider
(babel) defining a new family with \babelfont.
(babel) Reported on input line 3.
对于阿拉伯语,脚本和语言是根据 的内容设置的babel-ar.ini
。我假设这是来自tag.opentype
和script.tag.opentype
,但似乎不起作用。
字体本身报告:
$ otfinfo -s /usr/share/fonts/truetype/noto/NotoSansSyriac-Regular.ttf
DFLT Default
syrc Syriac
syrc.SYR Syriac/Syriac
syrc.SYRE Syriac/<unknown language>
syrc.SYRJ Syriac/<unknown language>
syrc.SYRN Syriac/<unknown language>
我究竟做错了什么?
平均能量损失
用 编译lualatex
。
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{babel-classicalsyriac.tex}
\ifx\BabelBeforeIni\undefined
\PackageError{babel}%
{This file is a component of babel and cannot\MessageBreak
be loaded directly. I'll stop immediately}%
{Just use babel as documented.}%
\stop
\fi
\BabelBeforeIni{syc}{%
}
\endinput
\end{filecontents}
\begin{filecontents}{babel-syc.ini}
[identification]
charset = utf8
version = 0.1
date = 2019-08-25
name.local = ܠܫܢܐ ܣܘܪܝܝܐ
name.english = Syriac
name.babel = classicalsyriac
tag.bcp47 = syc
tag.opentype = SYR
script.name = Syriac
script.tag.bcp47 = Syrc
script.tag.opentype = syrc
level = 1
encodings =
derivate = no
\end{filecontents}
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=syc,main]{classicalsyriac}
\babelprovide[import=en,language=Default]{english}
\babelfont[classicalsyriac]{rm}{Noto Sans Syriac}
\babelfont[classicalsyriac]{sf}{Noto Sans Syriac}
\babelfont[classicalsyriac]{tt}{Noto Sans Syriac}
\babelfont{rm}{Latin Modern Sans}
\babelfont{sf}{Latin Modern Sans}
\babelfont{tt}{Latin Modern Mono}
\newfontfamily\sycfont{Noto Sans Syriac}[Script=Syriac, Language=Syriac]
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
ܛܘܼܒܲܝܗܘܿܢ ܠܐܲܝܠܹܝܢ ܕܲܕ݂ܟܹܝܢ ܒܠܸܒ̇ܗܘܿܢ܄ ܕܗܸܢ݂ܘܿܢ ܢܸܚܙܘܿܢ ܠܐܲܠܵܗܵܐ܂
\selectlanguage{english}
Blessed are the pure in heart, for they shall see God.
\bigskip
Correct output:
\pardir TRT \textdir TRT \sycfont
ܛܘܼܒܲܝܗܘܿܢ ܠܐܲܝܠܹܝܢ ܕܲܕ݂ܟܹܝܢ ܒܠܸܒ̇ܗܘܿܢ܄ ܕܗܸܢ݂ܘܿܢ ܢܸܚܙܘܿܢ ܠܐܲܠܵܗܵܐ܂
\end{document}
答案1
感谢 Javier 的评论,事实证明babel
需要将所有部分添加到语言ini
文件中,即使它们是空的。
平均能量损失
\documentclass{article}
\usepackage{filecontents}
\begin{filecontents}{babel-syc.ini}
[identification]
charset = utf8
version = 0.1
date = 2019-08-25
name.local = ܠܫܢܐ ܣܘܪܝܝܐ
name.english = Classical Syriac
name.babel = classicalsyriac
tag.bcp47 = syc
tag.opentype = SYR
script.name = Syriac
script.tag.bcp47 = Syrc
script.tag.opentype = syrc
level = 1
encodings =
derivate = no
[captions]
[date.gregorian]
[date.islamic]
[time.gregorian]
[typography]
[characters]
[numbers]
[counters]
\end{filecontents}
\usepackage[nil,bidi=basic-r]{babel}
\babelprovide[import=syc,main]{classicalsyriac}
\babelprovide[import=en,language=Default]{english}
\babelfont[classicalsyriac]{rm}{Noto Sans Syriac}
\babelfont[classicalsyriac]{sf}{Noto Sans Syriac}
\babelfont[classicalsyriac]{tt}{Noto Sans Syriac}
\babelfont{rm}{Latin Modern Sans}
\babelfont{sf}{Latin Modern Sans}
\babelfont{tt}{Latin Modern Mono}
\renewcommand{\familydefault}{\sfdefault}
\begin{document}
ܛܘܼܒܲܝܗܘܿܢ ܠܐܲܝܠܹܝܢ ܕܲܕ݂ܟܹܝܢ ܒܠܸܒ̇ܗܘܿܢ܄ ܕܗܸܢ݂ܘܿܢ ܢܸܚܙܘܿܢ ܠܐܲܠܵܗܵܐ܂
\selectlanguage{english}
Blessed are the pure in heart, for they shall see God.
\end{document}