diff options
author | Karl Berry <karl@freefriends.org> | 2017-11-03 21:38:44 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-11-03 21:38:44 +0000 |
commit | 753ccf29ee3c32686dbe1cb4ada792d0f26ec429 (patch) | |
tree | 9a9c511a29d95c90ead813a096e17b7249a002a9 /Master/texmf-dist/tex | |
parent | e4d8f7684792e7652b447e6ad94b82ca72886fe3 (diff) |
babel (3nov17)
git-svn-id: svn://tug.org/texlive/trunk@45683 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel.def | 79 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/babel.sty | 27 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/hyphen.cfg | 4 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/luababel.def | 128 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/nil.ldf | 2 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/switch.def | 41 | ||||
-rw-r--r-- | Master/texmf-dist/tex/generic/babel/xebabel.def | 126 |
8 files changed, 329 insertions, 107 deletions
diff --git a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua index 2f80775609e..fab6721456a 100644 --- a/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua +++ b/Master/texmf-dist/tex/generic/babel/babel-bidi-basic-r.lua @@ -33,8 +33,6 @@ -- Babel = Babel or {} -Babel.langdirs = {} - require('babel-bidi.lua') local characters = Babel.characters @@ -53,11 +51,10 @@ local function dir_mark(head, from, to, outer) end function Babel.pre_otfload(head) - local first_n, last_n = nil, nil -- first and last char with nums - local last_es = nil -- an auxiliary 'last' used with nums - local first_d, last_d = nil, nil -- first and last char in L/R block - local dir = nil - local dir_real = nil + local first_n, last_n -- first and last char with nums + local last_es -- an auxiliary 'last' used with nums + local first_d, last_d -- first and last char in L/R block + local dir, dir_real local strong = ('TRT' == tex.pardir) and 'r' or 'l' local strong_lr = (strong == 'l') and 'l' or 'r' local outer = strong @@ -65,7 +62,7 @@ function Babel.pre_otfload(head) local new_dir = false local first_dir = false - local last_lr = nil + local last_lr local type_n = '' @@ -88,7 +85,20 @@ function Babel.pre_otfload(head) end dir = dir or 'l' if new_dir then - strong = Babel.langdirs[item.lang] or 'l' + attr_dir = 0 + for at in node.traverse(item.attr) do + if at.number == luatexbase.registernumber'bbl@attr@dir' then + attr_dir = at.value + end + end + texio.write_nl(attr_dir) + if attr_dir == 1 then + strong = 'r' + elseif attr_dir == 2 then + strong = 'al' + else + strong = 'l' + end strong_lr = (strong == 'l') and 'l' or 'r' outer = strong_lr new_dir = false @@ -151,7 +161,6 @@ function Babel.pre_otfload(head) ch.char = characters[ch.char].m or ch.char end end - --last_lr = nil end end if dir == 'l' or dir == 'r' then diff --git a/Master/texmf-dist/tex/generic/babel/babel.def b/Master/texmf-dist/tex/generic/babel/babel.def index 6db9b31282e..cd6e92b3584 100644 --- a/Master/texmf-dist/tex/generic/babel/babel.def +++ b/Master/texmf-dist/tex/generic/babel/babel.def @@ -40,7 +40,7 @@ \wlog{File: #1 #4 #3 <#2>}% \let\ProvidesFile\@undefined} \fi -\ProvidesFile{babel.def}[2017/10/04 3.14 Babel common definitions] +\ProvidesFile{babel.def}[2017/11/03 3.15 Babel common definitions] \ifx\AtBeginDocument\@undefined \input plain.def\relax \fi @@ -83,7 +83,9 @@ \bbl@ifunset{\bbl@stripslash#1}% {\def#1{#2}}% {\expandafter\def\expandafter#1\expandafter{#1#2}}} +\def\bbl@xin@{\@expandtwoargs\in@} \def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}% +\def\bbl@cs#1{\csname bbl@#1\endcsname} \def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,} \def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}} \def\bbl@@loop#1#2#3,{% @@ -688,7 +690,7 @@ \ifx\bbl@known@attribs\@undefined \in@false \else - \@expandtwoargs\in@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}% + \bbl@xin@{,\bbl@tempc-##1,}{,\bbl@known@attribs,}% \fi \ifin@ \bbl@warning{% @@ -708,7 +710,7 @@ {The attribute #2 is unknown for language #1.}% {Your command will be ignored, type <return> to proceed}} \def\bbl@declare@ttribute#1#2#3{% - \@expandtwoargs\in@{,#2,}{,\BabelModifiers,}% + \bbl@xin@{,#2,}{,\BabelModifiers,}% \ifin@ \AfterBabelLanguage{#1}{\languageattribute{#1}{#2}}% \fi @@ -718,7 +720,7 @@ \ifx\bbl@known@attribs\@undefined \in@false \else - \@expandtwoargs\in@{,#1-#2,}{,\bbl@known@attribs,}% + \bbl@xin@{,#1-#2,}{,\bbl@known@attribs,}% \fi \ifin@ \bbl@afterelse#3% @@ -952,8 +954,7 @@ \expandafter \bbl@toglobal\csname####1\string##1\endcsname}}}% \def\bbl@sctest{% - \@expandtwoargs - \in@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}% + \bbl@xin@{,\bbl@opt@strings,}{,\bbl@sc@label,\bbl@sc@fontenc,}}% \fi \ifx\bbl@opt@strings\@nnil % ie, no strings key -> defaults \else\ifx\bbl@opt@strings\relax % ie, strings=encoded @@ -982,14 +983,14 @@ \fi} \def\bbl@forlang#1#2{% \bbl@for#1\bbl@L{% - \@expandtwoargs\in@{,#1,}{,\BabelLanguages,}% + \bbl@xin@{,#1,}{,\BabelLanguages,}% \ifin@#2\relax\fi}} \def\bbl@scswitch{% \bbl@forlang\bbl@tempa{% \ifx\bbl@G\@empty\else \ifx\SetString\@gobbletwo\else \edef\bbl@GL{\bbl@G\bbl@tempa}% - \@expandtwoargs\in@{,\bbl@GL,}{,\bbl@screset,}% + \bbl@xin@{,\bbl@GL,}{,\bbl@screset,}% \ifin@\else \global\expandafter\let\csname\bbl@GL\endcsname\@undefined \xdef\bbl@screset{\bbl@screset,\bbl@GL}% @@ -1065,7 +1066,7 @@ \bbl@tempa} \AtEndOfPackage{% \ifx\bbl@opt@hyphenmap\@undefined - \@expandtwoargs\in@{,}{\bbl@language@opts}% + \bbl@xin@{,}{\bbl@language@opts}% \chardef\bbl@opt@hyphenmap\ifin@4\else\@ne\fi \fi} \def\set@low@box#1{\setbox\tw@\hbox{,}\setbox\z@\hbox{#1}% @@ -1259,6 +1260,9 @@ \let\bbl@KVP@captions\@nil \let\bbl@KVP@import\@nil \let\bbl@KVP@main\@nil + \let\bbl@KVP@script\@nil + \let\bbl@KVP@language\@nil + \let\bbl@KVP@dir\@nil \let\bbl@KVP@hyphenrules\@nil \bbl@forkv{#1}{\bbl@csarg\def{KVP@##1}{##2}}% TODO - error handling \ifx\bbl@KVP@captions\@nil @@ -1275,6 +1279,12 @@ {Use this macro as documented}}% {\bbl@provide@renew{#2}}}% \bbl@exp{\\\babelensure[exclude=\\\today]{#2}}% + \ifx\bbl@KVP@script\@nil\else + \bbl@csarg\edef{sname@#2}{\bbl@KVP@script}% + \fi + \ifx\bbl@KVP@language\@nil\else + \bbl@csarg\edef{lname@#2}{\bbl@KVP@language}% + \fi \let\languagename\bbl@savelangname} \def\bbl@provide@new#1{% \@namedef{date#1}{}% marks lang exists - required by \StartBabelCommands @@ -1346,14 +1356,14 @@ \bbl@exp{% and hyphenrules is not empty \\\bbl@ifblank{\@nameuse{bbl@hyphr@#1}}% {}% - {\\\adddialect\<l@#1>\<l@\@nameuse{bbl@hyphr@\languagename}>}}% + {\let\\\bbl@tempa\<l@\@nameuse{bbl@hyphr@\languagename}>}}% \fi - \bbl@ifunset{l@#1}% no hyphenrules found - fallback - {\bbl@exp{\\\adddialect\<l@#1>\language}}% - {}% - \else - \bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}% found in opt list - \fi} + \fi + \bbl@ifunset{bbl@tempa}% ie, relax or undefined + {\bbl@ifunset{l@#1}% no hyphenrules found - fallback + {\bbl@exp{\\\adddialect\<l@#1>\language}}% + {}}% so, l@<lang> is ok - nothing to do + {\bbl@exp{\\\adddialect\<l@#1>\bbl@tempa}}}% found in opt list or ini \def\bbl@read@ini#1{% \openin1=babel-#1.ini \ifeof1 @@ -1532,7 +1542,7 @@ \@tempswatrue \fi} \fi -\@expandtwoargs\in@{R}\bbl@opt@safe +\bbl@xin@{R}\bbl@opt@safe \ifin@ \bbl@redefinerobust\ref#1{% \@safe@activestrue\org@ref{#1}\@safe@activesfalse} @@ -1542,7 +1552,7 @@ \let\org@ref\ref \let\org@pageref\pageref \fi -\@expandtwoargs\in@{B}\bbl@opt@safe +\bbl@xin@{B}\bbl@opt@safe \ifin@ \bbl@redefine\@citex[#1]#2{% \@safe@activestrue\edef\@tempa{#2}\@safe@activesfalse @@ -1602,7 +1612,7 @@ {\@temptokena\expandafter{\bbl@tempb{#2}}}% \bbl@exp{\\\org@markboth{\the\toks@}{\the\@temptokena}}} \bbl@tempc -\@expandtwoargs\in@{R}\bbl@opt@safe +\bbl@xin@{R}\bbl@opt@safe \ifin@ \AtBeginDocument{% \@ifpackageloaded{ifthen}{% @@ -1681,7 +1691,7 @@ \in@false \bbl@foreach\BabelNonASCII{% is there a non-ascii enc? \ifin@\else - \lowercase{\@expandtwoargs\in@{,#1enc.def,}{,\@filelist,}}% + \lowercase{\bbl@xin@{,#1enc.def,}{,\@filelist,}}% \fi}% \ifin@ % if a non-ascii has been loaded \def\ensureascii#1{{\fontencoding{OT1}\selectfont#1}}% @@ -1692,7 +1702,7 @@ \ifx\@empty#2\else \bbl@ifunset{T@#1}% {}% - {\@expandtwoargs\in@{,#1,}{,\BabelNonASCII,}% + {\bbl@xin@{,#1,}{,\BabelNonASCII,}% \ifin@ \DeclareTextCommand{\TeX}{#1}{\ensureascii{\org@TeX}}% \DeclareTextCommand{\LaTeX}{#1}{\ensureascii{\org@LaTeX}}% @@ -1701,7 +1711,7 @@ \fi}% \fi}% \bbl@foreach\@filelist{\bbl@tempb#1\@@}% TODO - \@@ de mas?? - \@expandtwoargs\in@{,\cf@encoding,}{,\BabelNonASCII,}% + \bbl@xin@{,\cf@encoding,}{,\BabelNonASCII,}% \ifin@\else \edef\ensureascii#1{{% \noexpand\fontencoding{\cf@encoding}\noexpand\selectfont#1}}% @@ -1738,15 +1748,20 @@ Nabataean,N'Ko,Orkhon,Palmyrene,Inscriptional Pahlavi,% Psalter Pahlavi,Phoenician,Inscriptional Parthian,Samaritan,% Old South Arabian,}% -\def\bbl@ensuredir{% - \@expandtwoargs - \in@{\csname bbl@script@\languagename\endcsname}% - {\bbl@alscripts\bbl@rscripts}% +\def\bbl@provide@dirs#1{% + \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts\bbl@rscripts}% \ifin@ - \bbl@setdirs\@ne + \global\bbl@csarg\chardef{wdir@#1}\@ne + \bbl@xin@{\csname bbl@sname@#1\endcsname}{\bbl@alscripts}% + \ifin@ + \global\bbl@csarg\chardef{wdir@#1}\tw@ % useless in xetex + \fi \else - \bbl@setdirs\z@ + \global\bbl@csarg\chardef{wdir@#1}\z@ \fi} +\def\bbl@switchdir{% + \bbl@ifunset{bbl@wdir@\languagename}{\bbl@provide@dirs{\languagename}}{}% + \bbl@exp{\\\bbl@setdirs\bbl@cs{wdir@\languagename}}} \def\bbl@setdirs#1{% TODO - math \ifcase\bbl@select@type % TODO - strictly, not the right test \bbl@pagedir{#1}% @@ -1756,7 +1771,7 @@ \bbl@textdir{#1}} \ifcase\bbl@engine \or - \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir} + \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir} \DisableBabelHook{babel-bidi} \def\bbl@getluadir#1{% \directlua{ @@ -1775,13 +1790,15 @@ #2 TRT\relax \fi \fi} - \def\bbl@textdir{\bbl@setdir{text}\textdir}% TODO - ?\linedir + \def\bbl@textdir#1{% + \bbl@setdir{text}\textdir{#1}% TODO - ?\linedir + \setattribute\bbl@attr@dir{#1}} \def\bbl@pardir{\bbl@setdir{par}\pardir} \def\bbl@bodydir{\bbl@setdir{body}\bodydir} \def\bbl@pagedir{\bbl@setdir{page}\pagedir} \def\bbl@dirparastext{\pardir\the\textdir\relax}% %%%% \or - \AddBabelHook{babel-bidi}{afterextras}{\bbl@ensuredir} + \AddBabelHook{babel-bidi}{afterextras}{\bbl@switchdir} \DisableBabelHook{babel-bidi} \newcount\bbl@dirlevel \chardef\bbl@thetextdir\z@ diff --git a/Master/texmf-dist/tex/generic/babel/babel.sty b/Master/texmf-dist/tex/generic/babel/babel.sty index d1d3e3c9752..c5ce24b584f 100644 --- a/Master/texmf-dist/tex/generic/babel/babel.sty +++ b/Master/texmf-dist/tex/generic/babel/babel.sty @@ -32,7 +32,7 @@ %% extension |.ins|) which are part of the distribution. %% \NeedsTeXFormat{LaTeX2e}[2005/12/01] -\ProvidesPackage{babel}[2017/10/04 3.14 The Babel package] +\ProvidesPackage{babel}[2017/11/03 3.15 The Babel package] \@ifpackagewith{babel}{debug} {\let\bbl@debug\@firstofone} {\let\bbl@debug\@gobble} @@ -47,7 +47,9 @@ \bbl@ifunset{\bbl@stripslash#1}% {\def#1{#2}}% {\expandafter\def\expandafter#1\expandafter{#1#2}}} +\def\bbl@xin@{\@expandtwoargs\in@} \def\bbl@csarg#1#2{\expandafter#1\csname bbl@#2\endcsname}% +\def\bbl@cs#1{\csname bbl@#1\endcsname} \def\bbl@loop#1#2#3{\bbl@@loop#1{#3}#2,\@nnil,} \def\bbl@loopx#1#2{\expandafter\bbl@loop\expandafter#1\expandafter{#2}} \def\bbl@@loop#1#2#3,{% @@ -178,6 +180,8 @@ \bbl@languages \fi \@ifpackagewith{babel}{bidi=basic-r}{% must go before any \DeclareOption + \let\bbl@beforeforeign\leavevmode + \AtEndOfPackage{\EnableBabelHook{babel-bidi}}% \RequirePackage{luatexbase}% \directlua{ require('babel-bidi.lua') @@ -246,7 +250,20 @@ \DeclareOption{safe=none}{\let\bbl@opt@safe\@empty} \DeclareOption{safe=bib}{\def\bbl@opt@safe{B}} \DeclareOption{safe=ref}{\def\bbl@opt@safe{R}} -\DeclareOption{bidi=basic-r}{} +\DeclareOption{bidi=basic-r}% + {\newattribute\bbl@attr@dir + \let\bbl@beforeforeign\leavevmode + \AtEndOfPackage{\EnableBabelHook{babel-bidi}}} +\DeclareOption{bidi=default}% + {\let\bbl@beforeforeign\leavevmode + \ifcase\bbl@engine\or + \newattribute\bbl@attr@dir + \fi + \AtEndOfPackage{% + \EnableBabelHook{babel-bidi}% + \ifcase\bbl@engine\or\or + \bbl@xebidipar + \fi}} \let\bbl@opt@shorthands\@nnil \let\bbl@opt@config\@nnil \let\bbl@opt@main\@nnil @@ -263,7 +280,7 @@ \fi} \let\bbl@language@opts\@empty \DeclareOption*{% - \@expandtwoargs\in@{\string=}{\CurrentOption}% + \bbl@xin@{\string=}{\CurrentOption}% \ifin@ \expandafter\bbl@tempa\CurrentOption\bbl@tempa \else @@ -284,7 +301,7 @@ \def\bbl@ifshorthand#1#2#3{#3}% \else \def\bbl@ifshorthand#1{% - \@expandtwoargs\in@{\string#1}{\bbl@opt@shorthands}% + \bbl@xin@{\string#1}{\bbl@opt@shorthands}% \ifin@ \expandafter\@firstoftwo \else @@ -390,7 +407,7 @@ \edef\bbl@tempa{\@classoptionslist,\bbl@language@opts} \let\bbl@tempc\@empty \bbl@for\bbl@tempb\bbl@tempa{% - \@expandtwoargs\in@{,\bbl@tempb,}{,\bbl@loaded,}% + \bbl@xin@{,\bbl@tempb,}{,\bbl@loaded,}% \ifin@\edef\bbl@tempc{\bbl@tempb}\fi} \def\bbl@tempa#1,#2\@nnil{\def\bbl@tempb{#1}} \expandafter\bbl@tempa\bbl@loaded,\@nnil diff --git a/Master/texmf-dist/tex/generic/babel/hyphen.cfg b/Master/texmf-dist/tex/generic/babel/hyphen.cfg index 1dc995bb4a1..2a78efdda22 100644 --- a/Master/texmf-dist/tex/generic/babel/hyphen.cfg +++ b/Master/texmf-dist/tex/generic/babel/hyphen.cfg @@ -36,7 +36,7 @@ \wlog{File: #1 #4 #3 <#2>}% \let\ProvidesFile\@undefined} \fi -\ProvidesFile{hyphen.cfg}[2017/10/04 3.14 Babel hyphens] +\ProvidesFile{hyphen.cfg}[2017/11/03 3.15 Babel hyphens] \xdef\bbl@format{\jobname} \ifx\AtBeginDocument\@undefined \def\@empty{} @@ -67,7 +67,7 @@ \countdef\last@language=19 \def\addlanguage{\alloc@9\language\chardef\@cclvi} \fi -\toks8{Babel <3.14> and hyphenation patterns for }% +\toks8{Babel <3.15> and hyphenation patterns for }% \def\process@line#1#2 #3 #4 {% \ifx=#1% \process@synonym{#2}% diff --git a/Master/texmf-dist/tex/generic/babel/luababel.def b/Master/texmf-dist/tex/generic/babel/luababel.def index 7cbba864d1a..0ffb8d44cad 100644 --- a/Master/texmf-dist/tex/generic/babel/luababel.def +++ b/Master/texmf-dist/tex/generic/babel/luababel.def @@ -251,7 +251,7 @@ \csname bbl@hyphendata@\the\language\endcsname}}{}% \@ifundefined{bbl@patterns@}{}{% \begingroup - \@expandtwoargs\in@{,\number\language,}{,\bbl@pttnlist}% + \bbl@xin@{,\number\language,}{,\bbl@pttnlist}% \ifin@\else \ifx\bbl@patterns@\@empty\else \directlua{ Babel.addpatterns( @@ -332,30 +332,116 @@ \L 00FF 0178 00FF \endgroup \input #1\relax} +\ifx\DisableBabelHook\@undefined\endinput\fi +\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} +\DisableBabelHook{babel-fontspec} +\@onlypreamble\babelfont +\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam + \edef\bbl@tempa{#1}% + \def\bbl@tempb{#2}% + \ifx\fontspec\@undefined + \usepackage{fontspec}% + \fi + \EnableBabelHook{babel-fontspec}% + \bbl@bblfont} +\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname + \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}% + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \expandafter\bbl@ifblank\expandafter{\bbl@tempa}% + {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@ + \bbl@exp{% + \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>% + \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>% + \<\bbl@tempb default>\<\bbl@tempb family>}}% + {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt + \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}% +\def\bbl@providefam#1{% + \bbl@exp{% + \\\newcommand\<#1default>{}% Just define it + \\\bbl@add@list\\\bbl@font@fams{#1}% + \\\DeclareRobustCommand\<#1family>{% + \\\not@math@alphabet\<#1family>\relax + \\\fontfamily\<#1default>\\\selectfont}% + \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}} +\def\bbl@switchfont{% + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \bbl@exp{% eg Arabic -> arabic + \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}% + \bbl@foreach\bbl@font@fams{% + \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language? + {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script? + {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic? + {}% 123=F - nothing! + {\bbl@exp{% 3=T - from generic + \global\let\<bbl@##1dflt@\languagename>% + \<bbl@##1dflt@>}}}% + {\bbl@exp{% 2=T - from script + \global\let\<bbl@##1dflt@\languagename>% + \<bbl@##1dflt@*\bbl@tempa>}}}% + {}}% 1=T - language, already defined + \def\bbl@tempa{% + \bbl@warning{The current font is not a standard family.\\% + Script and Language are not applied. Consider defining\\% + a new family with \string\babelfont,}}% + \bbl@foreach\bbl@font@fams{% don't gather with prev for + \bbl@ifunset{bbl@##1dflt@\languagename}% + {\bbl@cs{famrst@##1}% + \global\bbl@csarg\let{famrst@##1}\relax}% + {\bbl@exp{% order is relevant + \\\bbl@add\\\originalTeX{% + \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}% + \<##1default>\<##1family>{##1}}% + \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part! + \<##1default>\<##1family>}}}% + \bbl@ifrestoring{}{\bbl@tempa}}% +\def\bbl@font@set#1#2#3{% + \bbl@xin@{<>}{#1}% + \ifin@ + \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}% + \fi + \bbl@exp{% + \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang} + \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}} +\def\bbl@fontspec@set#1#2#3{% + \bbl@exp{\<fontspec_set_family:Nnn>\\#1% + {\bbl@cs{lsys@\languagename},#2}}{#3}% + \bbl@toglobal#1}% +\def\bbl@provide@lsys#1{% + \bbl@ifunset{bbl@lname@#1}% + {\bbl@ini@ids{#1}}% + {}% + \bbl@csarg\let{lsys@#1}\@empty + \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}% + \bbl@ifunset{bbl@sotf#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}% + \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}% + \bbl@ifunset{bbl@lname@#1}{}% + {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}% + \bbl@csarg\bbl@toglobal{lsys@#1}}% + % \bbl@exp{% TODO - should be global + % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl@cs{sname@#1}}% + % {\\\newfontscript{\bbl@cs{sname@#1}}{\bbl@cs{sotf@#1}}}% + % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl@cs{lname@#1}}% + % {\\\newfontlanguage{\bbl@cs{lname@#1}}{\bbl@cs{lotf@#1}}}}} +\def\bbl@ini@ids#1{% + \def\BabelBeforeIni##1##2{% + \begingroup + \bbl@add\bbl@secpost@identification{% + \def\bbl@iniline########1\bbl@iniline{}}% + \catcode`\[=12 \catcode`\]=12 \catcode`\==12 + \bbl@read@ini{##1}% + \endgroup} + \InputIfFileExists{babel-#1.tex}{}{}} +\def\bbl@font@rst#1#2#3#4{% + \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}} +\def\bbl@font@fams{rm,sf,tt} \newcommand\babelFSstore[2][]{% \bbl@ifblank{#1}% - {\bbl@csarg\def{script@#2}{Latin}}% - {\bbl@csarg\def{script@#2}{#1}}% - \@expandtwoargs % TODO should go to the ini loaders - \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts\bbl@rscripts}% - \ifin@ + {\bbl@csarg\def{sname@#2}{Latin}}% + {\bbl@csarg\def{sname@#2}{#1}}% + \bbl@provide@dirs{#2}% + \bbl@csarg\ifnum{wdir@#2}>\z@ \let\bbl@beforeforeign\leavevmode \EnableBabelHook{babel-bidi}% - \ifcase\bbl@engine\or - \@expandtwoargs % TODO should go to the ini loaders - \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts}% - \directlua{ - Babel.langdirs = Babel.langdirs or {} - Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}% - \or - \bbl@xebidipar - \fi - \else - \ifcase\bbl@engine\or - \directlua{ - Babel.langdirs = Babel.langdirs or {} - Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}% - \fi \fi \bbl@foreach{#2}{% \bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault diff --git a/Master/texmf-dist/tex/generic/babel/nil.ldf b/Master/texmf-dist/tex/generic/babel/nil.ldf index a6c6ed76d76..a9fe897dc8f 100644 --- a/Master/texmf-dist/tex/generic/babel/nil.ldf +++ b/Master/texmf-dist/tex/generic/babel/nil.ldf @@ -31,7 +31,7 @@ %% and covered by LPPL is defined by the unpacking scripts (with %% extension |.ins|) which are part of the distribution. %% -\ProvidesLanguage{nil}[2017/10/04 3.14 Nil language] +\ProvidesLanguage{nil}[2017/11/03 3.15 Nil language] \LdfInit{nil}{datenil} \ifx\l@nohyphenation\@undefined \@nopatterns{nil} diff --git a/Master/texmf-dist/tex/generic/babel/switch.def b/Master/texmf-dist/tex/generic/babel/switch.def index 35901eab59e..3a0426fa3d9 100644 --- a/Master/texmf-dist/tex/generic/babel/switch.def +++ b/Master/texmf-dist/tex/generic/babel/switch.def @@ -36,7 +36,7 @@ \wlog{File: #1 #4 #3 <#2>}% \let\ProvidesFile\@undefined} \fi -\ProvidesFile{switch.def}[2017/10/04 3.14 Babel switching mechanism] +\ProvidesFile{switch.def}[2017/11/03 3.15 Babel switching mechanism] \ifx\AtBeginDocument\@undefined \input plain.def\relax \fi @@ -57,8 +57,8 @@ \countdef\last@language=19 \def\addlanguage{\alloc@9\language\chardef\@cclvi} \fi -\def\bbl@version{3.14} -\def\bbl@date{2017/10/04} +\def\bbl@version{3.15} +\def\bbl@date{2017/11/03} \def\adddialect#1#2{% \global\chardef#1#2\relax \bbl@usehooks{adddialect}{{#1}{#2}}% @@ -102,9 +102,12 @@ \xdef\bbl@language@stack{\languagename+\bbl@language@stack}} \def\bbl@pop@lang#1+#2-#3{% \edef\languagename{#1}\xdef#3{#2}} +\let\bbl@ifrestoring\@secondoftwo \def\bbl@pop@language{% \expandafter\bbl@pop@lang\bbl@language@stack-\bbl@language@stack - \expandafter\bbl@set@language\expandafter{\languagename}} + \let\bbl@ifrestoring\@firstoftwo + \expandafter\bbl@set@language\expandafter{\languagename}% + \let\bbl@ifrestoring\@secondoftwo} \expandafter\def\csname selectlanguage \endcsname#1{% \ifnum\bbl@hymapsel=\@cclv\let\bbl@hymapsel\tw@\fi \bbl@push@language @@ -150,8 +153,15 @@ \bbl@usehooks{afterreset}{}% \languageshorthands{none}% \ifcase\bbl@select@type - \csname captions#1\endcsname\relax - \csname date#1\endcsname\relax + \ifhmode + \hskip\z@skip % trick to ignore spaces + \csname captions#1\endcsname\relax + \csname date#1\endcsname\relax + \loop\ifdim\lastskip>\z@\unskip\repeat\unskip + \else + \csname captions#1\endcsname\relax + \csname date#1\endcsname\relax + \fi \fi \bbl@usehooks{beforeextras}{}% \csname extras#1\endcsname\relax @@ -242,7 +252,7 @@ \@expandtwoargs\bbl@usehooks{patterns}{{#1}{\bbl@tempa}}% \@ifundefined{bbl@hyphenation@}{}{% Can be \relax! \begingroup - \@expandtwoargs\in@{,\number\language,}{,\bbl@hyphlist}% + \bbl@xin@{,\number\language,}{,\bbl@hyphlist}% \ifin@\else \@expandtwoargs\bbl@usehooks{hyphenation}{{#1}{\bbl@tempa}}% \hyphenation{% @@ -254,17 +264,14 @@ \fi \endgroup}} \def\hyphenrules#1{% - \edef\languagename{#1}% - \bbl@fixname\languagename - \bbl@iflanguage\languagename{% - \expandafter\bbl@patterns\expandafter{\languagename}% + \edef\bbl@tempf{#1}% + \bbl@fixname\bbl@tempf + \bbl@iflanguage\bbl@tempf{% + \expandafter\bbl@patterns\expandafter{\bbl@tempf}% \languageshorthands{none}% - \expandafter\ifx\csname\languagename hyphenmins\endcsname\relax - \set@hyphenmins\tw@\thr@@\relax - \else - \expandafter\expandafter\expandafter\set@hyphenmins - \csname\languagename hyphenmins\endcsname\relax - \fi}} + \bbl@ifunset{\bbl@tempf hyphenmins}% + {\set@hyphenmins\tw@\thr@@\relax}% + {\bbl@exp{\\\set@hyphenmins\@nameuse{\bbl@tempf hyphenmins}}}}} \let\endhyphenrules\@empty \def\providehyphenmins#1#2{% \expandafter\ifx\csname #1hyphenmins\endcsname\relax diff --git a/Master/texmf-dist/tex/generic/babel/xebabel.def b/Master/texmf-dist/tex/generic/babel/xebabel.def index c3df40d1887..b3a75c9fd2b 100644 --- a/Master/texmf-dist/tex/generic/babel/xebabel.def +++ b/Master/texmf-dist/tex/generic/babel/xebabel.def @@ -73,30 +73,116 @@ \L 00FF 0178 00FF \endgroup \input #1\relax} +\ifx\DisableBabelHook\@undefined\endinput\fi +\AddBabelHook{babel-fontspec}{afterextras}{\bbl@switchfont} +\DisableBabelHook{babel-fontspec} +\@onlypreamble\babelfont +\newcommand\babelfont[2][]{% 1=langs/scripts 2=fam + \edef\bbl@tempa{#1}% + \def\bbl@tempb{#2}% + \ifx\fontspec\@undefined + \usepackage{fontspec}% + \fi + \EnableBabelHook{babel-fontspec}% + \bbl@bblfont} +\newcommand\bbl@bblfont[2][]{% 1=features 2=fontname + \bbl@ifunset{\bbl@tempb family}{\bbl@providefam{\bbl@tempb}}{}% + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \expandafter\bbl@ifblank\expandafter{\bbl@tempa}% + {\bbl@csarg\edef{\bbl@tempb dflt@}{<>{#1}{#2}}% save bbl@rmdflt@ + \bbl@exp{% + \let\<bbl@\bbl@tempb dflt@\languagename>\<bbl@\bbl@tempb dflt@>% + \\\bbl@font@set\<bbl@\bbl@tempb dflt@\languagename>% + \<\bbl@tempb default>\<\bbl@tempb family>}}% + {\bbl@foreach\bbl@tempa{% ie bbl@rmdflt@lang / *scrt + \bbl@csarg\def{\bbl@tempb dflt@##1}{<>{#1}{#2}}}}}% +\def\bbl@providefam#1{% + \bbl@exp{% + \\\newcommand\<#1default>{}% Just define it + \\\bbl@add@list\\\bbl@font@fams{#1}% + \\\DeclareRobustCommand\<#1family>{% + \\\not@math@alphabet\<#1family>\relax + \\\fontfamily\<#1default>\\\selectfont}% + \\\DeclareTextFontCommand{\<text#1>}{\<#1family>}}} +\def\bbl@switchfont{% + \bbl@ifunset{bbl@lsys@\languagename}{\bbl@provide@lsys{\languagename}}{}% + \bbl@exp{% eg Arabic -> arabic + \lowercase{\edef\\\bbl@tempa{\bbl@cs{sname@\languagename}}}}% + \bbl@foreach\bbl@font@fams{% + \bbl@ifunset{bbl@##1dflt@\languagename}% (1) language? + {\bbl@ifunset{bbl@##1dflt@*\bbl@tempa}% (2) from script? + {\bbl@ifunset{bbl@##1dflt@}% 2=F - (3) from generic? + {}% 123=F - nothing! + {\bbl@exp{% 3=T - from generic + \global\let\<bbl@##1dflt@\languagename>% + \<bbl@##1dflt@>}}}% + {\bbl@exp{% 2=T - from script + \global\let\<bbl@##1dflt@\languagename>% + \<bbl@##1dflt@*\bbl@tempa>}}}% + {}}% 1=T - language, already defined + \def\bbl@tempa{% + \bbl@warning{The current font is not a standard family.\\% + Script and Language are not applied. Consider defining\\% + a new family with \string\babelfont,}}% + \bbl@foreach\bbl@font@fams{% don't gather with prev for + \bbl@ifunset{bbl@##1dflt@\languagename}% + {\bbl@cs{famrst@##1}% + \global\bbl@csarg\let{famrst@##1}\relax}% + {\bbl@exp{% order is relevant + \\\bbl@add\\\originalTeX{% + \\\bbl@font@rst{\bbl@cs{##1dflt@\languagename}}% + \<##1default>\<##1family>{##1}}% + \\\bbl@font@set\<bbl@##1dflt@\languagename>% the main part! + \<##1default>\<##1family>}}}% + \bbl@ifrestoring{}{\bbl@tempa}}% +\def\bbl@font@set#1#2#3{% + \bbl@xin@{<>}{#1}% + \ifin@ + \bbl@exp{\\\bbl@fontspec@set\\#1\expandafter\@gobbletwo#1}% + \fi + \bbl@exp{% + \def\\#2{#1}% eg, \rmdefault{\bbl@rm1dflt@lang} + \\\bbl@ifsamestring{#2}{\f@family}{\\#3\let\\\bbl@tempa\relax}{}}} +\def\bbl@fontspec@set#1#2#3{% + \bbl@exp{\<fontspec_set_family:Nnn>\\#1% + {\bbl@cs{lsys@\languagename},#2}}{#3}% + \bbl@toglobal#1}% +\def\bbl@provide@lsys#1{% + \bbl@ifunset{bbl@lname@#1}% + {\bbl@ini@ids{#1}}% + {}% + \bbl@csarg\let{lsys@#1}\@empty + \bbl@ifunset{bbl@sname@#1}{\bbl@csarg\gdef{sname@#1}{Default}}{}% + \bbl@ifunset{bbl@sotf#1}{\bbl@csarg\gdef{sotf@#1}{DFLT}}{}% + \bbl@csarg\bbl@add@list{lsys@#1}{Script=\bbl@cs{sname@#1}}% + \bbl@ifunset{bbl@lname@#1}{}% + {\bbl@csarg\bbl@add@list{lsys@#1}{Language=\bbl@cs{lname@#1}}}% + \bbl@csarg\bbl@toglobal{lsys@#1}}% + % \bbl@exp{% TODO - should be global + % \<keys_if_exist:nnF>{fontspec-opentype/Script}{\bbl@cs{sname@#1}}% + % {\\\newfontscript{\bbl@cs{sname@#1}}{\bbl@cs{sotf@#1}}}% + % \<keys_if_exist:nnF>{fontspec-opentype/Language}{\bbl@cs{lname@#1}}% + % {\\\newfontlanguage{\bbl@cs{lname@#1}}{\bbl@cs{lotf@#1}}}}} +\def\bbl@ini@ids#1{% + \def\BabelBeforeIni##1##2{% + \begingroup + \bbl@add\bbl@secpost@identification{% + \def\bbl@iniline########1\bbl@iniline{}}% + \catcode`\[=12 \catcode`\]=12 \catcode`\==12 + \bbl@read@ini{##1}% + \endgroup} + \InputIfFileExists{babel-#1.tex}{}{}} +\def\bbl@font@rst#1#2#3#4{% + \bbl@csarg\def{famrst@#4}{\bbl@font@set{#1}#2#3}} +\def\bbl@font@fams{rm,sf,tt} \newcommand\babelFSstore[2][]{% \bbl@ifblank{#1}% - {\bbl@csarg\def{script@#2}{Latin}}% - {\bbl@csarg\def{script@#2}{#1}}% - \@expandtwoargs % TODO should go to the ini loaders - \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts\bbl@rscripts}% - \ifin@ + {\bbl@csarg\def{sname@#2}{Latin}}% + {\bbl@csarg\def{sname@#2}{#1}}% + \bbl@provide@dirs{#2}% + \bbl@csarg\ifnum{wdir@#2}>\z@ \let\bbl@beforeforeign\leavevmode \EnableBabelHook{babel-bidi}% - \ifcase\bbl@engine\or - \@expandtwoargs % TODO should go to the ini loaders - \in@{\csname bbl@script@#2\endcsname}{\bbl@alscripts}% - \directlua{ - Babel.langdirs = Babel.langdirs or {} - Babel.langdirs[\the\@nameuse{l@#2}] = \ifin@ 'al' \else 'r' \fi}% - \or - \bbl@xebidipar - \fi - \else - \ifcase\bbl@engine\or - \directlua{ - Babel.langdirs = Babel.langdirs or {} - Babel.langdirs[\the\@nameuse{l@#2}] = 'l'}% - \fi \fi \bbl@foreach{#2}{% \bbl@FSstore{##1}{rm}\rmdefault\bbl@save@rmdefault |