summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/generic/babel/xebabel.def
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/generic/babel/xebabel.def')
-rw-r--r--Master/texmf-dist/tex/generic/babel/xebabel.def126
1 files changed, 106 insertions, 20 deletions
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