summaryrefslogtreecommitdiff
path: root/Master/texmf-dist
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2017-11-03 21:38:44 +0000
committerKarl Berry <karl@freefriends.org>2017-11-03 21:38:44 +0000
commit753ccf29ee3c32686dbe1cb4ada792d0f26ec429 (patch)
tree9a9c511a29d95c90ead813a096e17b7249a002a9 /Master/texmf-dist
parente4d8f7684792e7652b447e6ad94b82ca72886fe3 (diff)
babel (3nov17)
git-svn-id: svn://tug.org/texlive/trunk@45683 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r--Master/texmf-dist/doc/latex/babel/README13
-rw-r--r--Master/texmf-dist/doc/latex/babel/babel.pdfbin573431 -> 620805 bytes
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.dtx1681
-rw-r--r--Master/texmf-dist/source/latex/babel/babel.ins4
-rw-r--r--Master/texmf-dist/source/latex/babel/bbcompat.dtx2
-rw-r--r--Master/texmf-dist/source/latex/babel/locale.zipbin682708 -> 682708 bytes
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua29
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel.def79
-rw-r--r--Master/texmf-dist/tex/generic/babel/babel.sty27
-rw-r--r--Master/texmf-dist/tex/generic/babel/hyphen.cfg4
-rw-r--r--Master/texmf-dist/tex/generic/babel/luababel.def128
-rw-r--r--Master/texmf-dist/tex/generic/babel/nil.ldf2
-rw-r--r--Master/texmf-dist/tex/generic/babel/switch.def41
-rw-r--r--Master/texmf-dist/tex/generic/babel/xebabel.def126
14 files changed, 1688 insertions, 448 deletions
diff --git a/Master/texmf-dist/doc/latex/babel/README b/Master/texmf-dist/doc/latex/babel/README
index 356a89f61e7..2c969bdea70 100644
--- a/Master/texmf-dist/doc/latex/babel/README
+++ b/Master/texmf-dist/doc/latex/babel/README
@@ -1,4 +1,4 @@
-Babel 3.14
+Babel 3.15
----------
This package manages culturally-determined typographical (and other)
@@ -49,6 +49,15 @@ respective authors.
Recent changes
--------------
+3.15 - New command \babelfont (in Unicode engines) to define
+ language/script dependent fonts. Related to it, new
+ keys (script, language) in \babelprovide.
+ - A common mistake is to leave some space(s) in \captions<lang>,
+ which go to the document. Now babel removes them.
+ - Fix - Error with hyphenrules in \babelprovide in some cases.
+ - Fix - \hyphenrules doesn't set \languagename any more (which
+ was against the documented behavior),
+
3.14 - R text (Hebrew-like) and AL text (Arabic-like) in luatex, with
"European" and "Arabic" numbers, mirroring and unmarked L text.
- Fix - `import' ignored `hyphenrules' in ini files.
@@ -90,5 +99,5 @@ Recent changes
------------
Javier Bezos
-2017/10/04
+2017/11/03
diff --git a/Master/texmf-dist/doc/latex/babel/babel.pdf b/Master/texmf-dist/doc/latex/babel/babel.pdf
index 65a1c252fb9..cb0b483c3f6 100644
--- a/Master/texmf-dist/doc/latex/babel/babel.pdf
+++ b/Master/texmf-dist/doc/latex/babel/babel.pdf
Binary files differ
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx
index 0f97e75f477..5f068ccd945 100644
--- a/Master/texmf-dist/source/latex/babel/babel.dtx
+++ b/Master/texmf-dist/source/latex/babel/babel.dtx
@@ -1,4 +1,5 @@
% \iffalse
+% This document requires lualatex
%%
%% Copyright (C) 2012-2017 Javier Bezos and Johannes L. Braams.
%% Copyright (C) 1989-2012 Johannes L. Braams and
@@ -30,7 +31,7 @@
%
% \iffalse
%<*filedriver>
-\ProvidesFile{babel.dtx}[2017/10/04 v3.14 The Babel package]
+\ProvidesFile{babel.dtx}[2017/11/03 v3.15 The Babel package]
\documentclass{ltxdoc}
\GetFileInfo{babel.dtx}
\usepackage{fontspec}
@@ -64,6 +65,7 @@
\addtolength{\oddsidemargin}{1em}
\setlength{\leftmargini}{1.5em}
\usepackage{framed}
+\usepackage{multicol}
\usepackage{color,colortbl}
\usepackage[linkbordercolor={.9 .7 .5}]{hyperref}
\newcommand\New[1]{%
@@ -201,13 +203,14 @@ Javier Bezos
script.
Current development is focused on Unicode engines (Xe\TeX{} and
- Lua\TeX). New features related to font selection, bidi writing and
- the like will be added incrementally, but you may use \babel{} for
- many languages.
+ Lua\TeX) and the so-called \textit{complex scripts}. New features
+ related to font selection, bidi writing and the like will be added
+ incrementally.
- Currently \babel{} provides support (total or partial) for about 200
- languages, either as a package option or as an |ini|
- file. Furthermore, new languages can be created from scratch easily.
+ \Babel{} provides support (total or partial) for about 200
+ languages, either as a “classical” package option or as an
+ |ini| file. Furthermore, new languages can be created from scratch
+ easily.
\vspace{20cm}
\end{minipage}
@@ -223,6 +226,9 @@ Javier Bezos
This user guide focuses on \LaTeX. There are also some notes on its
use with Plain \TeX.
+If you are interested in the \TeX{} multilingual support, please join the
+\textsf{kadingira} list on \texttt{http://tug.org/mailman/listinfo/kadingira}.
+
\section{The user interface}\label{U-I}
\subsection{Monolingual documents}
@@ -370,9 +376,7 @@ modifiers is a more general mechanism.
\subsection{\textsf{xelatex} and \textsf{lualatex}}
Many languages are compatible with \textsf{xetex} and \textsf{luatex}.
-With them you can use \babel{} to localize the documents, but an
-advanced interface to handle fonts is still under development (among
-other things, language and script will be set by \babel).
+With them you can use \babel{} to localize the documents.
The Latin script is covered by default in current \LaTeX{} (provided
the document encoding is UTF-8), because the font loader is preloaded
@@ -404,15 +408,15 @@ _\usepackage[vietnamese,danish]{babel}_
Here is a simple monolingual document in Russian (text from the
Wikipedia). Note neither \textsf{fontenc} nor \textsf{inputenc} are
necessary, but the document should be encoded in UTF-8 and a
-so-called Unicode font must be loaded with \textsf{fontspec}.
+so-called Unicode font must be loaded (in this example |\babelfont| is
+used, described below).
\begin{verbatim}
\documentclass{article}
_\usepackage[russian]{babel}_
-\usepackage{fontspec}
-\setmainfont[_Language=Russian,Script=Cyrillic_]{DejaVu Serif}
+\babelfont{rm}{DejaVu Serif}
\begin{document}
@@ -423,7 +427,6 @@ _\usepackage[russian]{babel}_
\end{document}
\end{verbatim}
-
\end{example}
\subsection{Troubleshooting}
@@ -454,8 +457,8 @@ _\usepackage[russian]{babel}_
cases, the error vanishes when the document is typeset again, but in
more severe ones you will need to remove the |aux| file.
-\item The following warning is about hyphenation patterns and it is not
- under the direct control of \babel:
+\item The following warning is about hyphenation patterns, which are
+ not under the direct control of \babel:
\begin{verbatim}
Package babel Warning: No hyphenation patterns were preloaded for
(babel) the language `LANG' into the format.
@@ -508,7 +511,6 @@ for the language chosen:
\selectlanguage{german}
\end{verbatim}
-
This command can be used as environment, too.
\begin{note}
@@ -629,13 +631,20 @@ text
|\begin{finnish}|).
\end{note}
+\begin{note}
+ Actually, there may be another advantage in the ‘short’ syntax |\text|\m{tag},
+ namely, it is not affected by |\MakeUppercase| (while
+ |\foreignlanguage| is).
+\end{note}
+
\Describe\babelensure{|[include=|\m{commands}|,exclude=|\m{commands}%
|,fontenc=|\m{encoding}|]|\marg{language}}
-\New{3.9i} Except in a few languages, like Russian, captions and
-dates are just strings, and do not switch the language. That means
-you should set it explicitly if you want to use them, or hyphenation
-(and in some cases the text itself) will be wrong. For example:
+\New{3.9i} Except in a few languages, like \textsf{russian},
+captions and dates are just strings, and do not switch the
+language. That means you should set it explicitly if you want to use
+them, or hyphenation (and in some cases the text itself) will be
+wrong. For example:
\begin{verbatim}
\foreignlanguage{russian}{text \foreignlanguage{polish}{\seename} text}
\end{verbatim}
@@ -662,88 +671,7 @@ event), and it makes some assumptions which could not be fulfilled in
some languages. Note also you should include only macros defined by
the language, not global macros (eg, |\TeX| of |\dag|).
-\subsection{Getting the current language name}
-
-\Describe\languagename{}
-The control sequence |\languagename| contains the name of the
-current language.
-
-\begin{warning}
- Due to some internal inconsistencies in catcodes it should
- \textit{not} be used to test its value. Use \textsf{iflang}, by
- Heiko Oberdiek.
-\end{warning}
-
-\Describe\iflanguage{\marg{language}\marg{true}\marg{false}}
-
-If more than one language is used, it might be necessary to know which
-language is active at a specific time. This can be checked by a call
-to |\iflanguage|, but note here ``language'' is used in the \TeX\
-sense, as a set of hyphenation patterns, and \textit{not} as its
-\textsf{babel} name. This macro takes three arguments. The first
-argument is the name of a language; the second and third arguments are
-the actions to take if the result of the test is true or false
-respectively.
-
-\begin{warning}
- The advice about |\languagename| also applies here -- use
- \textsf{iflang} instead of |\iflanguage| if possible.
-\end{warning}
-
-
-\subsection{Selecting scripts}
-
-Currently \babel{} provides no standard interface to select
-scripts, because they are best selected with either |\fontencoding|
-(low level) or a language name (high level). Even the Latin script may
-require different encodings (ie, sets of glyphs) depending on the
-language, and therefore such a switch would be in a sense
-incomplete.\footnote{The so-called Unicode fonts do not improve the
-situation either. So, a font suited for Vietnamese is not necessarily
-suited for, say, the romanization of Indic languages, and the fact it
-contains glyphs for Modern Greek does not mean it includes them for
-Classic Greek. As to directionality, it poses special challenges
-because it also affects individual characters and layout elements.}
-
-
-Some languages sharing the same script define macros to switch it (eg,
-|\textcyrillic|), but be aware they may also set the language to a
-certain default. Even the \babel{} core defined |\textlatin|, but is
-was somewhat buggy because in some cases it messed up encodings and
-fonts (for example, if the main latin encoding was |LY1|), and
-therefore it has been deprecated.\footnote{But still defined for
-backwards compatibility.}
-
-No macros to select the writing direction are provided, either --
-writing direction is intrinsic to each script and therefore it is best
-set by the language (which could be a dummy one). Furthermore, there
-are in fact two right-to-left modes, depending on the language, which
-differ in the way `weak' numeric characters are ordered (eg, Arabic
-\%123 \textit{vs} Hebrew 123\%).
-
-\Describe{\ensureascii}{\marg{text}}
-
-\New{3.9i} This macro makes sure \m{text} is typeset with a
-LICR-savvy encoding in the ASCII range. It is used to redefine |\TeX|
-and |\LaTeX| so that they are correctly typeset even with |LGR| or
-|X2| (the complete list is stored in |\BabelNonASCII|, which by default
-is |LGR|, |X2|, |OT2|, |OT3|, |OT6|, |LHE|, |LWN|, |LMA|, |LMC|,
-|LMS|, |LMU|, but you can modify it). So, in some sense it fixes the
-bug described in the previous paragraph.
-
-If non-ASCII encodings are not loaded (or no encoding at all), it is
-no-op (also |\TeX| and |\LaTeX| are not redefined); otherwise,
-|\ensureascii| switches to the encoding at the beginning of the
-document if ASCII-savvy, or else the last ASCII-savvy encoding
-loaded. For example, if you load |LY1,LGR|, then it is set to |LY1|,
-but if you load |LY1,T2A| it is set to |T2A|. The symbol encodings
-|TS1|, |T3|, and |TS3| are not taken into account, since they are not
-used for ``ordinary'' text.
-
-The foregoing rules (which are applied ``at begin document'') cover
-most of cases. No asumption is made on characters above
-127, which may not follow the LICR conventions -- the goal is just
-to ensure most of the ASCII letters and symbols are the right ones.
+With |ini| files (see below), captions are ensured by default.
\subsection{Shorthands}
@@ -771,7 +699,7 @@ precedence). Version 3.9 introduces the \textit{language user} level
on top of the user level, as described below. In most cases, you will
use only shorthands provided by languages.
-Please, note the following:
+\begin{note} Note the following:
\begin{enumerate}
\item Activated chars used for two-char shorthands cannot be followed
by a closing brace |}| and the spaces following are gobbled. With
@@ -783,6 +711,7 @@ Please, note the following:
character in its definition (except if it is deactivated with, eg,
|string|).
\end{enumerate}
+\end{note}
A typical error when using shorthands is the following:
\begin{verbatim}
@@ -845,11 +774,11 @@ The command |\defineshorthand| takes two arguments: the first is
a one- or two-character shorthand sequence, and the second is the
code the shorthand should expand to.
-\New{3.9a} An optional argument allows to (re)define language
-and system shorthands (some languages do not activate shorthands,
-so you may want to add |\languageshorthands|\marg{lang} to the
-corresponding |\extras|\m{lang}). By default, user shorthands are
-(re)defined.
+\New{3.9a} An optional argument allows to (re)define language and
+system shorthands (some languages do not activate shorthands, so you
+may want to add |\languageshorthands|\marg{lang} to the corresponding
+|\extras|\m{lang}, as explained below). By default, user shorthands
+are (re)defined.
User shorthands override language ones, which in turn override
system shorthands. Language-dependent user shorthands (new in
@@ -865,7 +794,7 @@ system shorthands. Language-dependent user shorthands (new in
\defineshorthand{"-}{\babelhyphen{hard}}
\end{verbatim}
However, behaviour of hyphens is language dependent. For example, in
- languages like Polish and Portugese, a hard hyphen inside compound
+ languages like Polish and Portuguese, a hard hyphen inside compound
words are repeated at the beginning of the next line. You could then
set:
\begin{verbatim}
@@ -887,21 +816,29 @@ The command |\aliasshorthand| can be used to let another
character perform the same functions as the default shorthand
character. If one prefers for example to use the character |/|
over |"| in typing Polish texts, this can be achieved by entering
-|\aliasshorthand{"}{/}|. \emph{Please note} the substitute
-character must \textit{not} have been declared before as
-shorthand (in such case, |\aliashorthands| is ignored).
+|\aliasshorthand{"}{/}|.
+
+\begin{note}
+ The substitute character must \textit{not} have been declared before
+ as shorthand (in such a case, |\aliashorthands| is ignored).
+\end{note}
-The following example shows how to replace a shorthand by another
+\begin{example}
+ The following example shows how to replace a shorthand by another
\begin{verbatim}
\aliasshorthand{~}{^}
\AtBeginDocument{\shorthandoff*{~}}
\end{verbatim}
-However, shorthands remember somehow the original character, and the
-fallback value is that of the latter. So, in this example, if no
-shorthand if found, |^| expands to a non-breaking space, because this
-is the value of |~| (internally, |^| calls |\active@char~| or
-|\normal@char~|). Furthermore, if you change the |system| value of |^|
-with |\defineshorthand| nothing happens.
+\end{example}
+
+\begin{warning}
+ Shorthands remember somehow the original character, and the fallback
+ value is that of the latter. So, in this example, if no shorthand if
+ found, |^| expands to a non-breaking space, because this is the
+ value of |~| (internally, |^| still calls |\active@char~| or
+ |\normal@char~|). Furthermore, if you change the |system| value of
+ |^| with |\defineshorthand| nothing happens.
+\end{warning}
\Describe\languageshorthands{\marg{language}} The command
|\languageshorthands| can be used to switch the shorthands on the
@@ -1098,13 +1035,48 @@ can take the following values:
really useful, but who knows.}
\end{description}
-\Describe{bidi=}{\texttt{basic-r}}
+\Describe{bidi=}{\texttt{default} $\string|$ \texttt{basic-r}}
+
+\New{3.14} Selects the bidi algorithm to be used in \luatex{} and
+\xetex{}. With |default| the bidi mechanism is just activated (by default
+it is not), but every change must by marked up. In \xetex{} this is
+the only option. In \luatex, |basic-r|, provides a simple and fast
+method for R text, which handles numbers and unmarked L text within an
+R context.
-\New{3.14} Selects the bidi algorithm to be used in \luatex{}. By
-default, every change must by marked up. With |basic-r| a simple and
-fast method for R text is used, which handles numbers and unmarked L
-text within an R context. This is the only option provided
-currently. See below, sec. “Tentative and experimental code”.
+\begin{example}
+The following text comes from the Arabic Wikipedia (article about
+Arabia). Copy-pasting some text from the Wikipedia is a good way to
+test this feature, which will be improved in the future. Remember
+|basic-r| is available in \luatex{} only.
+ \begingroup
+% If you are looking at the code to see how it has been written, you
+% will be disappointed :-). The following example is built ad hoc to
+% emulate the final result to avoid dependencies, and therefore it's
+% not "real" code.
+\setmonofont[Scale=.87,Script=Arabic]{DejaVu Sans Mono} \catcode`@=13
+\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
+\bgroup\textdir TRT \pardir TRT \fi}
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[nil, _bidi=basic-r_]{babel}
+
+_\babelprovide[import=ar, main]{arabic}_
+
+\babelfont{rm}{FreeSerif}
+
+\begin{document}
+
+@9وقد عرفت شبه جزيرة العرب طيلة العصر الهيليني )الاغريقي( بـ
+@1Arabia@0 أو @1Aravia@0 )بالاغريقية @1Αραβία@0(، استخدم الرومان ثلاث
+بادئات بـ@1“Arabia”@0 على ثلاث مناطق من شبه الجزيرة العربية، إلا أنها
+حقيقةً كانت أكبر مما تعرف عليه اليوم.
+
+@0\end{document}
+\end{verbatim}
+\endgroup
+\end{example}
\subsection{The \texttt{base} option}
@@ -1115,6 +1087,7 @@ option (by its name in |language.dat|). There are two main uses:
classes and packages, and as a last resort in case there are, for some
reason, incompatible languages. It can be used if you just want to
select the hyphenations patterns of a single language, too.
+% TODO: example
\Describe\AfterBabelLanguage{\marg{option-name}\marg{code}}
@@ -1142,6 +1115,778 @@ be the same as the option name as set in |\usepackage|!).
\end{verbatim}
\end{example}
+\subsection{\texttt{ini} files}
+
+An alternative approach to define a language is by means of an
+\texttt{ini} file. Currently \babel{} provides about 200 of these
+files containing the basic data required for a language.
+
+Most of them set the date, and many also the captions (Unicode and
+LICR). They will be evolving with the time to add more features
+(something to keep in mind if backward compatibility is
+important). The following section shows how to make use of them
+currently (by means of |\babelprovide|), but a higher interface, based
+on package options, in under development.
+
+\begin{example}
+ Although Georgian has its own \texttt{ldf} file, here is how to
+ declare this language with an |ini| file in Unicode engines. The
+ |nil| language is required, because currently \babel{} raises an
+ error if there is no language.
+\begingroup
+\setmonofont[Scale=.87,Script=Georgian]{DejaVu Sans Mono}
+\begin{verbatim}
+\documentclass{book}
+
+\usepackage[nil]{babel}
+\babelprovide[import=ka, main]{georgian}
+
+\babelfont{rm}{DejaVu Sans}
+
+\begin{document}
+
+\tableofcontents
+
+\chapter{სამზარეულო და სუფრის ტრადიციები}
+
+ქართული ტრადიციული სამზარეულო ერთ-ერთი უმდიდრესია მთელ მსოფლიოში.
+
+\end{document}
+\end{verbatim}
+\endgroup
+\end{example}
+
+Here is the list (u means Unicode captions, and l means LICR
+captions):
+
+\begingroup
+\bigskip\hrule\nobreak
+
+\makeatletter
+\def\tag#1{\par\@hangfrom{\makebox[7em][l]{#1}}\ignorespaces}
+\def\hascapu{\textsuperscript{u}}
+\def\hascapl{\textsuperscript{l}}
+
+\begin{multicols}{2}
+
+\tag{af} Afrikaans\hascapu\hascapl
+\tag{agq} Aghem
+\tag{ak} Akan
+\tag{am} Amharic\hascapu\hascapl
+\tag{ar} Arabic\hascapu\hascapl
+\tag{as} Assamese
+\tag{asa} Asu
+\tag{ast} Asturian\hascapu\hascapl
+\tag{az-Cyrl} Azerbaijani
+\tag{az-Latn} Azerbaijani
+\tag{az} Azerbaijani\hascapu\hascapl
+\tag{bas} Basaa
+\tag{be} Belarusian\hascapu\hascapl
+\tag{bem} Bemba
+\tag{bez} Bena
+\tag{bg} Bulgarian\hascapu\hascapl
+\tag{bm} Bambara
+\tag{bn} Bangla\hascapu\hascapl
+\tag{bo} Tibetan\hascapu
+\tag{brx} Bodo
+\tag{bs-Cyrl} Bosnian
+\tag{bs-Latn} Bosnian\hascapu\hascapl
+\tag{bs} Bosnian\hascapu\hascapl
+\tag{ca} Catalan\hascapu\hascapl
+\tag{ce} Chechen
+\tag{cgg} Chiga
+\tag{chr} Cherokee
+\tag{ckb} Central Kurdish
+\tag{cs} Czech\hascapu\hascapl
+\tag{cy} Welsh\hascapu\hascapl
+\tag{da} Danish\hascapu\hascapl
+\tag{dav} Taita
+\tag{de-AT} German\hascapu\hascapl
+\tag{de-CH} German\hascapu\hascapl
+\tag{de} German\hascapu\hascapl
+\tag{dje} Zarma
+\tag{dsb} Lower Sorbian\hascapu\hascapl
+\tag{dua} Duala
+\tag{dyo} Jola-Fonyi
+\tag{dz} Dzongkha
+\tag{ebu} Embu
+\tag{ee} Ewe
+\tag{el} Greek\hascapu\hascapl
+\tag{en-AU} English\hascapu\hascapl
+\tag{en-CA} English\hascapu\hascapl
+\tag{en-GB} English\hascapu\hascapl
+\tag{en-NZ} English\hascapu\hascapl
+\tag{en-US} English\hascapu\hascapl
+\tag{en} English\hascapu\hascapl
+\tag{eo} Esperanto\hascapu\hascapl
+\tag{es-MX} Spanish\hascapu\hascapl
+\tag{es} Spanish\hascapu\hascapl
+\tag{et} Estonian\hascapu\hascapl
+\tag{eu} Basque\hascapu\hascapl
+\tag{ewo} Ewondo
+\tag{fa} Persian\hascapu\hascapl
+\tag{ff} Fulah
+\tag{fi} Finnish\hascapu\hascapl
+\tag{fil} Filipino
+\tag{fo} Faroese
+\tag{fur} Friulian\hascapu\hascapl
+\tag{fy} Western Frisian
+\tag{ga} Irish\hascapu\hascapl
+\tag{gd} Scottish Gaelic\hascapu\hascapl
+\tag{gl} Galician\hascapu\hascapl
+\tag{gsw} Swiss German
+\tag{gu} Gujarati
+\tag{guz} Gusii
+\tag{gv} Manx
+\tag{ha-GH} Hausa
+\tag{ha-NE} Hausa\hascapl
+\tag{ha} Hausa
+\tag{haw} Hawaiian
+\tag{he} Hebrew\hascapu\hascapl
+\tag{hi} Hindi\hascapu
+\tag{hr} Croatian\hascapu\hascapl
+\tag{hsb} Upper Sorbian\hascapu\hascapl
+\tag{hu} Hungarian\hascapu\hascapl
+\tag{hy} Armenian
+\tag{ia} Interlingua\hascapu\hascapl
+\tag{id} Indonesian\hascapu\hascapl
+\tag{ig} Igbo
+\tag{ii} Sichuan Yi
+\tag{is} Icelandic\hascapu\hascapl
+\tag{it} Italian\hascapu\hascapl
+\tag{ja} Japanese
+\tag{jgo} Ngomba
+\tag{jmc} Machame
+\tag{ka} Georgian\hascapu\hascapl
+\tag{kab} Kabyle
+\tag{kam} Kamba
+\tag{kde} Makonde
+\tag{kea} Kabuverdianu
+\tag{khq} Koyra Chiini
+\tag{ki} Kikuyu
+\tag{kk} Kazakh
+\tag{kkj} Kako
+\tag{kl} Kalaallisut
+\tag{kln} Kalenjin
+\tag{km} Khmer
+\tag{kn} Kannada\hascapu\hascapl
+\tag{ko} Korean
+\tag{kok} Konkani
+\tag{ks} Kashmiri
+\tag{ksb} Shambala
+\tag{ksf} Bafia
+\tag{ksh} Colognian
+\tag{kw} Cornish
+\tag{ky} Kyrgyz
+\tag{lag} Langi
+\tag{lb} Luxembourgish
+\tag{lg} Ganda
+\tag{lkt} Lakota
+\tag{ln} Lingala
+\tag{lo} Lao\hascapu\hascapl
+\tag{lrc} Northern Luri
+\tag{lt} Lithuanian\hascapu\hascapl
+\tag{lu} Luba-Katanga
+\tag{luo} Luo
+\tag{luy} Luyia
+\tag{lv} Latvian\hascapu\hascapl
+\tag{mas} Masai
+\tag{mer} Meru
+\tag{mfe} Morisyen
+\tag{mg} Malagasy
+\tag{mgh} Makhuwa-Meetto
+\tag{mgo} Metaʼ
+\tag{mk} Macedonian\hascapu\hascapl
+\tag{ml} Malayalam\hascapu\hascapl
+\tag{mn} Mongolian
+\tag{mr} Marathi\hascapu\hascapl
+\tag{ms-BN} Malay\hascapl
+\tag{ms-SG} Malay\hascapl
+\tag{ms} Malay\hascapu\hascapl
+\tag{mt} Maltese
+\tag{mua} Mundang
+\tag{my} Burmese
+\tag{mzn} Mazanderani
+\tag{naq} Nama
+\tag{nb} Norwegian Bokmål\hascapu\hascapl
+\tag{nd} North Ndebele
+\tag{ne} Nepali
+\tag{nl} Dutch\hascapu\hascapl
+\tag{nmg} Kwasio
+\tag{nn} Norwegian Nynorsk\hascapu\hascapl
+\tag{nnh} Ngiemboon
+\tag{nus} Nuer
+\tag{nyn} Nyankole
+\tag{om} Oromo
+\tag{or} Odia
+\tag{os} Ossetic
+\tag{pa-Arab} Punjabi
+\tag{pa-Guru} Punjabi
+\tag{pa} Punjabi
+\tag{pl} Polish\hascapu\hascapl
+\tag{pms} Piedmontese\hascapu\hascapl
+\tag{ps} Pashto
+\tag{pt-BR} Portuguese\hascapu\hascapl
+\tag{pt-PT} Portuguese\hascapu\hascapl
+\tag{pt} Portuguese\hascapu\hascapl
+\tag{qu} Quechua
+\tag{rm} Romansh\hascapu\hascapl
+\tag{rn} Rundi
+\tag{ro} Romanian\hascapu\hascapl
+\tag{rof} Rombo
+\tag{ru} Russian\hascapu\hascapl
+\tag{rw} Kinyarwanda
+\tag{rwk} Rwa
+\tag{sah} Sakha
+\tag{saq} Samburu
+\tag{sbp} Sangu
+\tag{se} Northern Sami\hascapu\hascapl
+\tag{seh} Sena
+\tag{ses} Koyraboro Senni
+\tag{sg} Sango
+\tag{shi-Latn} Tachelhit
+\tag{shi-Tfng} Tachelhit
+\tag{shi} Tachelhit
+\tag{si} Sinhala
+\tag{sk} Slovak\hascapu\hascapl
+\tag{sl} Slovenian\hascapu\hascapl
+\tag{smn} Inari Sami
+\tag{sn} Shona
+\tag{so} Somali
+\tag{sq} Albanian\hascapu\hascapl
+\tag{sr-Cyrl-BA} Serbian\hascapu\hascapl
+\tag{sr-Cyrl-ME} Serbian\hascapu\hascapl
+\tag{sr-Cyrl-XK} Serbian\hascapu\hascapl
+\tag{sr-Cyrl} Serbian\hascapu\hascapl
+\tag{sr-Latn-BA} Serbian\hascapu\hascapl
+\tag{sr-Latn-ME} Serbian\hascapu\hascapl
+\tag{sr-Latn-XK} Serbian\hascapu\hascapl
+\tag{sr-Latn} Serbian\hascapu\hascapl
+\tag{sr} Serbian\hascapu\hascapl
+\tag{sv} Swedish\hascapu\hascapl
+\tag{sw} Swahili
+\tag{ta} Tamil\hascapu
+\tag{te} Telugu\hascapu\hascapl
+\tag{teo} Teso
+\tag{th} Thai\hascapu\hascapl
+\tag{ti} Tigrinya
+\tag{tk} Turkmen\hascapu\hascapl
+\tag{to} Tongan
+\tag{tr} Turkish\hascapu\hascapl
+\tag{twq} Tasawaq
+\tag{tzm} Central Atlas Tamazight
+\tag{ug} Uyghur
+\tag{uk} Ukrainian\hascapu\hascapl
+\tag{ur} Urdu\hascapu\hascapl
+\tag{uz-Arab} Uzbek
+\tag{uz-Cyrl} Uzbek
+\tag{uz-Latn} Uzbek
+\tag{uz} Uzbek
+\tag{vai-Latn} Vai
+\tag{vai-Vaii} Vai
+\tag{vai} Vai
+\tag{vi} Vietnamese\hascapu\hascapl
+\tag{vun} Vunjo
+\tag{wae} Walser
+\tag{xog} Soga
+\tag{yav} Yangben
+\tag{yi} Yiddish
+\tag{yo} Yoruba
+\tag{yue} Cantonese
+\tag{zgh} Standard Moroccan Tamazight
+\tag{zh-Hans-HK} Chinese
+\tag{zh-Hans-MO} Chinese
+\tag{zh-Hans-SG} Chinese
+\tag{zh-Hans} Chinese
+\tag{zh-Hant-HK} Chinese
+\tag{zh-Hant-MO} Chinese
+\tag{zh-Hant} Chinese
+\tag{zh} Chinese
+\tag{zu} Zulu
+
+\end{multicols}
+\endgroup
+\hrule
+\bigskip
+
+In some context (currently |\babelfont|) an \textsc{ini} file may be
+loaded by its name. Here is the list of the names currently
+supported. With these languages, |\babelfont| loads (if not done
+before) the language and script names (even if the language is defined
+as a package option with an \textsf{ldf} file).
+
+\begingroup
+\bigskip\hrule\nobreak
+
+\let\\\par
+
+\begin{multicols}{2}
+
+aghem\\
+akan\\
+albanian\\
+american\\
+amharic\\
+arabic\\
+armenian\\
+assamese\\
+asturian\\
+asu\\
+australian\\
+austrian\\
+azerbaijani-cyrillic\\
+azerbaijani-cyrl\\
+azerbaijani-latin\\
+azerbaijani-latn\\
+azerbaijani\\
+bafia\\
+bambara\\
+basaa\\
+basque\\
+belarusian\\
+bemba\\
+bena\\
+bengali\\
+bodo\\
+bosnian-cyrillic\\
+bosnian-cyrl\\
+bosnian-latin\\
+bosnian-latn\\
+bosnian\\
+brazilian\\
+breton\\
+british\\
+bulgarian\\
+burmese\\
+canadian\\
+cantonese\\
+catalan\\
+centralatlastamazight\\
+centralkurdish\\
+chechen\\
+cherokee\\
+chiga\\
+chinese-hans-hk\\
+chinese-hans-mo\\
+chinese-hans-sg\\
+chinese-hans\\
+chinese-hant-hk\\
+chinese-hant-mo\\
+chinese-hant\\
+chinese-simplified-hongkongsarchina\\
+chinese-simplified-macausarchina\\
+chinese-simplified-singapore\\
+chinese-simplified\\
+chinese-traditional-hongkongsarchina\\
+chinese-traditional-macausarchina\\
+chinese-traditional\\
+chinese\\
+colognian\\
+cornish\\
+croatian\\
+czech\\
+danish\\
+duala\\
+dutch\\
+dzongkha\\
+embu\\
+english-au\\
+english-australia\\
+english-ca\\
+english-canada\\
+english-gb\\
+english-newzealand\\
+english-nz\\
+english-unitedkingdom\\
+english-unitedstates\\
+english-us\\
+english\\
+esperanto\\
+estonian\\
+ewe\\
+ewondo\\
+faroese\\
+filipino\\
+finnish\\
+french-be\\
+french-belgium\\
+french-ca\\
+french-canada\\
+french-ch\\
+french-lu\\
+french-luxembourg\\
+french-switzerland\\
+french\\
+friulian\\
+fulah\\
+galician\\
+ganda\\
+georgian\\
+german-at\\
+german-austria\\
+german-ch\\
+german-switzerland\\
+german\\
+greek\\
+gujarati\\
+gusii\\
+hausa-gh\\
+hausa-ghana\\
+hausa-ne\\
+hausa-niger\\
+hausa\\
+hawaiian\\
+hebrew\\
+hindi\\
+hungarian\\
+icelandic\\
+igbo\\
+inarisami\\
+indonesian\\
+interlingua\\
+irish\\
+italian\\
+japanese\\
+jolafonyi\\
+kabuverdianu\\
+kabyle\\
+kako\\
+kalaallisut\\
+kalenjin\\
+kamba\\
+kannada\\
+kashmiri\\
+kazakh\\
+khmer\\
+kikuyu\\
+kinyarwanda\\
+konkani\\
+korean\\
+koyraborosenni\\
+koyrachiini\\
+kwasio\\
+kyrgyz\\
+lakota\\
+langi\\
+lao\\
+latvian\\
+lingala\\
+lithuanian\\
+lowersorbian\\
+lsorbian\\
+lubakatanga\\
+luo\\
+luxembourgish\\
+luyia\\
+macedonian\\
+machame\\
+makhuwameetto\\
+makonde\\
+malagasy\\
+malay-bn\\
+malay-brunei\\
+malay-sg\\
+malay-singapore\\
+malay\\
+malayalam\\
+maltese\\
+manx\\
+marathi\\
+masai\\
+mazanderani\\
+meru\\
+meta\\
+mexican\\
+mongolian\\
+morisyen\\
+mundang\\
+nama\\
+nepali\\
+newzealand\\
+ngiemboon\\
+ngomba\\
+norsk\\
+northernluri\\
+northernsami\\
+northndebele\\
+norwegianbokmal\\
+norwegiannynorsk\\
+nswissgerman\\
+nuer\\
+nyankole\\
+nynorsk\\
+occitan\\
+oriya\\
+oromo\\
+ossetic\\
+pashto\\
+persian\\
+piedmontese\\
+polish\\
+portuguese-br\\
+portuguese-brazil\\
+portuguese-portugal\\
+portuguese-pt\\
+portuguese\\
+punjabi-arab\\
+punjabi-arabic\\
+punjabi-gurmukhi\\
+punjabi-guru\\
+punjabi\\
+quechua\\
+romanian\\
+romansh\\
+rombo\\
+rundi\\
+russian\\
+rwa\\
+sakha\\
+samburu\\
+samin\\
+sango\\
+sangu\\
+scottishgaelic\\
+sena\\
+serbian-cyrillic-bosniaherzegovina\\
+serbian-cyrillic-kosovo\\
+serbian-cyrillic-montenegro\\
+serbian-cyrillic\\
+serbian-cyrl-ba\\
+serbian-cyrl-me\\
+serbian-cyrl-xk\\
+serbian-cyrl\\
+serbian-latin-bosniaherzegovina\\
+serbian-latin-kosovo\\
+serbian-latin-montenegro\\
+serbian-latin\\
+serbian-latn-ba\\
+serbian-latn-me\\
+serbian-latn-xk\\
+serbian-latn\\
+serbian\\
+shambala\\
+shona\\
+sichuanyi\\
+sinhala\\
+slovak\\
+slovene\\
+slovenian\\
+soga\\
+somali\\
+spanish-mexico\\
+spanish-mx\\
+spanish\\
+standardmoroccantamazight\\
+swahili\\
+swedish\\
+swissgerman\\
+tachelhit-latin\\
+tachelhit-latn\\
+tachelhit-tfng\\
+tachelhit-tifinagh\\
+tachelhit\\
+taita\\
+tamil\\
+tasawaq\\
+telugu\\
+teso\\
+thai\\
+tibetan\\
+tigrinya\\
+tongan\\
+turkish\\
+turkmen\\
+ukenglish\\
+ukrainian\\
+uppersorbian\\
+urdu\\
+usenglish\\
+usorbian\\
+uyghur\\
+uzbek-arab\\
+uzbek-arabic\\
+uzbek-cyrillic\\
+uzbek-cyrl\\
+uzbek-latin\\
+uzbek-latn\\
+uzbek\\
+vai-latin\\
+vai-latn\\
+vai-vai\\
+vai-vaii\\
+vai\\
+vietnam\\
+vietnamese\\
+vunjo\\
+walser\\
+welsh\\
+westernfrisian\\
+yangben\\
+yiddish\\
+yoruba\\
+zarma\\
+zulu
+afrikaans\\
+
+\end{multicols}
+\endgroup
+\hrule
+
+\subsection{Selecting fonts}
+
+\New{3.15} Babel provides a high level interface on top of |fontspec| to select
+fonts. There is no need to load \textsf{fontspec} explicitly --
+\babel{} does it for you with the first |\babelfont|.
+
+\Describe\babelfont{\oarg{language-list}\marg{font-family}%
+ \oarg{font-options}\marg{font-name}}
+
+Here \textit{font-family} is |rm|, |sf| or |tt| (or newly defined
+ones, as explained below), and \textit{font-name} is the same as in
+\textsf{fontspec} and the like.
+
+If no language is given, then it is considered the default font for
+the family, activated when a language is selected. On the other hand,
+if there is one or more languages in the optional argument, the font
+will be assigned to them, overriding the default. Alternatively, you
+may set a font for a script -- just precede its name (lowercase) with
+a star (eg, |*devanagari|).
+
+\Babel{} takes care the font language and the font script when
+languages are selected (as well as the writing direction); see the
+recognized languages above. In most cases, you will not need
+\textit{font-options}, which is the same as in \textsf{fontspec}, but
+you may add further key/value pairs if necessary.
+
+\begin{example}
+ Usage in most cases is very simple. Let us assume you are setting up
+ a document in Swedish, with some words in Hebrew, with a font suited
+ for both languages.
+ \begingroup
+% If you are looking at the code to see how it has been written, you
+% will be disappointed :-). The following example is built ad hoc to
+% emulate the final result to avoid dependencies, and therefore it's
+% not "real" code.
+\setmonofont[Scale=.87,Script=Hebrew]{DejaVu Sans Mono} \catcode`@=13
+\def@#1{\ifcase#1\relax \egroup \or \bgroup\textdir TLT \else
+\bgroup\textdir TRT \fontspec[Scale=.87,Script=Hebrew]{Liberation
+Mono} \fi}
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[swedish]{babel}
+
+\babelprovide[import=he]{hebrew}
+
+_\babelfont{rm}{FreeSerif}_
+
+\begin{document}
+
+Svenska \foreignlanguage{hebrew}{@2עִבְרִית@0} svenska.
+
+\end{document}
+\end{verbatim}
+\endgroup
+
+If on the other hand you have to resort to different fonts, you could
+replace the red line above with, say:
+\begin{verbatim}
+\babelfont{rm}{Iwona}
+\babelfont[hebrew]{rm}{FreeSerif}
+\end{verbatim}
+\end{example}
+
+|\babelfont| can be used to implicitly define a new font family. Just
+write its name instead of |rm|, |sf| or |tt|. This is the preferred way
+to select fonts in addition to the three basic ones.
+
+\begin{example}
+ Here is how to do it:
+\begin{verbatim}
+\babelfont{kai}{FandolKai}
+\end{verbatim}
+Now, |\kaifamily| and |\kaidefault| are at your disposal.
+\end{example}
+
+\begin{note}
+ Directionality is a property affecting margins, intentation, column
+ order, etc., not just text. Therefore, it is under the direct
+ control of the language, which appplies both the script and the
+ direction to the text. As a consequence, there is no need to set
+ \texttt{Script} when declaring a font (nor \texttt{Language}). In
+ fact, it is even discouraged.
+\end{note}
+
+\begin{note}
+ |\fontspec| is not touched at all, only the preset font families
+ (|rm|, |sf|, |tt|, and the like). If a language is switched when an
+ \textit{ad hoc} font is active, or you select the font it with this
+ command, neither the script nor the language are passed. You must
+ add them by hand. This is by design, for several reasons (for
+ example, each font has its own set of features and a generic setting
+ for several of them could be problematic, and also a “lower level”
+ font selection is useful).
+\end{note}
+
+\begin{note}
+ The keys |Language| and |Script| just pass these values to the
+ \textit{font}, and do \textit{not} set the script for the
+ \textit{language} (and therefore the writing direction). In other
+ words, the |ini| file or |\babelprovide| provides default values for
+ |\babelfont| if omitted, but the opposite is not true. See the note
+ above for the reasons of this behaviour.
+\end{note}
+
+\begin{warning}
+ Do not use |\set|\textit{xxxx}|font| and |\babelfont| at the same
+ time. |\babelfont| follows the standard \LaTeX{} conventions to set
+ the basic families -- define |\|\textit{xx}|default|, and activate
+ it with |\|\textit{xx}|family|. On the other hand,
+ |\set|\textit{xxxx}|font| in \textsf{fontspec} takes a different
+ approach, because |\|\textit{xx}|family| is redefined with the
+ family name hardcoded (so that |\|\textit{xx}|default| becomes
+ no-op). Of course, both methods are incompatible, and if you use
+ |\set|\textit{xxxx}|font|, font switching with |\babelfont| just
+ does \textit{not} work (nor the standard |\|\textit{xx}|default|,
+ for that matter).
+\end{warning}
+
+\subsection{Modifying a language}
+
+Modifying the behaviour of a language (say, the chapter “caption”), is
+sometimes necessary, but not always trivial.
+\begin{itemize}
+\item The old way, still valid for many languages, to redefine a
+ caption is the following:
+\begin{verbatim}
+\addto\captionsenglish{%
+ \renewcommand\contentsname{Foo}%
+}
+\end{verbatim}
+ As of 3.15, there is no need to hide spaces with \texttt{\%}
+(\babel{} removes them), but it is advisable to do it.
+\item The new way, which is found in |bulgarian|, |azerbaijani|,
+ |spanish|, |french|, |turkish|, |icelandic|, |vietnamese| and a few
+ more, as well as in languages created with |\babelprovide| and its
+ key |import|, is:
+\begin{verbatim}
+\renewcommand\spanishchaptername{Foo}
+\end{verbatim}
+\item Macros to be run when a language is selected can be add to
+ |\extras|\m{lang}:
+\begin{verbatim}
+\addto\extrasrussian{\mymacro}
+\end{verbatim}
+There is a counterpart for code to be run when a language is
+unselected: |\noextras|\m{lang}.
+\end{itemize}
+
+\begin{note}
+ These macros (|\captions|\m{lang}, |\extras|\m{lang}) may be redefined, but
+ must not be used as such -- they just pass information to \babel{},
+ which executes them in the proper context.
+\end{note}
+
\subsection{Creating a language}
\New{3.10} And what if there is no style for your language or none
@@ -1188,8 +1933,8 @@ and hyphenmins. For example:
\begin{verbatim}
\babelprovide[import=hu]{hungarian}
\end{verbatim}
-Unicode engines load the UTF-8 variants, while
-8-bit engines load the LICR (ie, with macros like |\'| or |\ss|) ones.
+Unicode engines load the UTF-8 variants, while 8-bit engines load the
+LICR (ie, with macros like |\'| or |\ss|) ones.
There are about 200 |ini| files, with data taken from the |ldf| files
and the CLDR provided by Unicode. Not all languages in the latter are
@@ -1203,18 +1948,11 @@ arguments: year, month and day numbers. In fact, |\today| calls
|\<language>today| which in turn calls
|\<language>date{\year}{\month}{\day}|.
-Encoding, font, \textsf{fontspec} language and script, writing
-direction, etc., are not touched at all. They will be loaded in the
-future and used in a forthcoming set of tools to set the language
-fonts.
-
\Describe{captions=}{\meta{language-tag}}
Loads only the strings. For example:
\begin{verbatim}
\babelprovide[captions=hu]{hungarian}
\end{verbatim}
-Encoding, font, \textsf{fontspec} language and script, writing
-direction, etc., are not touched at all.
\Describe{hyphenrules=}{\meta{language-list}} With this option, with a
space-separated list of hyphenation rules, \babel{} assigns to the
@@ -1241,13 +1979,51 @@ list is empty).
\Describe{main}{} This valueless option makes the language the main
one. Only in newly defined languages.
+\Describe{script=}{\meta{script-name}} \New{3.15} Sets the script name
+to be used by \textsf{fontspec} (eg, |Devanagari|). Overrides the
+value in the |ini| file. This value is particularly important because
+it sets the writing direction.
+
+\Describe{language=}{\meta{language-name}} \New{3.15} Sets the
+language name to be used by \textsf{fontspec} (eg, |Hindi|). Overrides
+the value in the |ini| file. Not so important, but sometimes still
+relevant.
+
\begin{note}
(1) If you need shorthands, you can use |\useshorthands| and
|\defineshorthand| as described above. (2) Captions and |\today| are
- ``ensured'' with |\babelensure| (because this will be the default in
+ ``ensured'' with |\babelensure| (this is be the default in
|ini|-based languages).
\end{note}
+\subsection{Getting the current language name}
+
+\Describe\languagename{}
+The control sequence |\languagename| contains the name of the
+current language.
+
+\begin{warning}
+ Due to some internal inconsistencies in catcodes, it should
+ \textit{not} be used to test its value. Use \textsf{iflang}, by
+ Heiko Oberdiek.
+\end{warning}
+
+\Describe\iflanguage{\marg{language}\marg{true}\marg{false}}
+
+If more than one language is used, it might be necessary to know which
+language is active at a specific time. This can be checked by a call
+to |\iflanguage|, but note here ``language'' is used in the \TeX\
+sense, as a set of hyphenation patterns, and \textit{not} as its
+\textsf{babel} name. This macro takes three arguments. The first
+argument is the name of a language; the second and third arguments are
+the actions to take if the result of the test is true or false
+respectively.
+
+\begin{warning}
+ The advice about |\languagename| also applies here -- use
+ \textsf{iflang} instead of |\iflanguage| if possible.
+\end{warning}
+
\subsection{Hooks}
\New{3.9a} A hook is a piece of code to be executed at certain
@@ -1435,6 +2211,59 @@ Listed patterns are saved expanded and therefore it relies on the
LICR. Of course, it also works without the LICR if the input and the
font encodings are the same, like in Unicode based engines.
+\subsection{Selecting scripts}
+
+Currently \babel{} provides no standard interface to select
+scripts, because they are best selected with either |\fontencoding|
+(low level) or a language name (high level). Even the Latin script may
+require different encodings (ie, sets of glyphs) depending on the
+language, and therefore such a switch would be in a sense
+incomplete.\footnote{The so-called Unicode fonts do not improve the
+situation either. So, a font suited for Vietnamese is not necessarily
+suited for, say, the romanization of Indic languages, and the fact it
+contains glyphs for Modern Greek does not mean it includes them for
+Classic Greek. As to directionality, it poses special challenges
+because it also affects individual characters and layout elements.}
+
+Some languages sharing the same script define macros to switch it (eg,
+|\textcyrillic|), but be aware they may also set the language to a
+certain default. Even the \babel{} core defined |\textlatin|, but is
+was somewhat buggy because in some cases it messed up encodings and
+fonts (for example, if the main latin encoding was |LY1|), and
+therefore it has been deprecated.\footnote{But still defined for
+backwards compatibility.}
+
+No macros to select the writing direction are provided, either --
+writing direction is intrinsic to each script and therefore it is best
+set by the language (which could be a dummy one). Furthermore, there
+are in fact two right-to-left modes, depending on the language, which
+differ in the way `weak' numeric characters are ordered (eg, Arabic
+\%123 \textit{vs} Hebrew 123\%).
+
+\Describe{\ensureascii}{\marg{text}}
+
+\New{3.9i} This macro makes sure \m{text} is typeset with a
+LICR-savvy encoding in the ASCII range. It is used to redefine |\TeX|
+and |\LaTeX| so that they are correctly typeset even with |LGR| or
+|X2| (the complete list is stored in |\BabelNonASCII|, which by default
+is |LGR|, |X2|, |OT2|, |OT3|, |OT6|, |LHE|, |LWN|, |LMA|, |LMC|,
+|LMS|, |LMU|, but you can modify it). So, in some sense it fixes the
+bug described in the previous paragraph.
+
+If non-ASCII encodings are not loaded (or no encoding at all), it is
+no-op (also |\TeX| and |\LaTeX| are not redefined); otherwise,
+|\ensureascii| switches to the encoding at the beginning of the
+document if ASCII-savvy, or else the last ASCII-savvy encoding
+loaded. For example, if you load |LY1,LGR|, then it is set to |LY1|,
+but if you load |LY1,T2A| it is set to |T2A|. The symbol encodings
+|TS1|, |T3|, and |TS3| are not taken into account, since they are not
+used for ``ordinary'' text.
+
+The foregoing rules (which are applied ``at begin document'') cover
+most of cases. No asumption is made on characters above
+127, which may not follow the LICR conventions -- the goal is just
+to ensure most of the ASCII letters and symbols are the right ones.
+
\subsection{Language attributes}
\DescribeMacro{\languageattribute}
@@ -1458,16 +2287,15 @@ options are also used (eg, |\ProsodicMarksOn| in \textsf{latin}).
\subsection{Languages supported by \babel}
In the following table most of the languages supported by \babel\ are
-listed, together with the names of the options which you can load
+listed, together with the names of the option which you can load
\babel\ with for each language. Note this list is open and the
-current options may be different.
+current options may be different. It does not include |ini| files.
\begin{description}
\itemsep=-\parskip
\sffamily
\item[Afrikaans] afrikaans
-\item[Bahasa] bahasa, indonesian, indon, bahasai,
- bahasam, malay, melayu
+\item[Azerbaijani] azerbaijani
\item[Basque] basque
\item[Breton] breton
\item[Bulgarian] bulgarian
@@ -1487,11 +2315,13 @@ current options may be different.
\item[Greek] greek, polutonikogreek
\item[Hebrew] hebrew
\item[Icelandic] icelandic
+\item[Indonesian] bahasa, indonesian, indon, bahasai
\item[Interlingua] interlingua
\item[Irish Gaelic] irish
\item[Italian] italian
\item[Latin] latin
\item[Lower Sorbian] lowersorbian
+\item[Malay] bahasam, malay, melayu
\item[North Sami] samin
\item[Norwegian] norsk, nynorsk
\item[Polish] polish
@@ -1611,7 +2441,68 @@ some languages (kerning and spacing). Ligatures can be disabled.
\item[tracklang] Tracks which languages have been requested.
\end{description}
-\subsection{Future work}
+\subsection{Current and future work}
+
+Current work is focused on the so-called complex scripts in \luatex{}.
+In 8-bit engines, \babel{} provided a basic support for bidi text as part
+of the style for Hebrew, but it is somewhat unsatisfactory and
+internally replaces some hardwired commands by other hardwired
+commands (generic changes would be much better).
+
+It is possible now to typeset Arabic or Hebrew with numbers and L
+text. Next on the roadmap are line breaking in Thai and the like,
+as well as “non-European” digits. Also on the roadmap are R layouts
+(lists, footnotes, tables, column order), page and section numbering,
+and maybe kashida justification.
+
+As to Thai line breaking, here is the basic idea of what \luatex{} can
+do for us, with the Thai patterns and a little script (the final
+version will not be so little, of course). It replaces each
+discretionary by the equivalent to ZWJ.
+
+\begingroup
+\catcode`\_=13 \def_{\string_}
+\begin{verbatim}
+\documentclass{article}
+
+\usepackage[nil]{babel}
+
+\babelprovide[import=th, main]{thai}
+
+\babelfont{rm}{FreeSerif}
+
+\directlua{
+local GLYF = node.id'glyph'
+function insertsp (head)
+ local size = 0
+ for item in node.traverse(head) do
+ local i = item.id
+ if i == GLYF then
+ f = font.getfont(item.font)
+ size = f.size
+ elseif i == 7 then
+ local n = node.new(12, 0)
+ node.setglue(n, 0, size * 1) % 1 is a factor
+ node.insert_before(head, item, n)
+ node.remove(head, item)
+ end
+ end
+end
+
+luatexbase.add_to_callback('hyphenate',
+ function (head, tail)
+ lang.hyphenate(head)
+ insertsp(head)
+ end, 'insertsp')
+}
+
+\begin{document}
+
+(Thai text.)
+
+\end{document}
+\end{verbatim}
+\endgroup
Useful additions would be, for example, time, currency, addresses and
personal names.\footnote{See for example POSIX, ISO 14652 and the
@@ -1620,7 +2511,7 @@ have limited application to \TeX\ because their aim is just to display
information and not fine typesetting.}. But that is the easy
part, because they don't require modifying the \LaTeX{} internals.
-More interesting are differences in the sentence structure or related
+Also interesting are differences in the sentence structure or related
to it. For example, in Basque the number precedes the name (including
chapters), in Hungarian ``from (1)'' is ``(1)-b\H{o}l'', but ``from
(3)'' is ``(3)-b\'{o}l'', in Spanish an item labelled
@@ -1628,116 +2519,40 @@ chapters), in Hungarian ``from (1)'' is ``(1)-b\H{o}l'', but ``from
``\'{\i}tem 3.$^{\textrm{\scriptsize o}}$'' or
``3.$^{\textrm{\scriptsize er}}$ \'{\i}tem'', and so on.
-Even more interesting is right-to-left, vertical and bidi
-typesetting. In 8-bit engines, Babel provided a basic support for bidi
-text as part of the style for Hebrew, but it is somewhat
-unsatisfactory and internally replaces some hardwired commands by
-other hardwired commands (generic changes would be much
-better). Current work is focused on \luatex.
-
\subsection{Tentative and experimental code}
Handling of \textbf{``Unicode'' fonts} is problematic. There is
\textsf{fontspec}, but special macros are required (not only the NFSS
ones) and it doesn't provide ``orthogonal axis'' for features,
including those related to the language (mainly language and
-script). A couple of tentative macros, which solve the two main cases,
-are provided by \babel{} ($\ge$3.9g) with a partial solution (only
-\xetex{} and \luatex, for obvious reasons), but use them at your own
-risk, as they might be removed in the future.
+script). A couple of tentative macros, were provided by \babel{}
+($\ge$3.9g) with a partial solution. These macros are now deprecated
+-- use |\babelfont|.
\begin{itemize}
\item |\babelFSstore|\marg{babel-language} sets the current three
basic families (rm, sf, tt) as the default for the language
- given. In most cases, this macro will be enough.
+ given.
\item |\babelFSdefault|\marg{babel-language}\marg{fontspec-features}
patches |\fontspec| so that the given features are always passed as
- the optional argument or added to it (not an ideal solution). Use it
- only if you select some fonts in the document with |\fontspec|.
+ the optional argument or added to it (not an ideal solution).
\end{itemize}
So, for example:
\begin{verbatim}
\setmainfont[Language=Turkish]{Minion Pro}
-\setsansfont[Language=Turkish]{Myriad Pro}
\babelFSstore{turkish}
\setmainfont{Minion Pro}
-\setsansfont{Myriad Pro}
\babelFSfeatures{turkish}{Language=Turkish}
\end{verbatim}
-Note you can set any feature required for the language -- not only
-|Language|, but also |Script| and even raw features. This makes those
-macros a bit more verbose, but also more powerful.
-
-\textbf{Bidi writing} is taking its \textit{first steps}. Here is a simple example:
-\begin{verbatim}
-\documentclass{article}
-
-\usepackage[english]{babel}
-\babelprovide{arabic} % declare a new empty language
-
-\usepackage{fontenc}
-\setmainfont[Script=Arabic,Language=Arabic]{Traditional Arabic}
-\babelFSstore[Arabic]{arabic}
-\begin{document}
-English \foreignlanguage{arabic}{Arabic} English
-\end{document}
-\end{verbatim}
+\textbf{Bidi writing} is taking its \textit{first steps}.
\textit{First steps} means exactly that. For example, in \luatex{} any
Arabic text must be marked up explicitly in L mode. On the other hand,
\xetex{} poses quite different challenges. Document layout (lists,
-footnotes, etc.) is not touched at all. The bidi mechanism is
-activated when an R script is passed as the new optional argument of
-|\babelFSstore|.
+footnotes, etc.) is not touched at all.
See the code section for |\foreignlanguage*| (a new starred version of
|\foreignlanguage|).
-\New{3.14} \textbf{With luatex only} there is the possibility to
-switch the direction without explicit markup (currently only L text
-inside R text). The following example shows how to do it:
-\begingroup
-% If you are looking at the code to see how it has been written, you
-% will be disappointed :-). The following example is built ad hoc to
-% emulate the final result to avoid dependencies, and therefore it's
-% not "real" code.
-\setmonofont[Scale=.87,Script=Arabic]{DejaVu Sans Mono}
-\catcode`@=13
-\def@#1{\ifcase#1\relax
- \egroup
- \or
- \bgroup\textdir TLT
- \else
- \bgroup\textdir TRT \pardir TRT
- \fi}
-\begin{verbatim}
-\documentclass{article}
-
-\usepackage[nil, _bidi=basic-r_]{babel}
-
-_\babelprovide[import=ar, hyphenrules=+, main]{arabic}_
-
-\setmainfont[Script=Arabic, Language=Arabic]{FreeSerif}
-\babelFSstore[Arabic]{arabic}
-
-\begin{document}
-
-@9وقد عرفت شبه جزيرة العرب طيلة العصر الهيليني )الاغريقي(
-بـ @1Arabia@0 أو @1Aravia@0 )بالاغريقية @1Αραβία@0(، استخدم
-الرومان ثلاث بادئات بـ@1“Arabia”@0 على ثلاث مناطق من شبه الجزيرة
-العربية، إلا أنها حقيقةً كانت أكبر مما تعرف عليه اليوم.
-
-@0\end{document}
-\end{verbatim}
-\endgroup
-
-The text comes from the Arabic Wikipedia (article about
-Arabia). Copy-pasting some text from the Wikipedia is a good way to
-test this feature, which will be improved in the future.
-
-This is experimental in the sense the internal implementation has
-still to be cleaned up, but its behaviour and the user interface
-will not change (except, of course, bugs fixes).
-
\xetex{} relies on the font to properly handle these unmarked changes,
so it is not under the control of \TeX.
@@ -1768,18 +2583,6 @@ it's not based on \babel{} but on \texttt{etex.src}. Until 3.9p it
just didn't work, but thanks to the new code it works by reloading the
data in the \babel{} way, i.e., with \texttt{language.dat}.}
-Unfortunately, the new model is intrinsically incompatible with the
-previous one, which means you can experience some problems with
-\textsf{polyglossia}. If using the latter, you must load the patterns
-with \babel{} as shown in the following example:
-\begin{verbatim}
-\usepackage[base,french,dutch,spanish,english]{babel}
-\usepackage{polyglossia}
-\setmainlanguage{french}
-\setotherlanguages{dutch,spanish,english}
-\end{verbatim}
-Be aware this is, very likely, a temporary solution.
-
\subsection{Format}
In that file the person who maintains a \TeX\ environment has to record
@@ -2381,10 +3184,10 @@ set for Turkish: % :-( Seem to be a bug in listings. Fixed with &&.
\StartBabelCommands{turkish}{}[unicode, fontenc=TU EU1 EU2, charset=utf8]
\SetCase
- {\uccode`i=`&İ&\relax
- \uccode`&ı&=`I\relax}
- {\lccode`&İ&=`i\relax
- \lccode`I=`&ı&\relax}
+ {\uccode`i=`İ\relax
+ \uccode`ı=`I\relax}
+ {\lccode`İ=`i\relax
+ \lccode`I=`ı\relax}
\StartBabelCommands{turkish}{}
\SetCase
@@ -2616,8 +3419,8 @@ help from Bernd Raichle, for which I am grateful.
% little bit of literate programming.
%
% \begin{macrocode}
-%<<version=3.14>>
-%<<date=2017/10/04>>
+%<<version=3.15>>
+%<<date=2017/11/03>>
% \end{macrocode}
%
% \section{Tools}
@@ -2641,6 +3444,8 @@ help from Bernd Raichle, for which I am grateful.
%
% \changes{babel~3.9i}{2014/02/16}{\cs{@for} didn't work with
% Plain. Added \cs{bbl@loop}}
+% \changes{babel~3.15}{2017/10/30}{New convenience macros
+% \cs{bbl@xin@} and \cs{bbl@cs}}
%
% \begin{macrocode}
%<<*Basic macros>>
@@ -2649,7 +3454,9 @@ help from Bernd Raichle, for which I am grateful.
\bbl@ifunset{\bbl@stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl@xin@{\@expandtwoargs\in@}
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl@cs#1{\csname bbl@#1\endcsname}
\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -2840,8 +3647,7 @@ help from Bernd Raichle, for which I am grateful.
% \end{macrocode}
% \end{macro}
%
-%
-% Two more tools. |\bbl@samestring| first expand its arguments and
+% Two further tools. |\bbl@samestring| first expand its arguments and
% then compare their expansion (sanitized, so that the catcodes do not
% matter). |\bbl@engine| takes the following values: 0 is pdf\TeX, 1
% is \luatex, and 2 is \xetex. You may use the latter it in your
@@ -3070,6 +3876,8 @@ help from Bernd Raichle, for which I am grateful.
\bbl@languages
\fi
\@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
\RequirePackage{luatexbase}%
\directlua{
require('babel-bidi.lua')
@@ -3206,7 +4014,7 @@ help from Bernd Raichle, for which I am grateful.
% \begin{macrocode}
\let\bbl@language@opts\@empty
\DeclareOption*{%
- \@expandtwoargs\in@{\string=}{\CurrentOption}%
+ \bbl@xin@{\string=}{\CurrentOption}%
\ifin@
\expandafter\bbl@tempa\CurrentOption\bbl@tempa
\else
@@ -3254,7 +4062,7 @@ help from Bernd Raichle, for which I am grateful.
%
% \begin{macrocode}
\def\bbl@ifshorthand#1{%
- \@expandtwoargs\in@{\string#1}{\bbl@opt@shorthands}%
+ \bbl@xin@{\string#1}{\bbl@opt@shorthands}%
\ifin@
\expandafter\@firstoftwo
\else
@@ -3482,7 +4290,7 @@ help from Bernd Raichle, for which I am grateful.
\edef\bbl@tempa{\@classoptionslist,\bbl@language@opts}
\let\bbl@tempc\@empty
\bbl@for\bbl@tempb\bbl@tempa{%
- \@expandtwoargs\in@{,\bbl@tempb,}{,\bbl@loaded,}%
+ \bbl@xin@{,\bbl@tempb,}{,\bbl@loaded,}%
\ifin@\edef\bbl@tempc{\bbl@tempb}\fi}
\def\bbl@tempa#1,#2\@nnil{\def\bbl@tempb{#1}}
\expandafter\bbl@tempa\bbl@loaded,\@nnil
@@ -4949,7 +5757,7 @@ help from Bernd Raichle, for which I am grateful.
% already selected attributes.
%
% \begin{macrocode}
- \@expandtwoargs\in@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}%
+ \bbl@xin@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}%
\fi
% \end{macrocode}
%
@@ -5008,7 +5816,7 @@ help from Bernd Raichle, for which I am grateful.
%
% \begin{macrocode}
\def\bbl@declare@ttribute#1#2#3{%
- \@expandtwoargs\in@{,#2,}{,\BabelModifiers,}%
+ \bbl@xin@{,#2,}{,\BabelModifiers,}%
\ifin@
\AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}%
\fi
@@ -5045,7 +5853,7 @@ help from Bernd Raichle, for which I am grateful.
% The we need to check the list of known attributes.
%
% \begin{macrocode}
- \@expandtwoargs\in@{,#1-#2,}{,\bbl@known@attribs,}%
+ \bbl@xin@{,#1-#2,}{,\bbl@known@attribs,}%
\fi
% \end{macrocode}
%
@@ -5573,8 +6381,7 @@ help from Bernd Raichle, for which I am grateful.
\expandafter
\bbl@toglobal\csname####1\string##1\endcsname}}}%
\def\bbl@sctest{%
- \@expandtwoargs
- \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
+ \bbl@xin@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
\fi
\ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults
\else\ifx\bbl@opt@strings\relax % ie, strings=encoded
@@ -5619,14 +6426,14 @@ help from Bernd Raichle, for which I am grateful.
% \begin{macrocode}
\def\bbl@forlang#1#2{%
\bbl@for#1\bbl@L{%
- \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}%
+ \bbl@xin@{,#1,}{,\BabelLanguages,}%
\ifin@#2\relax\fi}}
\def\bbl@scswitch{%
\bbl@forlang\bbl@tempa{%
\ifx\bbl@G\@empty\else
\ifx\SetString\@gobbletwo\else
\edef\bbl@GL{\bbl@G\bbl@tempa}%
- \@expandtwoargs\in@{,\bbl@GL,}{,\bbl@screset,}%
+ \bbl@xin@{,\bbl@GL,}{,\bbl@screset,}%
\ifin@\else
\global\expandafter\let\csname\bbl@GL\endcsname\@undefined
\xdef\bbl@screset{\bbl@screset,\bbl@GL}%
@@ -5826,7 +6633,7 @@ help from Bernd Raichle, for which I am grateful.
% \begin{macrocode}
\AtEndOfPackage{%
\ifx\bbl@opt@hyphenmap\@undefined
- \@expandtwoargs\in@{,}{\bbl@language@opts}%
+ \bbl@xin@{,}{\bbl@language@opts}%
\chardef\bbl@opt@hyphenmap\ifin@4\else\@ne\fi
\fi}
% \end{macrocode}
@@ -6360,6 +7167,8 @@ help from Bernd Raichle, for which I am grateful.
% \changes{3.10}{2017/05/19}{Added \cs{babelprovide}}
% \changes{3.13}{2017/08/30}{Added \cs{import}, which also reads
% dates. Some refactoring in the ini reader.}
+% \changes{3.15}{2017/10/30}{New keys script, language}
+%
%
% \begin{macrocode}
\newcommand\babelprovide[2][]{%
@@ -6368,6 +7177,9 @@ help from Bernd Raichle, for which I am grateful.
\let\bbl@KVP@captions\@nil
\let\bbl@KVP@import\@nil
\let\bbl@KVP@main\@nil
+ \let\bbl@KVP@script\@nil
+ \let\bbl@KVP@language\@nil
+ \let\bbl@KVP@dir\@nil
\let\bbl@KVP@hyphenrules\@nil
\bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling
\ifx\bbl@KVP@captions\@nil
@@ -6384,6 +7196,12 @@ help from Bernd Raichle, for which I am grateful.
{Use this macro as documented}}%
{\bbl@provide@renew{#2}}}%
\bbl@exp{\\\babelensure[exclude=\\\today]{#2}}%
+ \ifx\bbl@KVP@script\@nil\else
+ \bbl@csarg\edef{sname@#2}{\bbl@KVP@script}%
+ \fi
+ \ifx\bbl@KVP@language\@nil\else
+ \bbl@csarg\edef{lname@#2}{\bbl@KVP@language}%
+ \fi
\let\languagename\bbl@savelangname}
% \end{macrocode}
%
@@ -6468,14 +7286,14 @@ help from Bernd Raichle, for which I am grateful.
\bbl@exp{% and hyphenrules is not empty
\\\bbl@ifblank{\@nameuse{bbl@hyphr@#1}}%
{}%
- {\\\adddialect\<l@#1>\<l@\@nameuse{bbl@hyphr@\languagename}>}}%
+ {\let\\\bbl@tempa\<l@\@nameuse{bbl@hyphr@\languagename}>}}%
\fi
- \bbl@ifunset{l@#1}% no hyphenrules found - fallback
- {\bbl@exp{\\\adddialect\<l@#1>\language}}%
- {}%
- \else
- \bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}% found in opt list
- \fi}
+ \fi
+ \bbl@ifunset{bbl@tempa}% ie, relax or undefined
+ {\bbl@ifunset{l@#1}% no hyphenrules found - fallback
+ {\bbl@exp{\\\adddialect\<l@#1>\language}}%
+ {}}% so, l@<lang> is ok - nothing to do
+ {\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}}% found in opt list or ini
% \end{macrocode}
%
% The reader of |ini| files. There are 3 possible cases: a section name
@@ -6836,7 +7654,7 @@ help from Bernd Raichle, for which I am grateful.
% become expanded at the wrong moment.
%
% \begin{macrocode}
-\@expandtwoargs\in@{R}\bbl@opt@safe
+\bbl@xin@{R}\bbl@opt@safe
\ifin@
\bbl@redefinerobust\ref#1{%
\@safe@activestrue\org@ref{#1}\@safe@activesfalse}
@@ -6860,7 +7678,7 @@ help from Bernd Raichle, for which I am grateful.
% only be deactivated in the second argument.
%
% \begin{macrocode}
-\@expandtwoargs\in@{B}\bbl@opt@safe
+\bbl@xin@{B}\bbl@opt@safe
\ifin@
\bbl@redefine\@citex[#1]#2{%
\@safe@activestrue\edef\@tempa{#2}\@safe@activesfalse
@@ -7131,7 +7949,7 @@ help from Bernd Raichle, for which I am grateful.
% time.
%
% \begin{macrocode}
-\@expandtwoargs\in@{R}\bbl@opt@safe
+\bbl@xin@{R}\bbl@opt@safe
\ifin@
\AtBeginDocument{%
\@ifpackageloaded{ifthen}{%
@@ -7379,7 +8197,7 @@ help from Bernd Raichle, for which I am grateful.
\in@false
\bbl@foreach\BabelNonASCII{% is there a non-ascii enc?
\ifin@\else
- \lowercase{\@expandtwoargs\in@{,#1enc.def,}{,\@filelist,}}%
+ \lowercase{\bbl@xin@{,#1enc.def,}{,\@filelist,}}%
\fi}%
\ifin@ % if a non-ascii has been loaded
\def\ensureascii#1{{\fontencoding{OT1}\selectfont#1}}%
@@ -7390,7 +8208,7 @@ help from Bernd Raichle, for which I am grateful.
\ifx\@empty#2\else
\bbl@ifunset{T@#1}%
{}%
- {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}%
+ {\bbl@xin@{,#1,}{,\BabelNonASCII,}%
\ifin@
\DeclareTextCommand{\TeX}{#1}{\ensureascii{\org@TeX}}%
\DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org@LaTeX}}%
@@ -7399,7 +8217,7 @@ help from Bernd Raichle, for which I am grateful.
\fi}%
\fi}%
\bbl@foreach\@filelist{\bbl@tempb#1\@@}% TODO - \@@ de mas??
- \@expandtwoargs\in@{,\cf@encoding,}{,\BabelNonASCII,}%
+ \bbl@xin@{,\cf@encoding,}{,\BabelNonASCII,}%
\ifin@\else
\edef\ensureascii#1{{%
\noexpand\fontencoding{\cf@encoding}\noexpand\selectfont#1}}%
@@ -7508,6 +8326,11 @@ help from Bernd Raichle, for which I am grateful.
% in fact minimal.}
% \end{itemize}
%
+% \changes{3.15}{2017/10/30}{Use an attribute instead of tex language
+% (reserved for hyphenation).}
+% \changes{3.15}{2017/10/30}{Store direction in @wdir@<lang>.}
+%
+%
% \begin{macrocode}
\def\bbl@alscripts{,Arabic,Syriac,Thaana,}
\def\bbl@rscripts{%
@@ -7517,15 +8340,20 @@ help from Bernd Raichle, for which I am grateful.
Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
Old South Arabian,}%
-\def\bbl@ensuredir{%
- \@expandtwoargs
- \in@{\csname bbl@script@\languagename\endcsname}%
- {\bbl@alscripts\bbl@rscripts}%
+\def\bbl@provide@dirs#1{%
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}%
\ifin@
- \bbl@setdirs\@ne
+ \global\bbl@csarg\chardef{wdir@#1}\@ne
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts}%
+ \ifin@
+ \global\bbl@csarg\chardef{wdir@#1}\tw@ % useless in xetex
+ \fi
\else
- \bbl@setdirs\z@
+ \global\bbl@csarg\chardef{wdir@#1}\z@
\fi}
+\def\bbl@switchdir{%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \bbl@exp{\\\bbl@setdirs\bbl@cs{wdir@\languagename}}}
\def\bbl@setdirs#1{% TODO - math
\ifcase\bbl@select@type % TODO - strictly, not the right test
\bbl@pagedir{#1}%
@@ -7535,7 +8363,7 @@ help from Bernd Raichle, for which I am grateful.
\bbl@textdir{#1}}
\ifcase\bbl@engine
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
\DisableBabelHook{babel-bidi}
\def\bbl@getluadir#1{%
\directlua{
@@ -7554,13 +8382,15 @@ help from Bernd Raichle, for which I am grateful.
#2 TRT\relax
\fi
\fi}
- \def\bbl@textdir{\bbl@setdir{text}\textdir}% TODO - ?\linedir
+ \def\bbl@textdir#1{%
+ \bbl@setdir{text}\textdir{#1}% TODO - ?\linedir
+ \setattribute\bbl@attr@dir{#1}}
\def\bbl@pardir{\bbl@setdir{par}\pardir}
\def\bbl@bodydir{\bbl@setdir{body}\bodydir}
\def\bbl@pagedir{\bbl@setdir{page}\pagedir}
\def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%%
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
\DisableBabelHook{babel-bidi}
\newcount\bbl@dirlevel
\chardef\bbl@thetextdir\z@
@@ -7889,9 +8719,12 @@ help from Bernd Raichle, for which I am grateful.
% the `-'-sign and finally the reference to the stack.
%
% \begin{macrocode}
+\let\bbl@ifrestoring\@secondoftwo
\def\bbl@pop@language{%
\expandafter\bbl@pop@lang\bbl@language@stack-\bbl@language@stack
- \expandafter\bbl@set@language\expandafter{\languagename}}
+ \let\bbl@ifrestoring\@firstoftwo
+ \expandafter\bbl@set@language\expandafter{\languagename}%
+ \let\bbl@ifrestoring\@secondoftwo}
% \end{macrocode}
%
% Once the name of the previous language is retrieved from the stack,
@@ -8021,6 +8854,7 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.9h}{2013/11/29}{Use \cs{def} instead of
% \cs{renewcommand} for \cs{BabelLower}}
% \changes{babel~3.9i}{2014/03/04}{Added `afterreset' hook}
+% \changes{3.15}{2017/10/30}{Remove spaces inside captions and date.}
%
% \begin{macrocode}
\def\bbl@switch#1{%
@@ -8032,8 +8866,15 @@ help from Bernd Raichle, for which I am grateful.
\bbl@usehooks{afterreset}{}%
\languageshorthands{none}%
\ifcase\bbl@select@type
- \csname captions#1\endcsname\relax
- \csname date#1\endcsname\relax
+ \ifhmode
+ \hskip\z@skip % trick to ignore spaces
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+ \else
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \fi
\fi
\bbl@usehooks{beforeextras}{}%
\csname extras#1\endcsname\relax
@@ -8259,7 +9100,7 @@ help from Bernd Raichle, for which I am grateful.
\@expandtwoargs\bbl@usehooks{patterns}{{#1}{\bbl@tempa}}%
\@ifundefined{bbl@hyphenation@}{}{% Can be \relax!
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl@hyphlist}%
+ \bbl@xin@{,\number\language,}{,\bbl@hyphlist}%
\ifin@\else
\@expandtwoargs\bbl@usehooks{hyphenation}{{#1}{\bbl@tempa}}%
\hyphenation{%
@@ -8285,20 +9126,18 @@ help from Bernd Raichle, for which I am grateful.
% \changes{babel~3.8j}{2008/03/16}{Also set the hyphenmin parameters to
% the correct value (PR3997)}
% \changes{babel~3.8l}{2008/07/06}{Use \cs{bbl@patterns}}
+% \changes{3.15}{2017/10/30}{Don't set language name. Use temp macro.}
%
% \begin{macrocode}
\def\hyphenrules#1{%
- \edef\languagename{#1}%
- \bbl@fixname\languagename
- \bbl@iflanguage\languagename{%
- \expandafter\bbl@patterns\expandafter{\languagename}%
+ \edef\bbl@tempf{#1}%
+ \bbl@fixname\bbl@tempf
+ \bbl@iflanguage\bbl@tempf{%
+ \expandafter\bbl@patterns\expandafter{\bbl@tempf}%
\languageshorthands{none}%
- \expandafter\ifx\csname\languagename hyphenmins\endcsname\relax
- \set@hyphenmins\tw@\thr@@\relax
- \else
- \expandafter\expandafter\expandafter\set@hyphenmins
- \csname\languagename hyphenmins\endcsname\relax
- \fi}}
+ \bbl@ifunset{\bbl@tempf hyphenmins}%
+ {\set@hyphenmins\tw@\thr@@\relax}%
+ {\bbl@exp{\\\set@hyphenmins\@nameuse{\bbl@tempf hyphenmins}}}}}
\let\endhyphenrules\@empty
% \end{macrocode}
%
@@ -8954,48 +9793,203 @@ help from Bernd Raichle, for which I am grateful.
% Here the code for ini\TeX\ ends.
% \end{macro}
%
-% \section{Tentative font handling with fontspec}
+% \section{Font handling with fontspec}
%
-% A general solution is far from trivial:
-% \begin{itemize}
-% \item |\addfontfeature| only sets it for the current family and it's
-% not very efficient, and
-% \item |\defaultfontfeatures| requires to redefine the font (and the
-% options are not ``orthogonal'').
-% \end{itemize}
+% \changes{3.15}{2017/10/30}{New way to select fonts, with \cs{babelfont}}
%
% Add the bidi handler just before luaoftload, which is loaded by default
-% by LaTeX. Just in case, consider the possibility it has not been loaded.
+% by LaTeX. Just in case, consider the possibility it has not been
+% loaded. First, a couple of definitions related to bidi [misplaced].
%
% \begin{macrocode}
%<<*More package options>>
-\DeclareOption{bidi=basic-r}{}
+\DeclareOption{bidi=basic-r}%
+ {\newattribute\bbl@attr@dir
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
+\DeclareOption{bidi=default}%
+ {\let\bbl@beforeforeign\leavevmode
+ \ifcase\bbl@engine\or
+ \newattribute\bbl@attr@dir
+ \fi
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifcase\bbl@engine\or\or
+ \bbl@xebidipar
+ \fi}}
%<</More package options>>
-%<<*Font selection>>
+% \end{macrocode}
+%
+% With explicit languages, we could define the font at once, but we
+% don't. Just wait and see if the language is actually activated.
+%
+% \begin{macrocode}
+%<<*Font selection>>
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl@tempa{#1}%
+ \def\bbl@tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl@bblfont}
+\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname
+ \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \expandafter\bbl@ifblank\expandafter{\bbl@tempa}%
+ {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@
+ \bbl@exp{%
+ \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>%
+ \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>%
+ \<\bbl@tempb default>\<\bbl@tempb family>}}%
+ {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt
+ \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}%
+% \end{macrocode}
+%
+% If the family in the previous command does not exist, it must be
+% defined. Here is how:
+%
+% \begin{macrocode}
+\def\bbl@providefam#1{%
+ \bbl@exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl@add@list\\\bbl@font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not@math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+% \end{macrocode}
+%
+% The following macro is activated when the hook |babel-fontspec| is
+% enabled.
+%
+% \begin{macrocode}
+\def\bbl@switchfont{%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}%
+ \bbl@foreach\bbl@font@fams{%
+ \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script?
+ {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl@exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl@exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl@tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl@tempa{%
+ \bbl@warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl@foreach\bbl@font@fams{% don't gather with prev for
+ \bbl@ifunset{bbl@##1dflt@\languagename}%
+ {\bbl@cs{famrst@##1}%
+ \global\bbl@csarg\let{famrst@##1}\relax}%
+ {\bbl@exp{% order is relevant
+ \\\bbl@add\\\originalTeX{%
+ \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl@ifrestoring{}{\bbl@tempa}}%
+% \end{macrocode}
+%
+% Now the macros defining the font with \textsf{fontspec}.
+%
+% When there are repeated keys in \textsf{fontspec}, the last value
+% wins. So, we just place the ini settings at the beginning, and user
+% settings will take precedence.
+%
+% \begin{macrocode}
+\def\bbl@font@set#1#2#3{%
+ \bbl@xin@{<>}{#1}%
+ \ifin@
+ \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl@exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang}
+ \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}}
+\def\bbl@fontspec@set#1#2#3{%
+ \bbl@exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl@cs{lsys@\languagename},#2}}{#3}%
+ \bbl@toglobal#1}%
+% \end{macrocode}
+%
+% Language and Script values to be used when defining a font are set
+% with the following macros.
+%
+% \begin{macrocode}
+\def\bbl@provide@lsys#1{%
+ \bbl@ifunset{bbl@lname@#1}%
+ {\bbl@ini@ids{#1}}%
+ {}%
+ \bbl@csarg\let{lsys@#1}\@empty
+ \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}%
+ \bbl@ifunset{bbl@sotf#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}%
+ \bbl@ifunset{bbl@lname@#1}{}%
+ {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}%
+ \bbl@csarg\bbl@toglobal{lsys@#1}}%
+ % \bbl@exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl@cs{sname@#1}}%
+ % {\\\newfontscript{\bbl@cs{sname@#1}}{\bbl@cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl@cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl@cs{lname@#1}}{\bbl@cs{lotf@#1}}}}}
+% \end{macrocode}
+%
+% The following |ini| reader ignores everything but the
+% |identification| section. It is called when a font is defined (ie,
+% when the language is first selected) to know which script/language
+% must be enabled. This means we must make sure a few characters are
+% not active. The |ini| is not read directly, but with a proxy |tex|
+% file named as the language.
+%
+% \begin{macrocode}
+\def\bbl@ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl@add\bbl@secpost@identification{%
+ \def\bbl@iniline########1\bbl@iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl@read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+% \end{macrocode}
+%
+% font@rst and famrst are only used when there is no global settings,
+% to save and restore de previous families. Not really necessary, but
+% done for optimization.
+%
+% \begin{macrocode}
+\def\bbl@font@rst#1#2#3#4{%
+ \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}}
+% \end{macrocode}
+%
+% The default font families. They are eurocentric, but the list can be
+% expanded easily with |\babelfont|.
+%
+% \begin{macrocode}
+\def\bbl@font@fams{rm,sf,tt}
+% \end{macrocode}
+%
+% The old tentative way. Short and preverved for compatibility, but
+% deprecated. Note there is no direct alternative for
+% |\babelFSfeatures|. The reason in explained in the user guide, but
+% essentially -- that was not the way to go :-).
+%
+% \begin{macrocode}
\newcommand\babelFSstore[2][]{%
\bbl@ifblank{#1}%
- {\bbl@csarg\def{script@#2}{Latin}}%
- {\bbl@csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts\bbl@rscripts}%
- \ifin@
+ {\bbl@csarg\def{sname@#2}{Latin}}%
+ {\bbl@csarg\def{sname@#2}{#1}}%
+ \bbl@provide@dirs{#2}%
+ \bbl@csarg\ifnum{wdir@#2}>\z@
\let\bbl@beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl@engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl@xebidipar
- \fi
- \else
- \ifcase\bbl@engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl@foreach{#2}{%
\bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault
@@ -9103,6 +10097,9 @@ help from Bernd Raichle, for which I am grateful.
\let\xebbl@stop\relax}
\AddBabelHook{xetex}{loadkernel}{%
<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
<@Font selection@>
%</xetex>
% \end{macrocode}
@@ -9401,7 +10398,7 @@ help from Bernd Raichle, for which I am grateful.
\csname bbl@hyphendata@\the\language\endcsname}}{}%
\@ifundefined{bbl@patterns@}{}{%
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl@pttnlist}%
+ \bbl@xin@{,\number\language,}{,\bbl@pttnlist}%
\ifin@\else
\ifx\bbl@patterns@\@empty\else
\directlua{ Babel.addpatterns(
@@ -9472,6 +10469,9 @@ help from Bernd Raichle, for which I am grateful.
% \begin{macrocode}
\AddBabelHook{luatex}{loadkernel}{%
<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
<@Font selection@>
%</luatex>
% \end{macrocode}
@@ -9481,8 +10481,8 @@ help from Bernd Raichle, for which I am grateful.
% \changes{3.14}{2017/09/30}{LuaTeX - support for R/AL texts - basic-r}
%
% \textbf{Work in progress}. The file \textsf{babel-bidi.lua}
-% currently only contains data. It's a large file and it's not shown
-% here. See the generated file.
+% currently only contains data. It's a large and boring file and it's
+% not shown here. See the generated file.
%\iffalse
% \begin{macrocode}
%<*bidi>
@@ -15614,8 +16614,6 @@ Babel.characters={
%<*basic-r>
Babel = Babel or {}
-Babel.langdirs = {}
-
require('babel-bidi.lua')
local characters = Babel.characters
@@ -15634,11 +16632,10 @@ local function dir_mark(head, from, to, outer)
end
function Babel.pre_otfload(head)
- local first_n, last_n = nil, nil -- first and last char with nums
- local last_es = nil -- an auxiliary 'last' used with nums
- local first_d, last_d = nil, nil -- first and last char in L/R block
- local dir = nil
- local dir_real = nil
+ local first_n, last_n -- first and last char with nums
+ local last_es -- an auxiliary 'last' used with nums
+ local first_d, last_d -- first and last char in L/R block
+ local dir, dir_real
% \end{macrocode}
%
% Next also depends on script/lang (<al>/<r>). To be set by
@@ -15655,7 +16652,7 @@ function Babel.pre_otfload(head)
local new_dir = false
local first_dir = false
- local last_lr = nil
+ local last_lr
local type_n = ''
@@ -15687,7 +16684,20 @@ function Babel.pre_otfload(head)
%
% \begin{macrocode}
if new_dir then
- strong = Babel.langdirs[item.lang] or 'l'
+ attr_dir = 0
+ for at in node.traverse(item.attr) do
+ if at.number == luatexbase.registernumber'bbl@attr@dir' then
+ attr_dir = at.value
+ end
+ end
+ texio.write_nl(attr_dir)
+ if attr_dir == 1 then
+ strong = 'r'
+ elseif attr_dir == 2 then
+ strong = 'al'
+ else
+ strong = 'l'
+ end
strong_lr = (strong == 'l') and 'l' or 'r'
outer = strong_lr
new_dir = false
@@ -15804,7 +16814,6 @@ function Babel.pre_otfload(head)
ch.char = characters[ch.char].m or ch.char
end
end
- --last_lr = nil
end
end
% \end{macrocode}
diff --git a/Master/texmf-dist/source/latex/babel/babel.ins b/Master/texmf-dist/source/latex/babel/babel.ins
index ce2a8c84f8c..21148e69505 100644
--- a/Master/texmf-dist/source/latex/babel/babel.ins
+++ b/Master/texmf-dist/source/latex/babel/babel.ins
@@ -26,7 +26,7 @@
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension .ins) which are part of the distribution.
%%
-\def\filedate{2017/10/04}
+\def\filedate{2017/11/03}
\def\batchfile{babel.ins}
\input docstrip.tex
@@ -127,7 +127,7 @@
\savingtrue
\generate{\usepreamble\empty
\usepostamble\empty
- \file{babel.aux}{\from{babel.dtx}{dummy}}}
+ \file{babel.log}{\from{babel.dtx}{dummy}}}
\savingfalse
\generate{\file{babel.sty}{\from{babel.dtx}{package}}
diff --git a/Master/texmf-dist/source/latex/babel/bbcompat.dtx b/Master/texmf-dist/source/latex/babel/bbcompat.dtx
index 35a7fb53a11..55e0ae6e0e3 100644
--- a/Master/texmf-dist/source/latex/babel/bbcompat.dtx
+++ b/Master/texmf-dist/source/latex/babel/bbcompat.dtx
@@ -30,7 +30,7 @@
%
% \iffalse
%<*dtx>
-\ProvidesFile{bbcompat.dtx}[2017/10/04 v3.14]
+\ProvidesFile{bbcompat.dtx}[2017/11/03 v3.15]
%</dtx>
%
%% File 'bbcompat.dtx'
diff --git a/Master/texmf-dist/source/latex/babel/locale.zip b/Master/texmf-dist/source/latex/babel/locale.zip
index 8d734f53a6f..b1a5b9dbfe2 100644
--- a/Master/texmf-dist/source/latex/babel/locale.zip
+++ b/Master/texmf-dist/source/latex/babel/locale.zip
Binary files differ
diff --git a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
index 2f80775609e..fab6721456a 100644
--- a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
+++ b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
@@ -33,8 +33,6 @@
--
Babel = Babel or {}
-Babel.langdirs = {}
-
require('babel-bidi.lua')
local characters = Babel.characters
@@ -53,11 +51,10 @@ local function dir_mark(head, from, to, outer)
end
function Babel.pre_otfload(head)
- local first_n, last_n = nil, nil -- first and last char with nums
- local last_es = nil -- an auxiliary 'last' used with nums
- local first_d, last_d = nil, nil -- first and last char in L/R block
- local dir = nil
- local dir_real = nil
+ local first_n, last_n -- first and last char with nums
+ local last_es -- an auxiliary 'last' used with nums
+ local first_d, last_d -- first and last char in L/R block
+ local dir, dir_real
local strong = ('TRT' == tex.pardir) and 'r' or 'l'
local strong_lr = (strong == 'l') and 'l' or 'r'
local outer = strong
@@ -65,7 +62,7 @@ function Babel.pre_otfload(head)
local new_dir = false
local first_dir = false
- local last_lr = nil
+ local last_lr
local type_n = ''
@@ -88,7 +85,20 @@ function Babel.pre_otfload(head)
end
dir = dir or 'l'
if new_dir then
- strong = Babel.langdirs[item.lang] or 'l'
+ attr_dir = 0
+ for at in node.traverse(item.attr) do
+ if at.number == luatexbase.registernumber'bbl@attr@dir' then
+ attr_dir = at.value
+ end
+ end
+ texio.write_nl(attr_dir)
+ if attr_dir == 1 then
+ strong = 'r'
+ elseif attr_dir == 2 then
+ strong = 'al'
+ else
+ strong = 'l'
+ end
strong_lr = (strong == 'l') and 'l' or 'r'
outer = strong_lr
new_dir = false
@@ -151,7 +161,6 @@ function Babel.pre_otfload(head)
ch.char = characters[ch.char].m or ch.char
end
end
- --last_lr = nil
end
end
if dir == 'l' or dir == 'r' then
diff --git a/Master/texmf-dist/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def
index 6db9b31282e..cd6e92b3584 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.def
+++ b/Master/texmf-dist/tex/generic/babel/babel.def
@@ -40,7 +40,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{babel.def}[2017/10/04 3.14 Babel common definitions]
+\ProvidesFile{babel.def}[2017/11/03 3.15 Babel common definitions]
\ifx\AtBeginDocument\@undefined
\input plain.def\relax
\fi
@@ -83,7 +83,9 @@
\bbl@ifunset{\bbl@stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl@xin@{\@expandtwoargs\in@}
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl@cs#1{\csname bbl@#1\endcsname}
\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -688,7 +690,7 @@
\ifx\bbl@known@attribs\@undefined
\in@false
\else
- \@expandtwoargs\in@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}%
+ \bbl@xin@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}%
\fi
\ifin@
\bbl@warning{%
@@ -708,7 +710,7 @@
{The attribute #2 is unknown for language #1.}%
{Your command will be ignored, type <return> to proceed}}
\def\bbl@declare@ttribute#1#2#3{%
- \@expandtwoargs\in@{,#2,}{,\BabelModifiers,}%
+ \bbl@xin@{,#2,}{,\BabelModifiers,}%
\ifin@
\AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}%
\fi
@@ -718,7 +720,7 @@
\ifx\bbl@known@attribs\@undefined
\in@false
\else
- \@expandtwoargs\in@{,#1-#2,}{,\bbl@known@attribs,}%
+ \bbl@xin@{,#1-#2,}{,\bbl@known@attribs,}%
\fi
\ifin@
\bbl@afterelse#3%
@@ -952,8 +954,7 @@
\expandafter
\bbl@toglobal\csname####1\string##1\endcsname}}}%
\def\bbl@sctest{%
- \@expandtwoargs
- \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
+ \bbl@xin@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}%
\fi
\ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults
\else\ifx\bbl@opt@strings\relax % ie, strings=encoded
@@ -982,14 +983,14 @@
\fi}
\def\bbl@forlang#1#2{%
\bbl@for#1\bbl@L{%
- \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}%
+ \bbl@xin@{,#1,}{,\BabelLanguages,}%
\ifin@#2\relax\fi}}
\def\bbl@scswitch{%
\bbl@forlang\bbl@tempa{%
\ifx\bbl@G\@empty\else
\ifx\SetString\@gobbletwo\else
\edef\bbl@GL{\bbl@G\bbl@tempa}%
- \@expandtwoargs\in@{,\bbl@GL,}{,\bbl@screset,}%
+ \bbl@xin@{,\bbl@GL,}{,\bbl@screset,}%
\ifin@\else
\global\expandafter\let\csname\bbl@GL\endcsname\@undefined
\xdef\bbl@screset{\bbl@screset,\bbl@GL}%
@@ -1065,7 +1066,7 @@
\bbl@tempa}
\AtEndOfPackage{%
\ifx\bbl@opt@hyphenmap\@undefined
- \@expandtwoargs\in@{,}{\bbl@language@opts}%
+ \bbl@xin@{,}{\bbl@language@opts}%
\chardef\bbl@opt@hyphenmap\ifin@4\else\@ne\fi
\fi}
\def\set@low@box#1{\setbox\tw@\hbox{,}\setbox\z@\hbox{#1}%
@@ -1259,6 +1260,9 @@
\let\bbl@KVP@captions\@nil
\let\bbl@KVP@import\@nil
\let\bbl@KVP@main\@nil
+ \let\bbl@KVP@script\@nil
+ \let\bbl@KVP@language\@nil
+ \let\bbl@KVP@dir\@nil
\let\bbl@KVP@hyphenrules\@nil
\bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling
\ifx\bbl@KVP@captions\@nil
@@ -1275,6 +1279,12 @@
{Use this macro as documented}}%
{\bbl@provide@renew{#2}}}%
\bbl@exp{\\\babelensure[exclude=\\\today]{#2}}%
+ \ifx\bbl@KVP@script\@nil\else
+ \bbl@csarg\edef{sname@#2}{\bbl@KVP@script}%
+ \fi
+ \ifx\bbl@KVP@language\@nil\else
+ \bbl@csarg\edef{lname@#2}{\bbl@KVP@language}%
+ \fi
\let\languagename\bbl@savelangname}
\def\bbl@provide@new#1{%
\@namedef{date#1}{}% marks lang exists - required by \StartBabelCommands
@@ -1346,14 +1356,14 @@
\bbl@exp{% and hyphenrules is not empty
\\\bbl@ifblank{\@nameuse{bbl@hyphr@#1}}%
{}%
- {\\\adddialect\<l@#1>\<l@\@nameuse{bbl@hyphr@\languagename}>}}%
+ {\let\\\bbl@tempa\<l@\@nameuse{bbl@hyphr@\languagename}>}}%
\fi
- \bbl@ifunset{l@#1}% no hyphenrules found - fallback
- {\bbl@exp{\\\adddialect\<l@#1>\language}}%
- {}%
- \else
- \bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}% found in opt list
- \fi}
+ \fi
+ \bbl@ifunset{bbl@tempa}% ie, relax or undefined
+ {\bbl@ifunset{l@#1}% no hyphenrules found - fallback
+ {\bbl@exp{\\\adddialect\<l@#1>\language}}%
+ {}}% so, l@<lang> is ok - nothing to do
+ {\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}}% found in opt list or ini
\def\bbl@read@ini#1{%
\openin1=babel-#1.ini
\ifeof1
@@ -1532,7 +1542,7 @@
\@tempswatrue
\fi}
\fi
-\@expandtwoargs\in@{R}\bbl@opt@safe
+\bbl@xin@{R}\bbl@opt@safe
\ifin@
\bbl@redefinerobust\ref#1{%
\@safe@activestrue\org@ref{#1}\@safe@activesfalse}
@@ -1542,7 +1552,7 @@
\let\org@ref\ref
\let\org@pageref\pageref
\fi
-\@expandtwoargs\in@{B}\bbl@opt@safe
+\bbl@xin@{B}\bbl@opt@safe
\ifin@
\bbl@redefine\@citex[#1]#2{%
\@safe@activestrue\edef\@tempa{#2}\@safe@activesfalse
@@ -1602,7 +1612,7 @@
{\@temptokena\expandafter{\bbl@tempb{#2}}}%
\bbl@exp{\\\org@markboth{\the\toks@}{\the\@temptokena}}}
\bbl@tempc
-\@expandtwoargs\in@{R}\bbl@opt@safe
+\bbl@xin@{R}\bbl@opt@safe
\ifin@
\AtBeginDocument{%
\@ifpackageloaded{ifthen}{%
@@ -1681,7 +1691,7 @@
\in@false
\bbl@foreach\BabelNonASCII{% is there a non-ascii enc?
\ifin@\else
- \lowercase{\@expandtwoargs\in@{,#1enc.def,}{,\@filelist,}}%
+ \lowercase{\bbl@xin@{,#1enc.def,}{,\@filelist,}}%
\fi}%
\ifin@ % if a non-ascii has been loaded
\def\ensureascii#1{{\fontencoding{OT1}\selectfont#1}}%
@@ -1692,7 +1702,7 @@
\ifx\@empty#2\else
\bbl@ifunset{T@#1}%
{}%
- {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}%
+ {\bbl@xin@{,#1,}{,\BabelNonASCII,}%
\ifin@
\DeclareTextCommand{\TeX}{#1}{\ensureascii{\org@TeX}}%
\DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org@LaTeX}}%
@@ -1701,7 +1711,7 @@
\fi}%
\fi}%
\bbl@foreach\@filelist{\bbl@tempb#1\@@}% TODO - \@@ de mas??
- \@expandtwoargs\in@{,\cf@encoding,}{,\BabelNonASCII,}%
+ \bbl@xin@{,\cf@encoding,}{,\BabelNonASCII,}%
\ifin@\else
\edef\ensureascii#1{{%
\noexpand\fontencoding{\cf@encoding}\noexpand\selectfont#1}}%
@@ -1738,15 +1748,20 @@
Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
Old South Arabian,}%
-\def\bbl@ensuredir{%
- \@expandtwoargs
- \in@{\csname bbl@script@\languagename\endcsname}%
- {\bbl@alscripts\bbl@rscripts}%
+\def\bbl@provide@dirs#1{%
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}%
\ifin@
- \bbl@setdirs\@ne
+ \global\bbl@csarg\chardef{wdir@#1}\@ne
+ \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts}%
+ \ifin@
+ \global\bbl@csarg\chardef{wdir@#1}\tw@ % useless in xetex
+ \fi
\else
- \bbl@setdirs\z@
+ \global\bbl@csarg\chardef{wdir@#1}\z@
\fi}
+\def\bbl@switchdir{%
+ \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}%
+ \bbl@exp{\\\bbl@setdirs\bbl@cs{wdir@\languagename}}}
\def\bbl@setdirs#1{% TODO - math
\ifcase\bbl@select@type % TODO - strictly, not the right test
\bbl@pagedir{#1}%
@@ -1756,7 +1771,7 @@
\bbl@textdir{#1}}
\ifcase\bbl@engine
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
\DisableBabelHook{babel-bidi}
\def\bbl@getluadir#1{%
\directlua{
@@ -1775,13 +1790,15 @@
#2 TRT\relax
\fi
\fi}
- \def\bbl@textdir{\bbl@setdir{text}\textdir}% TODO - ?\linedir
+ \def\bbl@textdir#1{%
+ \bbl@setdir{text}\textdir{#1}% TODO - ?\linedir
+ \setattribute\bbl@attr@dir{#1}}
\def\bbl@pardir{\bbl@setdir{par}\pardir}
\def\bbl@bodydir{\bbl@setdir{body}\bodydir}
\def\bbl@pagedir{\bbl@setdir{page}\pagedir}
\def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%%
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir}
\DisableBabelHook{babel-bidi}
\newcount\bbl@dirlevel
\chardef\bbl@thetextdir\z@
diff --git a/Master/texmf-dist/tex/generic/babel/babel.sty b/Master/texmf-dist/tex/generic/babel/babel.sty
index d1d3e3c9752..c5ce24b584f 100644
--- a/Master/texmf-dist/tex/generic/babel/babel.sty
+++ b/Master/texmf-dist/tex/generic/babel/babel.sty
@@ -32,7 +32,7 @@
%% extension |.ins|) which are part of the distribution.
%%
\NeedsTeXFormat{LaTeX2e}[2005/12/01]
-\ProvidesPackage{babel}[2017/10/04 3.14 The Babel package]
+\ProvidesPackage{babel}[2017/11/03 3.15 The Babel package]
\@ifpackagewith{babel}{debug}
{\let\bbl@debug\@firstofone}
{\let\bbl@debug\@gobble}
@@ -47,7 +47,9 @@
\bbl@ifunset{\bbl@stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl@xin@{\@expandtwoargs\in@}
\def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl@cs#1{\csname bbl@#1\endcsname}
\def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -178,6 +180,8 @@
\bbl@languages
\fi
\@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
\RequirePackage{luatexbase}%
\directlua{
require('babel-bidi.lua')
@@ -246,7 +250,20 @@
\DeclareOption{safe=none}{\let\bbl@opt@safe\@empty}
\DeclareOption{safe=bib}{\def\bbl@opt@safe{B}}
\DeclareOption{safe=ref}{\def\bbl@opt@safe{R}}
-\DeclareOption{bidi=basic-r}{}
+\DeclareOption{bidi=basic-r}%
+ {\newattribute\bbl@attr@dir
+ \let\bbl@beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
+\DeclareOption{bidi=default}%
+ {\let\bbl@beforeforeign\leavevmode
+ \ifcase\bbl@engine\or
+ \newattribute\bbl@attr@dir
+ \fi
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifcase\bbl@engine\or\or
+ \bbl@xebidipar
+ \fi}}
\let\bbl@opt@shorthands\@nnil
\let\bbl@opt@config\@nnil
\let\bbl@opt@main\@nnil
@@ -263,7 +280,7 @@
\fi}
\let\bbl@language@opts\@empty
\DeclareOption*{%
- \@expandtwoargs\in@{\string=}{\CurrentOption}%
+ \bbl@xin@{\string=}{\CurrentOption}%
\ifin@
\expandafter\bbl@tempa\CurrentOption\bbl@tempa
\else
@@ -284,7 +301,7 @@
\def\bbl@ifshorthand#1#2#3{#3}%
\else
\def\bbl@ifshorthand#1{%
- \@expandtwoargs\in@{\string#1}{\bbl@opt@shorthands}%
+ \bbl@xin@{\string#1}{\bbl@opt@shorthands}%
\ifin@
\expandafter\@firstoftwo
\else
@@ -390,7 +407,7 @@
\edef\bbl@tempa{\@classoptionslist,\bbl@language@opts}
\let\bbl@tempc\@empty
\bbl@for\bbl@tempb\bbl@tempa{%
- \@expandtwoargs\in@{,\bbl@tempb,}{,\bbl@loaded,}%
+ \bbl@xin@{,\bbl@tempb,}{,\bbl@loaded,}%
\ifin@\edef\bbl@tempc{\bbl@tempb}\fi}
\def\bbl@tempa#1,#2\@nnil{\def\bbl@tempb{#1}}
\expandafter\bbl@tempa\bbl@loaded,\@nnil
diff --git a/Master/texmf-dist/tex/generic/babel/hyphen.cfg b/Master/texmf-dist/tex/generic/babel/hyphen.cfg
index 1dc995bb4a1..2a78efdda22 100644
--- a/Master/texmf-dist/tex/generic/babel/hyphen.cfg
+++ b/Master/texmf-dist/tex/generic/babel/hyphen.cfg
@@ -36,7 +36,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{hyphen.cfg}[2017/10/04 3.14 Babel hyphens]
+\ProvidesFile{hyphen.cfg}[2017/11/03 3.15 Babel hyphens]
\xdef\bbl@format{\jobname}
\ifx\AtBeginDocument\@undefined
\def\@empty{}
@@ -67,7 +67,7 @@
\countdef\last@language=19
\def\addlanguage{\alloc@9\language\chardef\@cclvi}
\fi
-\toks8{Babel <3.14> and hyphenation patterns for }%
+\toks8{Babel <3.15> and hyphenation patterns for }%
\def\process@line#1#2 #3 #4 {%
\ifx=#1%
\process@synonym{#2}%
diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def
index 7cbba864d1a..0ffb8d44cad 100644
--- a/Master/texmf-dist/tex/generic/babel/luababel.def
+++ b/Master/texmf-dist/tex/generic/babel/luababel.def
@@ -251,7 +251,7 @@
\csname bbl@hyphendata@\the\language\endcsname}}{}%
\@ifundefined{bbl@patterns@}{}{%
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl@pttnlist}%
+ \bbl@xin@{,\number\language,}{,\bbl@pttnlist}%
\ifin@\else
\ifx\bbl@patterns@\@empty\else
\directlua{ Babel.addpatterns(
@@ -332,30 +332,116 @@
\L 00FF 0178 00FF
\endgroup
\input #1\relax}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl@tempa{#1}%
+ \def\bbl@tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl@bblfont}
+\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname
+ \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \expandafter\bbl@ifblank\expandafter{\bbl@tempa}%
+ {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@
+ \bbl@exp{%
+ \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>%
+ \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>%
+ \<\bbl@tempb default>\<\bbl@tempb family>}}%
+ {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt
+ \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}%
+\def\bbl@providefam#1{%
+ \bbl@exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl@add@list\\\bbl@font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not@math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+\def\bbl@switchfont{%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}%
+ \bbl@foreach\bbl@font@fams{%
+ \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script?
+ {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl@exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl@exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl@tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl@tempa{%
+ \bbl@warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl@foreach\bbl@font@fams{% don't gather with prev for
+ \bbl@ifunset{bbl@##1dflt@\languagename}%
+ {\bbl@cs{famrst@##1}%
+ \global\bbl@csarg\let{famrst@##1}\relax}%
+ {\bbl@exp{% order is relevant
+ \\\bbl@add\\\originalTeX{%
+ \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl@ifrestoring{}{\bbl@tempa}}%
+\def\bbl@font@set#1#2#3{%
+ \bbl@xin@{<>}{#1}%
+ \ifin@
+ \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl@exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang}
+ \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}}
+\def\bbl@fontspec@set#1#2#3{%
+ \bbl@exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl@cs{lsys@\languagename},#2}}{#3}%
+ \bbl@toglobal#1}%
+\def\bbl@provide@lsys#1{%
+ \bbl@ifunset{bbl@lname@#1}%
+ {\bbl@ini@ids{#1}}%
+ {}%
+ \bbl@csarg\let{lsys@#1}\@empty
+ \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}%
+ \bbl@ifunset{bbl@sotf#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}%
+ \bbl@ifunset{bbl@lname@#1}{}%
+ {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}%
+ \bbl@csarg\bbl@toglobal{lsys@#1}}%
+ % \bbl@exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl@cs{sname@#1}}%
+ % {\\\newfontscript{\bbl@cs{sname@#1}}{\bbl@cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl@cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl@cs{lname@#1}}{\bbl@cs{lotf@#1}}}}}
+\def\bbl@ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl@add\bbl@secpost@identification{%
+ \def\bbl@iniline########1\bbl@iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl@read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+\def\bbl@font@rst#1#2#3#4{%
+ \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}}
+\def\bbl@font@fams{rm,sf,tt}
\newcommand\babelFSstore[2][]{%
\bbl@ifblank{#1}%
- {\bbl@csarg\def{script@#2}{Latin}}%
- {\bbl@csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts\bbl@rscripts}%
- \ifin@
+ {\bbl@csarg\def{sname@#2}{Latin}}%
+ {\bbl@csarg\def{sname@#2}{#1}}%
+ \bbl@provide@dirs{#2}%
+ \bbl@csarg\ifnum{wdir@#2}>\z@
\let\bbl@beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl@engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl@xebidipar
- \fi
- \else
- \ifcase\bbl@engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl@foreach{#2}{%
\bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault
diff --git a/Master/texmf-dist/tex/generic/babel/nil.ldf b/Master/texmf-dist/tex/generic/babel/nil.ldf
index a6c6ed76d76..a9fe897dc8f 100644
--- a/Master/texmf-dist/tex/generic/babel/nil.ldf
+++ b/Master/texmf-dist/tex/generic/babel/nil.ldf
@@ -31,7 +31,7 @@
%% and covered by LPPL is defined by the unpacking scripts (with
%% extension |.ins|) which are part of the distribution.
%%
-\ProvidesLanguage{nil}[2017/10/04 3.14 Nil language]
+\ProvidesLanguage{nil}[2017/11/03 3.15 Nil language]
\LdfInit{nil}{datenil}
\ifx\l@nohyphenation\@undefined
\@nopatterns{nil}
diff --git a/Master/texmf-dist/tex/generic/babel/switch.def b/Master/texmf-dist/tex/generic/babel/switch.def
index 35901eab59e..3a0426fa3d9 100644
--- a/Master/texmf-dist/tex/generic/babel/switch.def
+++ b/Master/texmf-dist/tex/generic/babel/switch.def
@@ -36,7 +36,7 @@
\wlog{File: #1 #4 #3 <#2>}%
\let\ProvidesFile\@undefined}
\fi
-\ProvidesFile{switch.def}[2017/10/04 3.14 Babel switching mechanism]
+\ProvidesFile{switch.def}[2017/11/03 3.15 Babel switching mechanism]
\ifx\AtBeginDocument\@undefined
\input plain.def\relax
\fi
@@ -57,8 +57,8 @@
\countdef\last@language=19
\def\addlanguage{\alloc@9\language\chardef\@cclvi}
\fi
-\def\bbl@version{3.14}
-\def\bbl@date{2017/10/04}
+\def\bbl@version{3.15}
+\def\bbl@date{2017/11/03}
\def\adddialect#1#2{%
\global\chardef#1#2\relax
\bbl@usehooks{adddialect}{{#1}{#2}}%
@@ -102,9 +102,12 @@
\xdef\bbl@language@stack{\languagename+\bbl@language@stack}}
\def\bbl@pop@lang#1+#2-#3{%
\edef\languagename{#1}\xdef#3{#2}}
+\let\bbl@ifrestoring\@secondoftwo
\def\bbl@pop@language{%
\expandafter\bbl@pop@lang\bbl@language@stack-\bbl@language@stack
- \expandafter\bbl@set@language\expandafter{\languagename}}
+ \let\bbl@ifrestoring\@firstoftwo
+ \expandafter\bbl@set@language\expandafter{\languagename}%
+ \let\bbl@ifrestoring\@secondoftwo}
\expandafter\def\csname selectlanguage \endcsname#1{%
\ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\tw@\fi
\bbl@push@language
@@ -150,8 +153,15 @@
\bbl@usehooks{afterreset}{}%
\languageshorthands{none}%
\ifcase\bbl@select@type
- \csname captions#1\endcsname\relax
- \csname date#1\endcsname\relax
+ \ifhmode
+ \hskip\z@skip % trick to ignore spaces
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \loop\ifdim\lastskip>\z@\unskip\repeat\unskip
+ \else
+ \csname captions#1\endcsname\relax
+ \csname date#1\endcsname\relax
+ \fi
\fi
\bbl@usehooks{beforeextras}{}%
\csname extras#1\endcsname\relax
@@ -242,7 +252,7 @@
\@expandtwoargs\bbl@usehooks{patterns}{{#1}{\bbl@tempa}}%
\@ifundefined{bbl@hyphenation@}{}{% Can be \relax!
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl@hyphlist}%
+ \bbl@xin@{,\number\language,}{,\bbl@hyphlist}%
\ifin@\else
\@expandtwoargs\bbl@usehooks{hyphenation}{{#1}{\bbl@tempa}}%
\hyphenation{%
@@ -254,17 +264,14 @@
\fi
\endgroup}}
\def\hyphenrules#1{%
- \edef\languagename{#1}%
- \bbl@fixname\languagename
- \bbl@iflanguage\languagename{%
- \expandafter\bbl@patterns\expandafter{\languagename}%
+ \edef\bbl@tempf{#1}%
+ \bbl@fixname\bbl@tempf
+ \bbl@iflanguage\bbl@tempf{%
+ \expandafter\bbl@patterns\expandafter{\bbl@tempf}%
\languageshorthands{none}%
- \expandafter\ifx\csname\languagename hyphenmins\endcsname\relax
- \set@hyphenmins\tw@\thr@@\relax
- \else
- \expandafter\expandafter\expandafter\set@hyphenmins
- \csname\languagename hyphenmins\endcsname\relax
- \fi}}
+ \bbl@ifunset{\bbl@tempf hyphenmins}%
+ {\set@hyphenmins\tw@\thr@@\relax}%
+ {\bbl@exp{\\\set@hyphenmins\@nameuse{\bbl@tempf hyphenmins}}}}}
\let\endhyphenrules\@empty
\def\providehyphenmins#1#2{%
\expandafter\ifx\csname #1hyphenmins\endcsname\relax
diff --git a/Master/texmf-dist/tex/generic/babel/xebabel.def b/Master/texmf-dist/tex/generic/babel/xebabel.def
index c3df40d1887..b3a75c9fd2b 100644
--- a/Master/texmf-dist/tex/generic/babel/xebabel.def
+++ b/Master/texmf-dist/tex/generic/babel/xebabel.def
@@ -73,30 +73,116 @@
\L 00FF 0178 00FF
\endgroup
\input #1\relax}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont}
+\DisableBabelHook{babel-fontspec}
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl@tempa{#1}%
+ \def\bbl@tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl@bblfont}
+\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname
+ \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \expandafter\bbl@ifblank\expandafter{\bbl@tempa}%
+ {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@
+ \bbl@exp{%
+ \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>%
+ \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>%
+ \<\bbl@tempb default>\<\bbl@tempb family>}}%
+ {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt
+ \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}%
+\def\bbl@providefam#1{%
+ \bbl@exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl@add@list\\\bbl@font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not@math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+\def\bbl@switchfont{%
+ \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}%
+ \bbl@exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}%
+ \bbl@foreach\bbl@font@fams{%
+ \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script?
+ {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl@exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl@exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl@tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl@tempa{%
+ \bbl@warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl@foreach\bbl@font@fams{% don't gather with prev for
+ \bbl@ifunset{bbl@##1dflt@\languagename}%
+ {\bbl@cs{famrst@##1}%
+ \global\bbl@csarg\let{famrst@##1}\relax}%
+ {\bbl@exp{% order is relevant
+ \\\bbl@add\\\originalTeX{%
+ \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl@ifrestoring{}{\bbl@tempa}}%
+\def\bbl@font@set#1#2#3{%
+ \bbl@xin@{<>}{#1}%
+ \ifin@
+ \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl@exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang}
+ \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}}
+\def\bbl@fontspec@set#1#2#3{%
+ \bbl@exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl@cs{lsys@\languagename},#2}}{#3}%
+ \bbl@toglobal#1}%
+\def\bbl@provide@lsys#1{%
+ \bbl@ifunset{bbl@lname@#1}%
+ {\bbl@ini@ids{#1}}%
+ {}%
+ \bbl@csarg\let{lsys@#1}\@empty
+ \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}%
+ \bbl@ifunset{bbl@sotf#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}%
+ \bbl@ifunset{bbl@lname@#1}{}%
+ {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}%
+ \bbl@csarg\bbl@toglobal{lsys@#1}}%
+ % \bbl@exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl@cs{sname@#1}}%
+ % {\\\newfontscript{\bbl@cs{sname@#1}}{\bbl@cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl@cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl@cs{lname@#1}}{\bbl@cs{lotf@#1}}}}}
+\def\bbl@ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl@add\bbl@secpost@identification{%
+ \def\bbl@iniline########1\bbl@iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl@read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+\def\bbl@font@rst#1#2#3#4{%
+ \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}}
+\def\bbl@font@fams{rm,sf,tt}
\newcommand\babelFSstore[2][]{%
\bbl@ifblank{#1}%
- {\bbl@csarg\def{script@#2}{Latin}}%
- {\bbl@csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts\bbl@rscripts}%
- \ifin@
+ {\bbl@csarg\def{sname@#2}{Latin}}%
+ {\bbl@csarg\def{sname@#2}{#1}}%
+ \bbl@provide@dirs{#2}%
+ \bbl@csarg\ifnum{wdir@#2}>\z@
\let\bbl@beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl@engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl@xebidipar
- \fi
- \else
- \ifcase\bbl@engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl@foreach{#2}{%
\bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault