diff options
author | Karl Berry <karl@freefriends.org> | 2020-07-07 21:14:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2020-07-07 21:14:15 +0000 |
commit | 36c4eea55754443b823136f84cfcd6cb51ece0bf (patch) | |
tree | 2c88196cb8513a4c6cbd33ce53b344e274486fe5 /Master/texmf-dist/source/latex/babel/babel.dtx | |
parent | cbd59dbab4fb9c2903c44e15ba79b41b53ac0387 (diff) |
babel (7jul20)
git-svn-id: svn://tug.org/texlive/trunk@55774 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/babel/babel.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/babel/babel.dtx | 271 |
1 files changed, 158 insertions, 113 deletions
diff --git a/Master/texmf-dist/source/latex/babel/babel.dtx b/Master/texmf-dist/source/latex/babel/babel.dtx index 8ffa9a13601..736f7e25bf9 100644 --- a/Master/texmf-dist/source/latex/babel/babel.dtx +++ b/Master/texmf-dist/source/latex/babel/babel.dtx @@ -31,7 +31,7 @@ % % \iffalse %<*filedriver> -\ProvidesFile{babel.dtx}[2020/06/10 v3.45 The Babel package] +\ProvidesFile{babel.dtx}[2020/07/07 v3.46 The Babel package] \documentclass{ltxdoc} \GetFileInfo{babel.dtx} \usepackage{fontspec} @@ -1312,7 +1312,7 @@ _\babelprovide[import, main]{georgian}_ longer be valid when you read this manual, if the packages involved han been updated). The Harfbuzz renderer has still some issues, so as a rule of thumb prefer the default renderer, and resort to Harfbuzz - only if the former does work for you. Fortunately, fonts can be + only if the former does not work for you. Fortunately, fonts can be loaded twice with different renderers; for example: \begin{verbatim} \babelfont[spanish]{rm}{FreeSerif} @@ -2041,7 +2041,7 @@ also the package \textsf{combofont} for a complementary approach.} \Describe\babelfont{\oarg{language-list}\marg{font-family}% \oarg{font-options}\marg{font-name}} - + \begin{note} See the note in the previous section about some issues in specific languages. @@ -2452,6 +2452,13 @@ values of this locale; with |fonts|, the fonts are changed to those of this locale (as set with |\babelfont|). This option is not compatible with |mapfont|. Characters can be added with |\babelcharproperty|. +\begin{note} + An alternative approach with \luatex{} and Harfbuzz is the font + option |RawFeature={multiscript=auto}|. It does not switch the + \babel{} language and therefore the line breaking rules, but in many + cases it could be enough. +\end{note} + \Describe{mapfont=}{\texttt{direction}} Assigns the font for the writing direction of this language (only with |bidi=basic|). Whenever possible, instead of this option use |onchar|, @@ -2637,9 +2644,9 @@ be printed with the numeral style |digits|. date corresponding to the Gregorian calendar and other lunisolar systems with the following command. -\Describe{\localedate}{\o{calendar=.., variant=..}% - {\m{year}\m{month}\m{day}}} - +\Describe{\localedate}{\oarg{calendar=.., variant=..}% + {\marg{year}\m{month}\m{day}}} + By default the calendar is the Gregorian, but a |ini| files may define strings for other calendars (currently |ar|, |ar-|*, |he|, |fa|, |hi|.) In the latter case, the three arguments are the year, the month, and @@ -2677,8 +2684,8 @@ respectively. \Describe{\localeinfo}{\marg{field}} \New{3.38} If an |ini| file has been loaded for the current language, -you may access the information stored in it. This macros is fully -expandable and the available fields are: +you may access the information stored in it. This macro is fully +expandable, and the available fields are: \begin{description} \itemsep=-\parskip \item[|name.english|] as provided by the Unicode CLDR. @@ -2686,16 +2693,23 @@ expandable and the available fields are: %%% activated because the bug in \languagename is far from trivial. \item[|tag.ini|] is the tag of the |ini| file (the way this file is identified in its name). -\item[|tag.bcp47|] is the BCP 47 language tag. +\item[|tag.bcp47|] is the full BCP 47 tag (see the warning below). +\item[|language.tag.bcp47|] is the BCP 47 language tag. \item[|tag.opentype|] is the tag used by OpenType (usually, but not always, the same as BCP 47). -\item[|script.name|] as provided by the Unicode CLDR. -\item[|script.tag.bcp47|] is the BCP 47 language tag of the script +\item[|script.name|], as provided by the Unicode CLDR. +\item[|script.tag.bcp47|] is the BCP 47 tag of the script used by this locale. \item[|script.tag.opentype|] is the tag used by OpenType (usually, but not always, the same as BCP 47). \end{description} +\begin{warning} + \New{3.46} As of version 3.46 |tag.bcp47| returns the full BCP 47 + tag. Formerly it returned just the language subtag, which was clearly + counterintuitive. +\end{warning} + \Describe{\getlocaleproperty}{\marg{macro}\marg{locale}\marg{property}} \New{3.42} The value of any locale property as set by the |ini| files @@ -2976,6 +2990,18 @@ The behaviour is adjusted with |\babeladjust| with the following parameters: \texttt{bcp47-}. You may change it with this key. \end{description} +\New{3.46} If an |ldf| file has been loaded, you can enable the +corresponding language tags as selector names with: +\begin{verbatim} +\babeladjust{ bcp47.toname = on } +\end{verbatim} +(You can deactivate it with |off|.) So, if |dutch| is one of the +package (or class) options, you can write |\selectlanguage{nl}|. Note +the language name does not change (in this example is still |dutch|), +but you can get it with |\localeinfo| or |\getlanguageproperty|. It +must be turned on explicitly for similar reasons to those explained +above. + \subsection{Selecting scripts} Currently \babel{} provides no standard interface to select @@ -4656,8 +4682,8 @@ help from Bernd Raichle, for which I am grateful. % \section{Tools} % % \begin{macrocode} -%<<version=3.45>> -%<<date=2020/06/10>> +%<<version=3.46>> +%<<date=2020/07/07>> % \end{macrocode} % % \textbf{Do not use the following macros in \texttt{ldf} files. They @@ -10265,7 +10291,8 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@KVP@onchar\@nil \let\bbl@KVP@alph\@nil \let\bbl@KVP@Alph\@nil - \let\bbl@KVP@info\@nil % Ignored with import? Or error/warning? + \let\bbl@KVP@labels\@nil + \bbl@csarg\let{KVP@labels*}\@nil \bbl@forkv{#1}{% TODO - error handling \in@{/}{##1}% \ifin@ @@ -10279,7 +10306,7 @@ help from Bernd Raichle, for which I am grateful. {\ifx\bbl@initoload\relax \begingroup \def\BabelBeforeIni##1##2{\gdef\bbl@KVP@import{##1}\endinput}% - \InputIfFileExists{babel-#2.tex}{}{}% + \bbl@input@ini{#2}% \endgroup \else \xdef\bbl@KVP@import{\bbl@initoload}% @@ -10312,36 +10339,8 @@ help from Bernd Raichle, for which I am grateful. \\\bbl@toglobal\<bbl@ensure@\languagename\space>}% % At this point all parameters are defined if 'import'. Now we % execute some code depending on them. But what about if nothing was - % imported? We just load the very basic parameters: ids and a few - % more. - \bbl@ifunset{bbl@lname@#2}% TODO. Duplicated - {\def\BabelBeforeIni##1##2{% - \begingroup - \catcode`\[=12 \catcode`\]=12 \catcode`\==12 - \catcode`\;=12 \catcode`\|=12 % - \let\bbl@ini@captions@aux\@gobbletwo - \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}% - \bbl@read@ini{##1}{basic data}% - \bbl@exportkey{chrng}{characters.ranges}{}% - \bbl@exportkey{dgnat}{numbers.digits.native}{}% - \bbl@exportkey{prehc}{typography.prehyphenchar}{}% - \bbl@exportkey{lnbrk}{typography.linebreaking}{h}% - \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% - \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% - \bbl@exportkey{hyphr}{typography.hyphenrules}{}% - \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}% - \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}% - \bbl@exportkey{intsp}{typography.intraspace}{}% - \ifx\bbl@initoload\relax\endinput\fi - \endgroup}% - \begingroup % boxed, to avoid extra spaces: - \ifx\bbl@initoload\relax - \setbox\z@\hbox{\InputIfFileExists{babel-#2.tex}{}{}}% - \else - \setbox\z@\hbox{\BabelBeforeIni{\bbl@initoload}{}}% - \fi - \endgroup}% - {}% + % imported? We just load the very basic parameters. + \bbl@load@basic{#2}% % == script, language == % Override the values from ini or defines them \ifx\bbl@KVP@script\@nil\else @@ -10549,7 +10548,7 @@ help from Bernd Raichle, for which I am grateful. \let\BabelBeforeIni\@gobbletwo \chardef\atcatcode=\catcode`\@ \catcode`\@=11\relax - \InputIfFileExists{babel-\bbl@cs{rqtex@\languagename}.tex}{}{}% + \bbl@input@ini{\bbl@cs{rqtex@\languagename}}% \catcode`\@=\atcatcode \let\atcatcode\relax \fi}% @@ -10620,9 +10619,9 @@ help from Bernd Raichle, for which I am grateful. \expandafter\bbl@tempb\bbl@captionslist\@empty \else \ifx\bbl@initoload\relax - \bbl@read@ini{\bbl@KVP@captions}{data}% Here letters cat = 11 + \bbl@read@ini{\bbl@KVP@captions}0% Here letters cat = 11 \else - \bbl@read@ini{\bbl@initoload}{data}% Here all letters cat = 11 + \bbl@read@ini{\bbl@initoload}0% Here all letters cat = 11 \fi \bbl@after@ini \bbl@savestrings @@ -10636,33 +10635,7 @@ help from Bernd Raichle, for which I am grateful. \bbl@savedate \fi \bbl@endcommands - \bbl@ifunset{bbl@lname@#1}% TODO. Duplicated - {\def\BabelBeforeIni##1##2{% - \begingroup - \catcode`\[=12 \catcode`\]=12 \catcode`\==12 - \catcode`\;=12 \catcode`\|=12 % - \let\bbl@ini@captions@aux\@gobbletwo - \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}% - \bbl@read@ini{##1}{basic data}% - \bbl@exportkey{prehc}{typography.prehyphenchar}{}% - \bbl@exportkey{lnbrk}{typography.linebreaking}{h}% - \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% - \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% - \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}% - \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}% - \bbl@exportkey{intsp}{typography.intraspace}{}% - \bbl@exportkey{chrng}{characters.ranges}{}% - \bbl@exportkey{dgnat}{numbers.digits.native}{}% - \ifx\bbl@initoload\relax\endinput\fi - \endgroup}% - \begingroup % boxed, to avoid extra spaces: - \ifx\bbl@initoload\relax - \setbox\z@\hbox{\InputIfFileExists{babel-#1.tex}{}{}}% - \else - \setbox\z@\hbox{\BabelBeforeIni{\bbl@initoload}{}}% - \fi - \endgroup}% - {}% + \bbl@load@basic{#1}% \bbl@exp{% \gdef\<#1hyphenmins>{% {\bbl@ifunset{bbl@lfthm@#1}{2}{\bbl@cs{lfthm@#1}}}% @@ -10674,7 +10647,7 @@ help from Bernd Raichle, for which I am grateful. \def\bbl@provide@renew#1{% \ifx\bbl@KVP@captions\@nil\else \StartBabelCommands*{#1}{captions}% - \bbl@read@ini{\bbl@KVP@captions}{data}% Here all letters cat = 11 + \bbl@read@ini{\bbl@KVP@captions}0% Here all letters cat = 11 \bbl@after@ini \bbl@savestrings \EndBabelCommands @@ -10687,6 +10660,44 @@ help from Bernd Raichle, for which I am grateful. \fi % == hyphenrules == \bbl@provide@hyphens{#1}} +% Load the basic parameters (ids, typography, counters, and a few +% more), while captions and dates are left out. But it may happen some +% data has been loaded before automatically, so we first discard the +% saved values. +\def\bbl@load@basic#1{% + \bbl@ifunset{bbl@inidata@\languagename}{}% + {\getlocaleproperty\bbl@tempa{\languagename}{identification/load.level}% + \ifcase\bbl@tempa\else + \bbl@csarg\let{lname@\languagename}\relax + \fi}% + \bbl@ifunset{bbl@lname@#1}% + {\def\BabelBeforeIni##1##2{% + \begingroup + \catcode`\[=12 \catcode`\]=12 \catcode`\==12 + \catcode`\;=12 \catcode`\|=12 % + \let\bbl@ini@captions@aux\@gobbletwo + \def\bbl@inidate ####1.####2.####3.####4\relax ####5####6{}% + \bbl@read@ini{##1}0% + \bbl@exportkey{prehc}{typography.prehyphenchar}{}% + \bbl@exportkey{lnbrk}{typography.linebreaking}{h}% + \bbl@exportkey{lfthm}{typography.lefthyphenmin}{2}% + \bbl@exportkey{rgthm}{typography.righthyphenmin}{3}% + \bbl@exportkey{hyphr}{typography.hyphenrules}{}% + \bbl@exportkey{hyotl}{typography.hyphenate.other.locale}{}% + \bbl@exportkey{hyots}{typography.hyphenate.other.script}{}% + \bbl@exportkey{intsp}{typography.intraspace}{}% + \bbl@exportkey{chrng}{characters.ranges}{}% + \bbl@exportkey{dgnat}{numbers.digits.native}{}% + \ifx\bbl@initoload\relax\endinput\fi + \endgroup}% + \begingroup % boxed, to avoid extra spaces: + \ifx\bbl@initoload\relax + \bbl@input@ini{#1}% + \else + \setbox\z@\hbox{\BabelBeforeIni{\bbl@initoload}{}}% + \fi + \endgroup}% + {}} % \end{macrocode} % % The |hyphenrules| option is handled with an auxiliary macro. @@ -10737,6 +10748,8 @@ help from Bernd Raichle, for which I am grateful. \ifx\bbl@readstream\@undefined \csname newread\endcsname\bbl@readstream \fi +\def\bbl@input@ini#1{% + \bbl@exp{\lowercase{\\\InputIfFileExists{babel-#1.tex}{}{}}}} \def\bbl@inipreread#1=#2\@@{% \bbl@trim@def\bbl@tempa{#1}% Redundant below !! \bbl@trim\toks@{#2}% @@ -10757,14 +10770,18 @@ help from Bernd Raichle, for which I am grateful. is not complete.}% {Fix the name or reinstall babel.}% \else - \bbl@exp{\def\\\bbl@inidata{\\\bbl@elt{identificacion}{tag.ini}{#1}}}% + \bbl@exp{\def\\\bbl@inidata{% + \\\bbl@elt{identification}{tag.ini}{#1}% + \\\bbl@elt{identification}{load.level}{#2}}}% \let\bbl@section\@empty \let\bbl@savestrings\@empty \let\bbl@savetoday\@empty \let\bbl@savedate\@empty \let\bbl@inireader\bbl@iniskip - \bbl@info{Importing #2 for \languagename\\% - from babel-#1.ini. Reported}% + \bbl@info{Importing + \ifcase#2 \or font and identification \or basic \fi + data for \languagename\\% + from babel-#1.ini. Reported}% \loop \if T\ifeof\bbl@readstream F\fi T\relax % Trick, because inside \loop \endlinechar\m@ne @@ -10898,13 +10915,16 @@ help from Bernd Raichle, for which I am grateful. \bbl@exportkey{elname}{identification.name.english}{}% \bbl@exp{\\\bbl@exportkey{lname}{identification.name.opentype}% {\csname bbl@elname@\languagename\endcsname}}% - \bbl@exportkey{lbcp}{identification.tag.bcp47}{}% + \bbl@exportkey{lbcp}{identification.tag.bcp47}{}% TODO \bbl@exportkey{lotf}{identification.tag.opentype}{dflt}% \bbl@exportkey{esname}{identification.script.name}{}% \bbl@exp{\\\bbl@exportkey{sname}{identification.script.name.opentype}% {\csname bbl@esname@\languagename\endcsname}}% \bbl@exportkey{sbcp}{identification.script.tag.bcp47}{}% - \bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}} + \bbl@exportkey{sotf}{identification.script.tag.opentype}{DFLT}% + \ifbbl@bcptoname + \bbl@csarg\xdef{bcp@map@\bbl@cl{lbcp}}{\languagename}% + \fi} \let\bbl@inikv@typography\bbl@inikv \let\bbl@inikv@characters\bbl@inikv \let\bbl@inikv@numbers\bbl@inikv @@ -11056,7 +11076,7 @@ help from Bernd Raichle, for which I am grateful. % \begin{macrocode} \let\bbl@calendar\@empty \newcommand\BabelDateSpace{\nobreakspace} -\newcommand\BabelDateDot{.\@} +\newcommand\BabelDateDot{.\@} % TODO. \let instead of repeating \newcommand\BabelDated[1]{{\number#1}} \newcommand\BabelDatedd[1]{{\ifnum#1<10 0\fi\number#1}} \newcommand\BabelDateM[1]{{\number#1}} @@ -11095,7 +11115,8 @@ help from Bernd Raichle, for which I am grateful. % Note after \bbl@replace \toks@ contains the resulting string. % TODO - Using this implicit behavior doesn't seem a good idea. \bbl@replace@finish@iii\bbl@toreplace} -\def\bbl@datecntr[#1|#2]{\localenumeral{#2}{#1}} +\def\bbl@datecntr{\expandafter\bbl@xdatecntr\expandafter} +\def\bbl@xdatecntr[#1|#2]{\localenumeral{#2}{#1}} % \end{macrocode} % % Language and Script values to be used when defining a font or @@ -11116,9 +11137,40 @@ help from Bernd Raichle, for which I am grateful. \bbl@ifunset{bbl@prehc@#1}{}% {\bbl@exp{\\\bbl@ifblank{\bbl@cs{prehc@#1}}}% {}% - {\bbl@csarg\bbl@add@list{lsys@#1}{HyphenChar="200B}}}% + {\ifx\bbl@xenohyph\@undefined + \let\bbl@xenohyph\bbl@xenohyph@d + \ifx\AtBeginDocument\@notprerr + \expandafter\@secondoftwo % to execute right now + \fi + \AtBeginDocument{% + \expandafter\bbl@add + \csname selectfont \endcsname{\bbl@xenohyph}% + \expandafter\selectlanguage\expandafter{\languagename}% + \expandafter\bbl@toglobal\csname selectfont \endcsname}% + \fi}}% \fi \bbl@csarg\bbl@toglobal{lsys@#1}} +\def\bbl@ifset#1#2#3{% TODO. Move to the correct place. + \bbl@ifunset{#1}{#3}{\bbl@exp{\\\bbl@ifblank{#1}}{#3}{#2}}} +\def\bbl@xenohyph@d{% + \bbl@ifset{bbl@prehc@\languagename}% + {\ifnum\hyphenchar\font=\defaulthyphenchar + \iffontchar\font\bbl@cl{prehc}\relax + \hyphenchar\font\bbl@cl{prehc}\relax + \else\iffontchar\font"200B + \hyphenchar\font"200B + \else + \bbl@error + {Neither 0 nor ZERO WIDTH SPACE are available\\% + in the current font, and therefore the hyphen\\% + will be printed. Try with 'HyphenChar', but be\\% + aware this setting is not safe (see the manual).}% + {See the manual.}% + \hyphenchar\font\defaulthyphenchar + \fi\fi + \fi}% + {\hyphenchar\font\defaulthyphenchar}} + % \fi} % \end{macrocode} % % The following |ini| reader ignores everything but the @@ -11136,10 +11188,10 @@ help from Bernd Raichle, for which I am grateful. \bbl@add\bbl@secpost@identification{\closein\bbl@readstream }% \catcode`\[=12 \catcode`\]=12 \catcode`\==12 \catcode`\;=12 \catcode`\|=12 % - \bbl@read@ini{##1}{font and identification data}% + \bbl@read@ini{##1}1% \endinput % babel- .tex may contain onlypreamble's \endgroup}% boxed, to avoid extra spaces: - {\setbox\z@\hbox{\InputIfFileExists{babel-#1.tex}{}{}}}} + {\bbl@input@ini{#1}}} % \end{macrocode} % % Alphabetic counters must be converted from a space separated list to @@ -11212,18 +11264,21 @@ help from Bernd Raichle, for which I am grateful. \@namedef{bbl@info@tag.ini}{lini} \@namedef{bbl@info@name.english}{elname} \@namedef{bbl@info@name.opentype}{lname} -\@namedef{bbl@info@tag.bcp47}{lbcp} -\@namedef{bbl@info@tag.opentype}{lotf} +\@namedef{bbl@info@tag.bcp47}{lbcp} % TODO +\@namedef{bbl@info@tag.opentype}{lotf} \@namedef{bbl@info@script.name}{esname} \@namedef{bbl@info@script.name.opentype}{sname} \@namedef{bbl@info@script.tag.bcp47}{sbcp} \@namedef{bbl@info@script.tag.opentype}{sotf} \let\bbl@ensureinfo\@gobble \newcommand\BabelEnsureInfo{% - \def\bbl@ensureinfo##1{% - \ifx\InputIfFileExists\@undefined\else % not in plain - \bbl@ifunset{bbl@lname@##1}{\bbl@ini@basic{##1}}{}% - \fi}} + \ifx\InputIfFileExists\@undefined\else + \def\bbl@ensureinfo##1{% + \bbl@ifunset{bbl@lname@##1}{\bbl@ini@basic{##1}}{}}% + \fi + \bbl@foreach\bbl@loaded{{% + \def\languagename{##1}% + \bbl@ensureinfo{##1}}}} % \end{macrocode} % % More general, but non-expandable, is |\getlocaleproperty|. To inspect @@ -11247,6 +11302,7 @@ help from Bernd Raichle, for which I am grateful. \string#1 will be set to \relax}% {Perhaps you misspelled it.}% \fi} +\let\bbl@ini@loaded\@empty \newcommand\LocaleForEach{\bbl@foreach\bbl@ini@loaded} % \end{macrocode} % @@ -11327,6 +11383,13 @@ help from Bernd Raichle, for which I am grateful. \let\bbl@autoload@bcpoptions\@empty \@namedef{bbl@ADJ@autoload.bcp47.options}#1{% \def\bbl@autoload@bcpoptions{#1}} +\newif\ifbbl@bcptoname +\@namedef{bbl@ADJ@bcp47.toname@on}{% + \bbl@bcptonametrue + \BabelEnsureInfo + } +\@namedef{bbl@ADJ@bcp47.toname@off}{% + \bbl@bcptonamefalse} % TODO: use babel name, override % % As the final task, load the code for lua. @@ -21278,27 +21341,9 @@ Babel.cjk_breaks = { }% } % -\def\UseTextSymbol#1#2{% -% \let\@curr@enc\cf@encoding -% \@use@text@encoding{#1}% - #2% -% \@use@text@encoding\@curr@enc -} -\def\UseTextAccent#1#2#3{% -% \let\@curr@enc\cf@encoding -% \@use@text@encoding{#1}% -% #2{\@use@text@encoding\@curr@enc\selectfont#3}% -% \@use@text@encoding\@curr@enc -} -\def\@use@text@encoding#1{% -% \edef\f@encoding{#1}% -% \xdef\font@name{% -% \csname\curr@fontshape/\f@size\endcsname -% }% -% \pickup@font -% \font@name -% \@@enc@update -} +\def\UseTextSymbol#1#2{#2} +\def\UseTextAccent#1#2#3{} +\def\@use@text@encoding#1{} \def\DeclareTextSymbolDefault#1#2{% \DeclareTextCommandDefault#1{\UseTextSymbol{#2}#1}% } |