texlive[45683] Master/texmf-dist: babel (3nov17)
commits+karl at tug.org
commits+karl at tug.org
Fri Nov 3 22:38:45 CET 2017
Revision: 45683
http://tug.org/svn/texlive?view=revision&revision=45683
Author: karl
Date: 2017-11-03 22:38:44 +0100 (Fri, 03 Nov 2017)
Log Message:
-----------
babel (3nov17)
Modified Paths:
--------------
trunk/Master/texmf-dist/doc/latex/babel/README
trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
trunk/Master/texmf-dist/source/latex/babel/babel.dtx
trunk/Master/texmf-dist/source/latex/babel/babel.ins
trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
trunk/Master/texmf-dist/source/latex/babel/locale.zip
trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
trunk/Master/texmf-dist/tex/generic/babel/babel.def
trunk/Master/texmf-dist/tex/generic/babel/babel.sty
trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
trunk/Master/texmf-dist/tex/generic/babel/luababel.def
trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
trunk/Master/texmf-dist/tex/generic/babel/switch.def
trunk/Master/texmf-dist/tex/generic/babel/xebabel.def
Modified: trunk/Master/texmf-dist/doc/latex/babel/README
===================================================================
--- trunk/Master/texmf-dist/doc/latex/babel/README 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/doc/latex/babel/README 2017-11-03 21:38:44 UTC (rev 45683)
@@ -1,4 +1,4 @@
-Babel 3.14
+Babel 3.15
----------
This package manages culturally-determined typographical (and other)
@@ -49,6 +49,15 @@
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 @@
------------
Javier Bezos
-2017/10/04
+2017/11/03
Modified: trunk/Master/texmf-dist/doc/latex/babel/babel.pdf
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/source/latex/babel/babel.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.dtx 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.dtx 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 @@
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 @@
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 @@
\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,7 +408,8 @@
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}
@@ -411,8 +416,7 @@
_\usepackage[russian]{babel}_
-\usepackage{fontspec}
-\setmainfont[_Language=Russian,Script=Cyrillic_]{DejaVu Serif}
+\babelfont{rm}{DejaVu Serif}
\begin{document}
@@ -423,7 +427,6 @@
\end{document}
\end{verbatim}
-
\end{example}
\subsection{Troubleshooting}
@@ -454,8 +457,8 @@
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 @@
\selectlanguage{german}
\end{verbatim}
-
This command can be used as environment, too.
\begin{note}
@@ -629,13 +631,20 @@
|\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,89 +671,8 @@
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}
+With |ini| files (see below), captions are ensured by default.
-\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.
-
\subsection{Shorthands}
A \textit{shorthand} is a sequence of one or two characters that
@@ -771,7 +699,7 @@
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 @@
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 @@
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 @@
\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,22 +816,30 @@
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{"}{/}|.
-The following example shows how to replace a shorthand by another
+\begin{note}
+ The substitute character must \textit{not} have been declared before
+ as shorthand (in such a case, |\aliashorthands| is ignored).
+\end{note}
+
+\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 at char~| or
-|\normal at 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 at char~| or
+ |\normal at 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
language level. It takes one argument, the name of a language or
@@ -1098,14 +1035,49 @@
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{}. 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”.
+\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.
+\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}
+
+ at 9وقد عرفت شبه جزيرة العرب طيلة العصر الهيليني )الاغريقي( بـ
+ at 1Arabia@0 أو @1Aravia at 0 )بالاغريقية @1Αραβία@0(، استخدم الرومان ثلاث
+بادئات بـ@1“Arabia”@0 على ثلاث مناطق من شبه الجزيرة العربية، إلا أنها
+حقيقةً كانت أكبر مما تعرف عليه اليوم.
+
+ at 0\end{document}
+\end{verbatim}
+\endgroup
+\end{example}
+
\subsection{The \texttt{base} option}
With this package option \babel{} just loads some basic macros (those
@@ -1115,6 +1087,7 @@
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 @@
\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 @@
\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 @@
|\<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 @@
\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 @@
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 @@
\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 @@
\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,8 +2441,69 @@
\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
Unicode Common Locale Data Repository (CLDR). Those system, however,
@@ -1620,7 +2511,7 @@
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,13 +2519,6 @@
``\'{\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
@@ -1641,103 +2525,34 @@
\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}
-
- at 9وقد عرفت شبه جزيرة العرب طيلة العصر الهيليني )الاغريقي(
-بـ @1Arabia at 0 أو @1Aravia at 0 )بالاغريقية @1Αραβία@0(، استخدم
-الرومان ثلاث بادئات بـ@1“Arabia”@0 على ثلاث مناطق من شبه الجزيرة
-العربية، إلا أنها حقيقةً كانت أكبر مما تعرف عليه اليوم.
-
- at 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 @@
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 @@
\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 @@
% 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 @@
%
% \changes{babel~3.9i}{2014/02/16}{\cs{@for} didn't work with
% Plain. Added \cs{bbl at loop}}
+% \changes{babel~3.15}{2017/10/30}{New convenience macros
+% \cs{bbl at xin@} and \cs{bbl at cs}}
%
% \begin{macrocode}
%<<*Basic macros>>
@@ -2649,7 +3454,9 @@
\bbl at ifunset{\bbl at stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl at xin@{\@expandtwoargs\in@}
\def\bbl at csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl at cs#1{\csname bbl@#1\endcsname}
\def\bbl at loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl at loopx#1#2{\expandafter\bbl at loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -2840,8 +3647,7 @@
% \end{macrocode}
% \end{macro}
%
-%
-% Two more tools. |\bbl at samestring| first expand its arguments and
+% Two further tools. |\bbl at samestring| first expand its arguments and
% then compare their expansion (sanitized, so that the catcodes do not
% matter). |\bbl at 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 @@
\bbl at languages
\fi
\@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption
+ \let\bbl at beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
\RequirePackage{luatexbase}%
\directlua{
require('babel-bidi.lua')
@@ -3206,7 +4014,7 @@
% \begin{macrocode}
\let\bbl at language@opts\@empty
\DeclareOption*{%
- \@expandtwoargs\in@{\string=}{\CurrentOption}%
+ \bbl at xin@{\string=}{\CurrentOption}%
\ifin@
\expandafter\bbl at tempa\CurrentOption\bbl at tempa
\else
@@ -3254,7 +4062,7 @@
%
% \begin{macrocode}
\def\bbl at ifshorthand#1{%
- \@expandtwoargs\in@{\string#1}{\bbl at opt@shorthands}%
+ \bbl at xin@{\string#1}{\bbl at opt@shorthands}%
\ifin@
\expandafter\@firstoftwo
\else
@@ -3482,7 +4290,7 @@
\edef\bbl at tempa{\@classoptionslist,\bbl at language@opts}
\let\bbl at tempc\@empty
\bbl at for\bbl at tempb\bbl at tempa{%
- \@expandtwoargs\in@{,\bbl at tempb,}{,\bbl at loaded,}%
+ \bbl at xin@{,\bbl at tempb,}{,\bbl at loaded,}%
\ifin@\edef\bbl at tempc{\bbl at tempb}\fi}
\def\bbl at tempa#1,#2\@nnil{\def\bbl at tempb{#1}}
\expandafter\bbl at tempa\bbl at loaded,\@nnil
@@ -4949,7 +5757,7 @@
% already selected attributes.
%
% \begin{macrocode}
- \@expandtwoargs\in@{,\bbl at tempc-##1,}{,\bbl at known@attribs,}%
+ \bbl at xin@{,\bbl at tempc-##1,}{,\bbl at known@attribs,}%
\fi
% \end{macrocode}
%
@@ -5008,7 +5816,7 @@
%
% \begin{macrocode}
\def\bbl at declare@ttribute#1#2#3{%
- \@expandtwoargs\in@{,#2,}{,\BabelModifiers,}%
+ \bbl at xin@{,#2,}{,\BabelModifiers,}%
\ifin@
\AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}%
\fi
@@ -5045,7 +5853,7 @@
% The we need to check the list of known attributes.
%
% \begin{macrocode}
- \@expandtwoargs\in@{,#1-#2,}{,\bbl at known@attribs,}%
+ \bbl at xin@{,#1-#2,}{,\bbl at known@attribs,}%
\fi
% \end{macrocode}
%
@@ -5573,8 +6381,7 @@
\expandafter
\bbl at toglobal\csname####1\string##1\endcsname}}}%
\def\bbl at sctest{%
- \@expandtwoargs
- \in@{,\bbl at opt@strings,}{,\bbl at sc@label,\bbl at sc@fontenc,}}%
+ \bbl at xin@{,\bbl at opt@strings,}{,\bbl at sc@label,\bbl at sc@fontenc,}}%
\fi
\ifx\bbl at opt@strings\@nnil % ie, no strings key -> defaults
\else\ifx\bbl at opt@strings\relax % ie, strings=encoded
@@ -5619,7 +6426,7 @@
% \begin{macrocode}
\def\bbl at forlang#1#2{%
\bbl at for#1\bbl at L{%
- \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}%
+ \bbl at xin@{,#1,}{,\BabelLanguages,}%
\ifin@#2\relax\fi}}
\def\bbl at scswitch{%
\bbl at forlang\bbl at tempa{%
@@ -5626,7 +6433,7 @@
\ifx\bbl at G\@empty\else
\ifx\SetString\@gobbletwo\else
\edef\bbl at GL{\bbl at G\bbl at tempa}%
- \@expandtwoargs\in@{,\bbl at GL,}{,\bbl at screset,}%
+ \bbl at xin@{,\bbl at GL,}{,\bbl at screset,}%
\ifin@\else
\global\expandafter\let\csname\bbl at GL\endcsname\@undefined
\xdef\bbl at screset{\bbl at screset,\bbl at GL}%
@@ -5826,7 +6633,7 @@
% \begin{macrocode}
\AtEndOfPackage{%
\ifx\bbl at opt@hyphenmap\@undefined
- \@expandtwoargs\in@{,}{\bbl at language@opts}%
+ \bbl at xin@{,}{\bbl at language@opts}%
\chardef\bbl at opt@hyphenmap\ifin at 4\else\@ne\fi
\fi}
% \end{macrocode}
@@ -6360,7 +7167,9 @@
% \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][]{%
\let\bbl at savelangname\languagename
@@ -6368,6 +7177,9 @@
\let\bbl at KVP@captions\@nil
\let\bbl at KVP@import\@nil
\let\bbl at KVP@main\@nil
+ \let\bbl at KVP@script\@nil
+ \let\bbl at KVP@language\@nil
+ \let\bbl at KVP@dir\@nil
\let\bbl at KVP@hyphenrules\@nil
\bbl at forkv{#1}{\bbl at csarg\def{KVP@##1}{##2}}% TODO - error handling
\ifx\bbl at KVP@captions\@nil
@@ -6384,6 +7196,12 @@
{Use this macro as documented}}%
{\bbl at provide@renew{#2}}}%
\bbl at exp{\\\babelensure[exclude=\\\today]{#2}}%
+ \ifx\bbl at KVP@script\@nil\else
+ \bbl at csarg\edef{sname@#2}{\bbl at KVP@script}%
+ \fi
+ \ifx\bbl at KVP@language\@nil\else
+ \bbl at csarg\edef{lname@#2}{\bbl at KVP@language}%
+ \fi
\let\languagename\bbl at savelangname}
% \end{macrocode}
%
@@ -6468,14 +7286,14 @@
\bbl at exp{% and hyphenrules is not empty
\\\bbl at ifblank{\@nameuse{bbl at hyphr@#1}}%
{}%
- {\\\adddialect\<l@#1>\<l@\@nameuse{bbl at hyphr@\languagename}>}}%
+ {\let\\\bbl at tempa\<l@\@nameuse{bbl at hyphr@\languagename}>}}%
\fi
- \bbl at ifunset{l@#1}% no hyphenrules found - fallback
- {\bbl at exp{\\\adddialect\<l@#1>\language}}%
- {}%
- \else
- \bbl at exp{\\\adddialect\<l@#1>\bbl at tempa}% found in opt list
- \fi}
+ \fi
+ \bbl at ifunset{bbl at tempa}% ie, relax or undefined
+ {\bbl at ifunset{l@#1}% no hyphenrules found - fallback
+ {\bbl at exp{\\\adddialect\<l@#1>\language}}%
+ {}}% so, l@<lang> is ok - nothing to do
+ {\bbl at exp{\\\adddialect\<l@#1>\bbl at 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 @@
% become expanded at the wrong moment.
%
% \begin{macrocode}
-\@expandtwoargs\in@{R}\bbl at opt@safe
+\bbl at xin@{R}\bbl at opt@safe
\ifin@
\bbl at redefinerobust\ref#1{%
\@safe at activestrue\org at ref{#1}\@safe at activesfalse}
@@ -6860,7 +7678,7 @@
% only be deactivated in the second argument.
%
% \begin{macrocode}
-\@expandtwoargs\in@{B}\bbl at opt@safe
+\bbl at xin@{B}\bbl at opt@safe
\ifin@
\bbl at redefine\@citex[#1]#2{%
\@safe at activestrue\edef\@tempa{#2}\@safe at activesfalse
@@ -7131,7 +7949,7 @@
% time.
%
% \begin{macrocode}
-\@expandtwoargs\in@{R}\bbl at opt@safe
+\bbl at xin@{R}\bbl at opt@safe
\ifin@
\AtBeginDocument{%
\@ifpackageloaded{ifthen}{%
@@ -7379,7 +8197,7 @@
\in at false
\bbl at foreach\BabelNonASCII{% is there a non-ascii enc?
\ifin@\else
- \lowercase{\@expandtwoargs\in@{,#1enc.def,}{,\@filelist,}}%
+ \lowercase{\bbl at xin@{,#1enc.def,}{,\@filelist,}}%
\fi}%
\ifin@ % if a non-ascii has been loaded
\def\ensureascii#1{{\fontencoding{OT1}\selectfont#1}}%
@@ -7390,7 +8208,7 @@
\ifx\@empty#2\else
\bbl at ifunset{T@#1}%
{}%
- {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}%
+ {\bbl at xin@{,#1,}{,\BabelNonASCII,}%
\ifin@
\DeclareTextCommand{\TeX}{#1}{\ensureascii{\org at TeX}}%
\DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org at LaTeX}}%
@@ -7399,7 +8217,7 @@
\fi}%
\fi}%
\bbl at foreach\@filelist{\bbl at tempb#1\@@}% TODO - \@@ de mas??
- \@expandtwoargs\in@{,\cf at encoding,}{,\BabelNonASCII,}%
+ \bbl at xin@{,\cf at encoding,}{,\BabelNonASCII,}%
\ifin@\else
\edef\ensureascii#1{{%
\noexpand\fontencoding{\cf at encoding}\noexpand\selectfont#1}}%
@@ -7508,6 +8326,11 @@
% 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 at alscripts{,Arabic,Syriac,Thaana,}
\def\bbl at rscripts{%
@@ -7517,15 +8340,20 @@
Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,%
Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,%
Old South Arabian,}%
-\def\bbl at ensuredir{%
- \@expandtwoargs
- \in@{\csname bbl at script@\languagename\endcsname}%
- {\bbl at alscripts\bbl at rscripts}%
+\def\bbl at provide@dirs#1{%
+ \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts\bbl at rscripts}%
\ifin@
- \bbl at setdirs\@ne
+ \global\bbl at csarg\chardef{wdir@#1}\@ne
+ \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts}%
+ \ifin@
+ \global\bbl at csarg\chardef{wdir@#1}\tw@ % useless in xetex
+ \fi
\else
- \bbl at setdirs\z@
+ \global\bbl at csarg\chardef{wdir@#1}\z@
\fi}
+\def\bbl at switchdir{%
+ \bbl at ifunset{bbl at wdir@\languagename}{\bbl at provide@dirs{\languagename}}{}%
+ \bbl at exp{\\\bbl at setdirs\bbl at cs{wdir@\languagename}}}
\def\bbl at setdirs#1{% TODO - math
\ifcase\bbl at select@type % TODO - strictly, not the right test
\bbl at pagedir{#1}%
@@ -7535,7 +8363,7 @@
\bbl at textdir{#1}}
\ifcase\bbl at engine
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl at ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
\DisableBabelHook{babel-bidi}
\def\bbl at getluadir#1{%
\directlua{
@@ -7554,13 +8382,15 @@
#2 TRT\relax
\fi
\fi}
- \def\bbl at textdir{\bbl at setdir{text}\textdir}% TODO - ?\linedir
+ \def\bbl at textdir#1{%
+ \bbl at setdir{text}\textdir{#1}% TODO - ?\linedir
+ \setattribute\bbl at attr@dir{#1}}
\def\bbl at pardir{\bbl at setdir{par}\pardir}
\def\bbl at bodydir{\bbl at setdir{body}\bodydir}
\def\bbl at pagedir{\bbl at setdir{page}\pagedir}
\def\bbl at dirparastext{\pardir\the\textdir\relax}% %%%%
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl at ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
\DisableBabelHook{babel-bidi}
\newcount\bbl at dirlevel
\chardef\bbl at thetextdir\z@
@@ -7889,9 +8719,12 @@
% the `-'-sign and finally the reference to the stack.
%
% \begin{macrocode}
+\let\bbl at ifrestoring\@secondoftwo
\def\bbl at pop@language{%
\expandafter\bbl at pop@lang\bbl at language@stack-\bbl at language@stack
- \expandafter\bbl at set@language\expandafter{\languagename}}
+ \let\bbl at ifrestoring\@firstoftwo
+ \expandafter\bbl at set@language\expandafter{\languagename}%
+ \let\bbl at ifrestoring\@secondoftwo}
% \end{macrocode}
%
% Once the name of the previous language is retrieved from the stack,
@@ -8021,6 +8854,7 @@
% \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 at switch#1{%
@@ -8032,8 +8866,15 @@
\bbl at usehooks{afterreset}{}%
\languageshorthands{none}%
\ifcase\bbl at select@type
- \csname captions#1\endcsname\relax
- \csname date#1\endcsname\relax
+ \ifhmode
+ \hskip\z at 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 at usehooks{beforeextras}{}%
\csname extras#1\endcsname\relax
@@ -8259,7 +9100,7 @@
\@expandtwoargs\bbl at usehooks{patterns}{{#1}{\bbl at tempa}}%
\@ifundefined{bbl at hyphenation@}{}{% Can be \relax!
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl at hyphlist}%
+ \bbl at xin@{,\number\language,}{,\bbl at hyphlist}%
\ifin@\else
\@expandtwoargs\bbl at usehooks{hyphenation}{{#1}{\bbl at tempa}}%
\hyphenation{%
@@ -8285,20 +9126,18 @@
% \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 at patterns}}
+% \changes{3.15}{2017/10/30}{Don't set language name. Use temp macro.}
%
% \begin{macrocode}
\def\hyphenrules#1{%
- \edef\languagename{#1}%
- \bbl at fixname\languagename
- \bbl at iflanguage\languagename{%
- \expandafter\bbl at patterns\expandafter{\languagename}%
+ \edef\bbl at tempf{#1}%
+ \bbl at fixname\bbl at tempf
+ \bbl at iflanguage\bbl at tempf{%
+ \expandafter\bbl at patterns\expandafter{\bbl at tempf}%
\languageshorthands{none}%
- \expandafter\ifx\csname\languagename hyphenmins\endcsname\relax
- \set at hyphenmins\tw@\thr@@\relax
- \else
- \expandafter\expandafter\expandafter\set at hyphenmins
- \csname\languagename hyphenmins\endcsname\relax
- \fi}}
+ \bbl at ifunset{\bbl at tempf hyphenmins}%
+ {\set at hyphenmins\tw@\thr@@\relax}%
+ {\bbl at exp{\\\set at hyphenmins\@nameuse{\bbl at tempf hyphenmins}}}}}
\let\endhyphenrules\@empty
% \end{macrocode}
%
@@ -8954,48 +9793,203 @@
% 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 at attr@dir
+ \let\bbl at beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
+\DeclareOption{bidi=default}%
+ {\let\bbl at beforeforeign\leavevmode
+ \ifcase\bbl at engine\or
+ \newattribute\bbl at attr@dir
+ \fi
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifcase\bbl at engine\or\or
+ \bbl at 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 at tempa{#1}%
+ \def\bbl at tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl at bblfont}
+\newcommand\bbl at bblfont[2][]{% 1=features 2=fontname
+ \bbl at ifunset{\bbl at tempb family}{\bbl at providefam{\bbl at tempb}}{}%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \expandafter\bbl at ifblank\expandafter{\bbl at tempa}%
+ {\bbl at csarg\edef{\bbl at tempb dflt@}{<>{#1}{#2}}% save bbl at rmdflt@
+ \bbl at exp{%
+ \let\<bbl@\bbl at tempb dflt@\languagename>\<bbl@\bbl at tempb dflt@>%
+ \\\bbl at font@set\<bbl@\bbl at tempb dflt@\languagename>%
+ \<\bbl at tempb default>\<\bbl at tempb family>}}%
+ {\bbl at foreach\bbl at tempa{% ie bbl at rmdflt@lang / *scrt
+ \bbl at csarg\def{\bbl at 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 at providefam#1{%
+ \bbl at exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl at add@list\\\bbl at font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not at 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 at switchfont{%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \bbl at exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl at tempa{\bbl at cs{sname@\languagename}}}}%
+ \bbl at foreach\bbl at font@fams{%
+ \bbl at ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl at ifunset{bbl@##1dflt@*\bbl at tempa}% (2) from script?
+ {\bbl at ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl at exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl at exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl at tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl at tempa{%
+ \bbl at warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl at foreach\bbl at font@fams{% don't gather with prev for
+ \bbl at ifunset{bbl@##1dflt@\languagename}%
+ {\bbl at cs{famrst@##1}%
+ \global\bbl at csarg\let{famrst@##1}\relax}%
+ {\bbl at exp{% order is relevant
+ \\\bbl at add\\\originalTeX{%
+ \\\bbl at font@rst{\bbl at cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl at font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl at ifrestoring{}{\bbl at 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 at font@set#1#2#3{%
+ \bbl at xin@{<>}{#1}%
+ \ifin@
+ \bbl at exp{\\\bbl at fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl at exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl at rm1dflt@lang}
+ \\\bbl at ifsamestring{#2}{\f at family}{\\#3\let\\\bbl at tempa\relax}{}}}
+\def\bbl at fontspec@set#1#2#3{%
+ \bbl at exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl at cs{lsys@\languagename},#2}}{#3}%
+ \bbl at 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 at provide@lsys#1{%
+ \bbl at ifunset{bbl at lname@#1}%
+ {\bbl at ini@ids{#1}}%
+ {}%
+ \bbl at csarg\let{lsys@#1}\@empty
+ \bbl at ifunset{bbl at sname@#1}{\bbl at csarg\gdef{sname@#1}{Default}}{}%
+ \bbl at ifunset{bbl at sotf#1}{\bbl at csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl at csarg\bbl at add@list{lsys@#1}{Script=\bbl at cs{sname@#1}}%
+ \bbl at ifunset{bbl at lname@#1}{}%
+ {\bbl at csarg\bbl at add@list{lsys@#1}{Language=\bbl at cs{lname@#1}}}%
+ \bbl at csarg\bbl at toglobal{lsys@#1}}%
+ % \bbl at exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl at cs{sname@#1}}%
+ % {\\\newfontscript{\bbl at cs{sname@#1}}{\bbl at cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl at cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl at cs{lname@#1}}{\bbl at 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 at ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl at add\bbl at secpost@identification{%
+ \def\bbl at iniline########1\bbl at iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl at read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+% \end{macrocode}
+%
+% font at 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 at font@rst#1#2#3#4{%
+ \bbl at csarg\def{famrst@#4}{\bbl at 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 at 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 at ifblank{#1}%
- {\bbl at csarg\def{script@#2}{Latin}}%
- {\bbl at csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts\bbl at rscripts}%
- \ifin@
+ {\bbl at csarg\def{sname@#2}{Latin}}%
+ {\bbl at csarg\def{sname@#2}{#1}}%
+ \bbl at provide@dirs{#2}%
+ \bbl at csarg\ifnum{wdir@#2}>\z@
\let\bbl at beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl at engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl at xebidipar
- \fi
- \else
- \ifcase\bbl at engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl at foreach{#2}{%
\bbl at FSstore{##1}{rm}\rmdefault\bbl at save@rmdefault
@@ -9103,6 +10097,9 @@
\let\xebbl at stop\relax}
\AddBabelHook{xetex}{loadkernel}{%
<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl at switchfont}
+\DisableBabelHook{babel-fontspec}
<@Font selection@>
%</xetex>
% \end{macrocode}
@@ -9401,7 +10398,7 @@
\csname bbl at hyphendata@\the\language\endcsname}}{}%
\@ifundefined{bbl at patterns@}{}{%
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl at pttnlist}%
+ \bbl at xin@{,\number\language,}{,\bbl at pttnlist}%
\ifin@\else
\ifx\bbl at patterns@\@empty\else
\directlua{ Babel.addpatterns(
@@ -9472,6 +10469,9 @@
% \begin{macrocode}
\AddBabelHook{luatex}{loadkernel}{%
<@Restore Unicode catcodes before loading patterns@>}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl at switchfont}
+\DisableBabelHook{babel-fontspec}
<@Font selection@>
%</luatex>
% \end{macrocode}
@@ -9481,8 +10481,8 @@
% \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 @@
%<*basic-r>
Babel = Babel or {}
-Babel.langdirs = {}
-
require('babel-bidi.lua')
local characters = Babel.characters
@@ -15634,11 +16632,10 @@
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 @@
local new_dir = false
local first_dir = false
- local last_lr = nil
+ local last_lr
local type_n = ''
@@ -15687,7 +16684,20 @@
%
% \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 at 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 @@
ch.char = characters[ch.char].m or ch.char
end
end
- --last_lr = nil
end
end
% \end{macrocode}
Modified: trunk/Master/texmf-dist/source/latex/babel/babel.ins
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/babel.ins 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/source/latex/babel/babel.ins 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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}}
Modified: trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/source/latex/babel/bbcompat.dtx 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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'
Modified: trunk/Master/texmf-dist/source/latex/babel/locale.zip
===================================================================
(Binary files differ)
Modified: trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua 2017-11-03 21:38:44 UTC (rev 45683)
@@ -33,8 +33,6 @@
--
Babel = Babel or {}
-Babel.langdirs = {}
-
require('babel-bidi.lua')
local characters = Babel.characters
@@ -53,11 +51,10 @@
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 @@
local new_dir = false
local first_dir = false
- local last_lr = nil
+ local last_lr
local type_n = ''
@@ -88,7 +85,20 @@
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 at 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 @@
ch.char = characters[ch.char].m or ch.char
end
end
- --last_lr = nil
end
end
if dir == 'l' or dir == 'r' then
Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.def 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.def 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 at ifunset{\bbl at stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl at xin@{\@expandtwoargs\in@}
\def\bbl at csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl at cs#1{\csname bbl@#1\endcsname}
\def\bbl at loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl at loopx#1#2{\expandafter\bbl at loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -688,7 +690,7 @@
\ifx\bbl at known@attribs\@undefined
\in at false
\else
- \@expandtwoargs\in@{,\bbl at tempc-##1,}{,\bbl at known@attribs,}%
+ \bbl at xin@{,\bbl at tempc-##1,}{,\bbl at known@attribs,}%
\fi
\ifin@
\bbl at warning{%
@@ -708,7 +710,7 @@
{The attribute #2 is unknown for language #1.}%
{Your command will be ignored, type <return> to proceed}}
\def\bbl at declare@ttribute#1#2#3{%
- \@expandtwoargs\in@{,#2,}{,\BabelModifiers,}%
+ \bbl at xin@{,#2,}{,\BabelModifiers,}%
\ifin@
\AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}%
\fi
@@ -718,7 +720,7 @@
\ifx\bbl at known@attribs\@undefined
\in at false
\else
- \@expandtwoargs\in@{,#1-#2,}{,\bbl at known@attribs,}%
+ \bbl at xin@{,#1-#2,}{,\bbl at known@attribs,}%
\fi
\ifin@
\bbl at afterelse#3%
@@ -952,8 +954,7 @@
\expandafter
\bbl at toglobal\csname####1\string##1\endcsname}}}%
\def\bbl at sctest{%
- \@expandtwoargs
- \in@{,\bbl at opt@strings,}{,\bbl at sc@label,\bbl at sc@fontenc,}}%
+ \bbl at xin@{,\bbl at opt@strings,}{,\bbl at sc@label,\bbl at sc@fontenc,}}%
\fi
\ifx\bbl at opt@strings\@nnil % ie, no strings key -> defaults
\else\ifx\bbl at opt@strings\relax % ie, strings=encoded
@@ -982,7 +983,7 @@
\fi}
\def\bbl at forlang#1#2{%
\bbl at for#1\bbl at L{%
- \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}%
+ \bbl at xin@{,#1,}{,\BabelLanguages,}%
\ifin@#2\relax\fi}}
\def\bbl at scswitch{%
\bbl at forlang\bbl at tempa{%
@@ -989,7 +990,7 @@
\ifx\bbl at G\@empty\else
\ifx\SetString\@gobbletwo\else
\edef\bbl at GL{\bbl at G\bbl at tempa}%
- \@expandtwoargs\in@{,\bbl at GL,}{,\bbl at screset,}%
+ \bbl at xin@{,\bbl at GL,}{,\bbl at screset,}%
\ifin@\else
\global\expandafter\let\csname\bbl at GL\endcsname\@undefined
\xdef\bbl at screset{\bbl at screset,\bbl at GL}%
@@ -1065,7 +1066,7 @@
\bbl at tempa}
\AtEndOfPackage{%
\ifx\bbl at opt@hyphenmap\@undefined
- \@expandtwoargs\in@{,}{\bbl at language@opts}%
+ \bbl at xin@{,}{\bbl at language@opts}%
\chardef\bbl at opt@hyphenmap\ifin at 4\else\@ne\fi
\fi}
\def\set at low@box#1{\setbox\tw@\hbox{,}\setbox\z@\hbox{#1}%
@@ -1259,6 +1260,9 @@
\let\bbl at KVP@captions\@nil
\let\bbl at KVP@import\@nil
\let\bbl at KVP@main\@nil
+ \let\bbl at KVP@script\@nil
+ \let\bbl at KVP@language\@nil
+ \let\bbl at KVP@dir\@nil
\let\bbl at KVP@hyphenrules\@nil
\bbl at forkv{#1}{\bbl at csarg\def{KVP@##1}{##2}}% TODO - error handling
\ifx\bbl at KVP@captions\@nil
@@ -1275,6 +1279,12 @@
{Use this macro as documented}}%
{\bbl at provide@renew{#2}}}%
\bbl at exp{\\\babelensure[exclude=\\\today]{#2}}%
+ \ifx\bbl at KVP@script\@nil\else
+ \bbl at csarg\edef{sname@#2}{\bbl at KVP@script}%
+ \fi
+ \ifx\bbl at KVP@language\@nil\else
+ \bbl at csarg\edef{lname@#2}{\bbl at KVP@language}%
+ \fi
\let\languagename\bbl at savelangname}
\def\bbl at provide@new#1{%
\@namedef{date#1}{}% marks lang exists - required by \StartBabelCommands
@@ -1346,14 +1356,14 @@
\bbl at exp{% and hyphenrules is not empty
\\\bbl at ifblank{\@nameuse{bbl at hyphr@#1}}%
{}%
- {\\\adddialect\<l@#1>\<l@\@nameuse{bbl at hyphr@\languagename}>}}%
+ {\let\\\bbl at tempa\<l@\@nameuse{bbl at hyphr@\languagename}>}}%
\fi
- \bbl at ifunset{l@#1}% no hyphenrules found - fallback
- {\bbl at exp{\\\adddialect\<l@#1>\language}}%
- {}%
- \else
- \bbl at exp{\\\adddialect\<l@#1>\bbl at tempa}% found in opt list
- \fi}
+ \fi
+ \bbl at ifunset{bbl at tempa}% ie, relax or undefined
+ {\bbl at ifunset{l@#1}% no hyphenrules found - fallback
+ {\bbl at exp{\\\adddialect\<l@#1>\language}}%
+ {}}% so, l@<lang> is ok - nothing to do
+ {\bbl at exp{\\\adddialect\<l@#1>\bbl at tempa}}}% found in opt list or ini
\def\bbl at read@ini#1{%
\openin1=babel-#1.ini
\ifeof1
@@ -1532,7 +1542,7 @@
\@tempswatrue
\fi}
\fi
-\@expandtwoargs\in@{R}\bbl at opt@safe
+\bbl at xin@{R}\bbl at opt@safe
\ifin@
\bbl at redefinerobust\ref#1{%
\@safe at activestrue\org at ref{#1}\@safe at activesfalse}
@@ -1542,7 +1552,7 @@
\let\org at ref\ref
\let\org at pageref\pageref
\fi
-\@expandtwoargs\in@{B}\bbl at opt@safe
+\bbl at xin@{B}\bbl at opt@safe
\ifin@
\bbl at redefine\@citex[#1]#2{%
\@safe at activestrue\edef\@tempa{#2}\@safe at activesfalse
@@ -1602,7 +1612,7 @@
{\@temptokena\expandafter{\bbl at tempb{#2}}}%
\bbl at exp{\\\org at markboth{\the\toks@}{\the\@temptokena}}}
\bbl at tempc
-\@expandtwoargs\in@{R}\bbl at opt@safe
+\bbl at xin@{R}\bbl at opt@safe
\ifin@
\AtBeginDocument{%
\@ifpackageloaded{ifthen}{%
@@ -1681,7 +1691,7 @@
\in at false
\bbl at foreach\BabelNonASCII{% is there a non-ascii enc?
\ifin@\else
- \lowercase{\@expandtwoargs\in@{,#1enc.def,}{,\@filelist,}}%
+ \lowercase{\bbl at 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 at ifunset{T@#1}%
{}%
- {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}%
+ {\bbl at xin@{,#1,}{,\BabelNonASCII,}%
\ifin@
\DeclareTextCommand{\TeX}{#1}{\ensureascii{\org at TeX}}%
\DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org at LaTeX}}%
@@ -1701,7 +1711,7 @@
\fi}%
\fi}%
\bbl at foreach\@filelist{\bbl at tempb#1\@@}% TODO - \@@ de mas??
- \@expandtwoargs\in@{,\cf at encoding,}{,\BabelNonASCII,}%
+ \bbl at xin@{,\cf at encoding,}{,\BabelNonASCII,}%
\ifin@\else
\edef\ensureascii#1{{%
\noexpand\fontencoding{\cf at 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 at ensuredir{%
- \@expandtwoargs
- \in@{\csname bbl at script@\languagename\endcsname}%
- {\bbl at alscripts\bbl at rscripts}%
+\def\bbl at provide@dirs#1{%
+ \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts\bbl at rscripts}%
\ifin@
- \bbl at setdirs\@ne
+ \global\bbl at csarg\chardef{wdir@#1}\@ne
+ \bbl at xin@{\csname bbl at sname@#1\endcsname}{\bbl at alscripts}%
+ \ifin@
+ \global\bbl at csarg\chardef{wdir@#1}\tw@ % useless in xetex
+ \fi
\else
- \bbl at setdirs\z@
+ \global\bbl at csarg\chardef{wdir@#1}\z@
\fi}
+\def\bbl at switchdir{%
+ \bbl at ifunset{bbl at wdir@\languagename}{\bbl at provide@dirs{\languagename}}{}%
+ \bbl at exp{\\\bbl at setdirs\bbl at cs{wdir@\languagename}}}
\def\bbl at setdirs#1{% TODO - math
\ifcase\bbl at select@type % TODO - strictly, not the right test
\bbl at pagedir{#1}%
@@ -1756,7 +1771,7 @@
\bbl at textdir{#1}}
\ifcase\bbl at engine
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl at ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
\DisableBabelHook{babel-bidi}
\def\bbl at getluadir#1{%
\directlua{
@@ -1775,13 +1790,15 @@
#2 TRT\relax
\fi
\fi}
- \def\bbl at textdir{\bbl at setdir{text}\textdir}% TODO - ?\linedir
+ \def\bbl at textdir#1{%
+ \bbl at setdir{text}\textdir{#1}% TODO - ?\linedir
+ \setattribute\bbl at attr@dir{#1}}
\def\bbl at pardir{\bbl at setdir{par}\pardir}
\def\bbl at bodydir{\bbl at setdir{body}\bodydir}
\def\bbl at pagedir{\bbl at setdir{page}\pagedir}
\def\bbl at dirparastext{\pardir\the\textdir\relax}% %%%%
\or
- \AddBabelHook{babel-bidi}{afterextras}{\bbl at ensuredir}
+ \AddBabelHook{babel-bidi}{afterextras}{\bbl at switchdir}
\DisableBabelHook{babel-bidi}
\newcount\bbl at dirlevel
\chardef\bbl at thetextdir\z@
Modified: trunk/Master/texmf-dist/tex/generic/babel/babel.sty
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/babel.sty 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/babel.sty 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 at debug\@firstofone}
{\let\bbl at debug\@gobble}
@@ -47,7 +47,9 @@
\bbl at ifunset{\bbl at stripslash#1}%
{\def#1{#2}}%
{\expandafter\def\expandafter#1\expandafter{#1#2}}}
+\def\bbl at xin@{\@expandtwoargs\in@}
\def\bbl at csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}%
+\def\bbl at cs#1{\csname bbl@#1\endcsname}
\def\bbl at loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,}
\def\bbl at loopx#1#2{\expandafter\bbl at loop\expandafter#1\expandafter{#2}}
\def\bbl@@loop#1#2#3,{%
@@ -178,6 +180,8 @@
\bbl at languages
\fi
\@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption
+ \let\bbl at beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}%
\RequirePackage{luatexbase}%
\directlua{
require('babel-bidi.lua')
@@ -246,7 +250,20 @@
\DeclareOption{safe=none}{\let\bbl at opt@safe\@empty}
\DeclareOption{safe=bib}{\def\bbl at opt@safe{B}}
\DeclareOption{safe=ref}{\def\bbl at opt@safe{R}}
-\DeclareOption{bidi=basic-r}{}
+\DeclareOption{bidi=basic-r}%
+ {\newattribute\bbl at attr@dir
+ \let\bbl at beforeforeign\leavevmode
+ \AtEndOfPackage{\EnableBabelHook{babel-bidi}}}
+\DeclareOption{bidi=default}%
+ {\let\bbl at beforeforeign\leavevmode
+ \ifcase\bbl at engine\or
+ \newattribute\bbl at attr@dir
+ \fi
+ \AtEndOfPackage{%
+ \EnableBabelHook{babel-bidi}%
+ \ifcase\bbl at engine\or\or
+ \bbl at xebidipar
+ \fi}}
\let\bbl at opt@shorthands\@nnil
\let\bbl at opt@config\@nnil
\let\bbl at opt@main\@nnil
@@ -263,7 +280,7 @@
\fi}
\let\bbl at language@opts\@empty
\DeclareOption*{%
- \@expandtwoargs\in@{\string=}{\CurrentOption}%
+ \bbl at xin@{\string=}{\CurrentOption}%
\ifin@
\expandafter\bbl at tempa\CurrentOption\bbl at tempa
\else
@@ -284,7 +301,7 @@
\def\bbl at ifshorthand#1#2#3{#3}%
\else
\def\bbl at ifshorthand#1{%
- \@expandtwoargs\in@{\string#1}{\bbl at opt@shorthands}%
+ \bbl at xin@{\string#1}{\bbl at opt@shorthands}%
\ifin@
\expandafter\@firstoftwo
\else
@@ -390,7 +407,7 @@
\edef\bbl at tempa{\@classoptionslist,\bbl at language@opts}
\let\bbl at tempc\@empty
\bbl at for\bbl at tempb\bbl at tempa{%
- \@expandtwoargs\in@{,\bbl at tempb,}{,\bbl at loaded,}%
+ \bbl at xin@{,\bbl at tempb,}{,\bbl at loaded,}%
\ifin@\edef\bbl at tempc{\bbl at tempb}\fi}
\def\bbl at tempa#1,#2\@nnil{\def\bbl at tempb{#1}}
\expandafter\bbl at tempa\bbl at loaded,\@nnil
Modified: trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/hyphen.cfg 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 at format{\jobname}
\ifx\AtBeginDocument\@undefined
\def\@empty{}
@@ -67,7 +67,7 @@
\countdef\last at language=19
\def\addlanguage{\alloc at 9\language\chardef\@cclvi}
\fi
-\toks8{Babel <3.14> and hyphenation patterns for }%
+\toks8{Babel <3.15> and hyphenation patterns for }%
\def\process at line#1#2 #3 #4 {%
\ifx=#1%
\process at synonym{#2}%
Modified: trunk/Master/texmf-dist/tex/generic/babel/luababel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/luababel.def 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/luababel.def 2017-11-03 21:38:44 UTC (rev 45683)
@@ -251,7 +251,7 @@
\csname bbl at hyphendata@\the\language\endcsname}}{}%
\@ifundefined{bbl at patterns@}{}{%
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl at pttnlist}%
+ \bbl at xin@{,\number\language,}{,\bbl at pttnlist}%
\ifin@\else
\ifx\bbl at 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 at switchfont}
+\DisableBabelHook{babel-fontspec}
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl at tempa{#1}%
+ \def\bbl at tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl at bblfont}
+\newcommand\bbl at bblfont[2][]{% 1=features 2=fontname
+ \bbl at ifunset{\bbl at tempb family}{\bbl at providefam{\bbl at tempb}}{}%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \expandafter\bbl at ifblank\expandafter{\bbl at tempa}%
+ {\bbl at csarg\edef{\bbl at tempb dflt@}{<>{#1}{#2}}% save bbl at rmdflt@
+ \bbl at exp{%
+ \let\<bbl@\bbl at tempb dflt@\languagename>\<bbl@\bbl at tempb dflt@>%
+ \\\bbl at font@set\<bbl@\bbl at tempb dflt@\languagename>%
+ \<\bbl at tempb default>\<\bbl at tempb family>}}%
+ {\bbl at foreach\bbl at tempa{% ie bbl at rmdflt@lang / *scrt
+ \bbl at csarg\def{\bbl at tempb dflt@##1}{<>{#1}{#2}}}}}%
+\def\bbl at providefam#1{%
+ \bbl at exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl at add@list\\\bbl at font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not at math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+\def\bbl at switchfont{%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \bbl at exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl at tempa{\bbl at cs{sname@\languagename}}}}%
+ \bbl at foreach\bbl at font@fams{%
+ \bbl at ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl at ifunset{bbl@##1dflt@*\bbl at tempa}% (2) from script?
+ {\bbl at ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl at exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl at exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl at tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl at tempa{%
+ \bbl at warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl at foreach\bbl at font@fams{% don't gather with prev for
+ \bbl at ifunset{bbl@##1dflt@\languagename}%
+ {\bbl at cs{famrst@##1}%
+ \global\bbl at csarg\let{famrst@##1}\relax}%
+ {\bbl at exp{% order is relevant
+ \\\bbl at add\\\originalTeX{%
+ \\\bbl at font@rst{\bbl at cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl at font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl at ifrestoring{}{\bbl at tempa}}%
+\def\bbl at font@set#1#2#3{%
+ \bbl at xin@{<>}{#1}%
+ \ifin@
+ \bbl at exp{\\\bbl at fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl at exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl at rm1dflt@lang}
+ \\\bbl at ifsamestring{#2}{\f at family}{\\#3\let\\\bbl at tempa\relax}{}}}
+\def\bbl at fontspec@set#1#2#3{%
+ \bbl at exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl at cs{lsys@\languagename},#2}}{#3}%
+ \bbl at toglobal#1}%
+\def\bbl at provide@lsys#1{%
+ \bbl at ifunset{bbl at lname@#1}%
+ {\bbl at ini@ids{#1}}%
+ {}%
+ \bbl at csarg\let{lsys@#1}\@empty
+ \bbl at ifunset{bbl at sname@#1}{\bbl at csarg\gdef{sname@#1}{Default}}{}%
+ \bbl at ifunset{bbl at sotf#1}{\bbl at csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl at csarg\bbl at add@list{lsys@#1}{Script=\bbl at cs{sname@#1}}%
+ \bbl at ifunset{bbl at lname@#1}{}%
+ {\bbl at csarg\bbl at add@list{lsys@#1}{Language=\bbl at cs{lname@#1}}}%
+ \bbl at csarg\bbl at toglobal{lsys@#1}}%
+ % \bbl at exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl at cs{sname@#1}}%
+ % {\\\newfontscript{\bbl at cs{sname@#1}}{\bbl at cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl at cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl at cs{lname@#1}}{\bbl at cs{lotf@#1}}}}}
+\def\bbl at ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl at add\bbl at secpost@identification{%
+ \def\bbl at iniline########1\bbl at iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl at read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+\def\bbl at font@rst#1#2#3#4{%
+ \bbl at csarg\def{famrst@#4}{\bbl at font@set{#1}#2#3}}
+\def\bbl at font@fams{rm,sf,tt}
\newcommand\babelFSstore[2][]{%
\bbl at ifblank{#1}%
- {\bbl at csarg\def{script@#2}{Latin}}%
- {\bbl at csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts\bbl at rscripts}%
- \ifin@
+ {\bbl at csarg\def{sname@#2}{Latin}}%
+ {\bbl at csarg\def{sname@#2}{#1}}%
+ \bbl at provide@dirs{#2}%
+ \bbl at csarg\ifnum{wdir@#2}>\z@
\let\bbl at beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl at engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl at xebidipar
- \fi
- \else
- \ifcase\bbl at engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl at foreach{#2}{%
\bbl at FSstore{##1}{rm}\rmdefault\bbl at save@rmdefault
Modified: trunk/Master/texmf-dist/tex/generic/babel/nil.ldf
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/nil.ldf 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/nil.ldf 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 at nohyphenation\@undefined
\@nopatterns{nil}
Modified: trunk/Master/texmf-dist/tex/generic/babel/switch.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/switch.def 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/switch.def 2017-11-03 21:38:44 UTC (rev 45683)
@@ -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 at language=19
\def\addlanguage{\alloc at 9\language\chardef\@cclvi}
\fi
-\def\bbl at version{3.14}
-\def\bbl at date{2017/10/04}
+\def\bbl at version{3.15}
+\def\bbl at date{2017/11/03}
\def\adddialect#1#2{%
\global\chardef#1#2\relax
\bbl at usehooks{adddialect}{{#1}{#2}}%
@@ -102,9 +102,12 @@
\xdef\bbl at language@stack{\languagename+\bbl at language@stack}}
\def\bbl at pop@lang#1+#2-#3{%
\edef\languagename{#1}\xdef#3{#2}}
+\let\bbl at ifrestoring\@secondoftwo
\def\bbl at pop@language{%
\expandafter\bbl at pop@lang\bbl at language@stack-\bbl at language@stack
- \expandafter\bbl at set@language\expandafter{\languagename}}
+ \let\bbl at ifrestoring\@firstoftwo
+ \expandafter\bbl at set@language\expandafter{\languagename}%
+ \let\bbl at ifrestoring\@secondoftwo}
\expandafter\def\csname selectlanguage \endcsname#1{%
\ifnum\bbl at hymapsel=\@cclv\let\bbl at hymapsel\tw@\fi
\bbl at push@language
@@ -150,8 +153,15 @@
\bbl at usehooks{afterreset}{}%
\languageshorthands{none}%
\ifcase\bbl at select@type
- \csname captions#1\endcsname\relax
- \csname date#1\endcsname\relax
+ \ifhmode
+ \hskip\z at 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 at usehooks{beforeextras}{}%
\csname extras#1\endcsname\relax
@@ -242,7 +252,7 @@
\@expandtwoargs\bbl at usehooks{patterns}{{#1}{\bbl at tempa}}%
\@ifundefined{bbl at hyphenation@}{}{% Can be \relax!
\begingroup
- \@expandtwoargs\in@{,\number\language,}{,\bbl at hyphlist}%
+ \bbl at xin@{,\number\language,}{,\bbl at hyphlist}%
\ifin@\else
\@expandtwoargs\bbl at usehooks{hyphenation}{{#1}{\bbl at tempa}}%
\hyphenation{%
@@ -254,17 +264,14 @@
\fi
\endgroup}}
\def\hyphenrules#1{%
- \edef\languagename{#1}%
- \bbl at fixname\languagename
- \bbl at iflanguage\languagename{%
- \expandafter\bbl at patterns\expandafter{\languagename}%
+ \edef\bbl at tempf{#1}%
+ \bbl at fixname\bbl at tempf
+ \bbl at iflanguage\bbl at tempf{%
+ \expandafter\bbl at patterns\expandafter{\bbl at tempf}%
\languageshorthands{none}%
- \expandafter\ifx\csname\languagename hyphenmins\endcsname\relax
- \set at hyphenmins\tw@\thr@@\relax
- \else
- \expandafter\expandafter\expandafter\set at hyphenmins
- \csname\languagename hyphenmins\endcsname\relax
- \fi}}
+ \bbl at ifunset{\bbl at tempf hyphenmins}%
+ {\set at hyphenmins\tw@\thr@@\relax}%
+ {\bbl at exp{\\\set at hyphenmins\@nameuse{\bbl at tempf hyphenmins}}}}}
\let\endhyphenrules\@empty
\def\providehyphenmins#1#2{%
\expandafter\ifx\csname #1hyphenmins\endcsname\relax
Modified: trunk/Master/texmf-dist/tex/generic/babel/xebabel.def
===================================================================
--- trunk/Master/texmf-dist/tex/generic/babel/xebabel.def 2017-11-03 21:38:07 UTC (rev 45682)
+++ trunk/Master/texmf-dist/tex/generic/babel/xebabel.def 2017-11-03 21:38:44 UTC (rev 45683)
@@ -73,30 +73,116 @@
\L 00FF 0178 00FF
\endgroup
\input #1\relax}
+\ifx\DisableBabelHook\@undefined\endinput\fi
+\AddBabelHook{babel-fontspec}{afterextras}{\bbl at switchfont}
+\DisableBabelHook{babel-fontspec}
+\@onlypreamble\babelfont
+\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam
+ \edef\bbl at tempa{#1}%
+ \def\bbl at tempb{#2}%
+ \ifx\fontspec\@undefined
+ \usepackage{fontspec}%
+ \fi
+ \EnableBabelHook{babel-fontspec}%
+ \bbl at bblfont}
+\newcommand\bbl at bblfont[2][]{% 1=features 2=fontname
+ \bbl at ifunset{\bbl at tempb family}{\bbl at providefam{\bbl at tempb}}{}%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \expandafter\bbl at ifblank\expandafter{\bbl at tempa}%
+ {\bbl at csarg\edef{\bbl at tempb dflt@}{<>{#1}{#2}}% save bbl at rmdflt@
+ \bbl at exp{%
+ \let\<bbl@\bbl at tempb dflt@\languagename>\<bbl@\bbl at tempb dflt@>%
+ \\\bbl at font@set\<bbl@\bbl at tempb dflt@\languagename>%
+ \<\bbl at tempb default>\<\bbl at tempb family>}}%
+ {\bbl at foreach\bbl at tempa{% ie bbl at rmdflt@lang / *scrt
+ \bbl at csarg\def{\bbl at tempb dflt@##1}{<>{#1}{#2}}}}}%
+\def\bbl at providefam#1{%
+ \bbl at exp{%
+ \\\newcommand\<#1default>{}% Just define it
+ \\\bbl at add@list\\\bbl at font@fams{#1}%
+ \\\DeclareRobustCommand\<#1family>{%
+ \\\not at math@alphabet\<#1family>\relax
+ \\\fontfamily\<#1default>\\\selectfont}%
+ \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}}
+\def\bbl at switchfont{%
+ \bbl at ifunset{bbl at lsys@\languagename}{\bbl at provide@lsys{\languagename}}{}%
+ \bbl at exp{% eg Arabic -> arabic
+ \lowercase{\edef\\\bbl at tempa{\bbl at cs{sname@\languagename}}}}%
+ \bbl at foreach\bbl at font@fams{%
+ \bbl at ifunset{bbl@##1dflt@\languagename}% (1) language?
+ {\bbl at ifunset{bbl@##1dflt@*\bbl at tempa}% (2) from script?
+ {\bbl at ifunset{bbl@##1dflt@}% 2=F - (3) from generic?
+ {}% 123=F - nothing!
+ {\bbl at exp{% 3=T - from generic
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@>}}}%
+ {\bbl at exp{% 2=T - from script
+ \global\let\<bbl@##1dflt@\languagename>%
+ \<bbl@##1dflt@*\bbl at tempa>}}}%
+ {}}% 1=T - language, already defined
+ \def\bbl at tempa{%
+ \bbl at warning{The current font is not a standard family.\\%
+ Script and Language are not applied. Consider defining\\%
+ a new family with \string\babelfont,}}%
+ \bbl at foreach\bbl at font@fams{% don't gather with prev for
+ \bbl at ifunset{bbl@##1dflt@\languagename}%
+ {\bbl at cs{famrst@##1}%
+ \global\bbl at csarg\let{famrst@##1}\relax}%
+ {\bbl at exp{% order is relevant
+ \\\bbl at add\\\originalTeX{%
+ \\\bbl at font@rst{\bbl at cs{##1dflt@\languagename}}%
+ \<##1default>\<##1family>{##1}}%
+ \\\bbl at font@set\<bbl@##1dflt@\languagename>% the main part!
+ \<##1default>\<##1family>}}}%
+ \bbl at ifrestoring{}{\bbl at tempa}}%
+\def\bbl at font@set#1#2#3{%
+ \bbl at xin@{<>}{#1}%
+ \ifin@
+ \bbl at exp{\\\bbl at fontspec@set\\#1\expandafter\@gobbletwo#1}%
+ \fi
+ \bbl at exp{%
+ \def\\#2{#1}% eg, \rmdefault{\bbl at rm1dflt@lang}
+ \\\bbl at ifsamestring{#2}{\f at family}{\\#3\let\\\bbl at tempa\relax}{}}}
+\def\bbl at fontspec@set#1#2#3{%
+ \bbl at exp{\<fontspec_set_family:Nnn>\\#1%
+ {\bbl at cs{lsys@\languagename},#2}}{#3}%
+ \bbl at toglobal#1}%
+\def\bbl at provide@lsys#1{%
+ \bbl at ifunset{bbl at lname@#1}%
+ {\bbl at ini@ids{#1}}%
+ {}%
+ \bbl at csarg\let{lsys@#1}\@empty
+ \bbl at ifunset{bbl at sname@#1}{\bbl at csarg\gdef{sname@#1}{Default}}{}%
+ \bbl at ifunset{bbl at sotf#1}{\bbl at csarg\gdef{sotf@#1}{DFLT}}{}%
+ \bbl at csarg\bbl at add@list{lsys@#1}{Script=\bbl at cs{sname@#1}}%
+ \bbl at ifunset{bbl at lname@#1}{}%
+ {\bbl at csarg\bbl at add@list{lsys@#1}{Language=\bbl at cs{lname@#1}}}%
+ \bbl at csarg\bbl at toglobal{lsys@#1}}%
+ % \bbl at exp{% TODO - should be global
+ % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl at cs{sname@#1}}%
+ % {\\\newfontscript{\bbl at cs{sname@#1}}{\bbl at cs{sotf@#1}}}%
+ % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl at cs{lname@#1}}%
+ % {\\\newfontlanguage{\bbl at cs{lname@#1}}{\bbl at cs{lotf@#1}}}}}
+\def\bbl at ini@ids#1{%
+ \def\BabelBeforeIni##1##2{%
+ \begingroup
+ \bbl at add\bbl at secpost@identification{%
+ \def\bbl at iniline########1\bbl at iniline{}}%
+ \catcode`\[=12 \catcode`\]=12 \catcode`\==12
+ \bbl at read@ini{##1}%
+ \endgroup}
+ \InputIfFileExists{babel-#1.tex}{}{}}
+\def\bbl at font@rst#1#2#3#4{%
+ \bbl at csarg\def{famrst@#4}{\bbl at font@set{#1}#2#3}}
+\def\bbl at font@fams{rm,sf,tt}
\newcommand\babelFSstore[2][]{%
\bbl at ifblank{#1}%
- {\bbl at csarg\def{script@#2}{Latin}}%
- {\bbl at csarg\def{script@#2}{#1}}%
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts\bbl at rscripts}%
- \ifin@
+ {\bbl at csarg\def{sname@#2}{Latin}}%
+ {\bbl at csarg\def{sname@#2}{#1}}%
+ \bbl at provide@dirs{#2}%
+ \bbl at csarg\ifnum{wdir@#2}>\z@
\let\bbl at beforeforeign\leavevmode
\EnableBabelHook{babel-bidi}%
- \ifcase\bbl at engine\or
- \@expandtwoargs % TODO should go to the ini loaders
- \in@{\csname bbl at script@#2\endcsname}{\bbl at alscripts}%
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}%
- \or
- \bbl at xebidipar
- \fi
- \else
- \ifcase\bbl at engine\or
- \directlua{
- Babel.langdirs = Babel.langdirs or {}
- Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}%
- \fi
\fi
\bbl at foreach{#2}{%
\bbl at FSstore{##1}{rm}\rmdefault\bbl at save@rmdefault
More information about the tex-live-commits
mailing list