diff options
Diffstat (limited to 'Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty')
-rw-r--r-- | Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty | 183 |
1 files changed, 110 insertions, 73 deletions
diff --git a/Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty b/Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty index 055e647a2ac..02889374b43 100644 --- a/Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty +++ b/Master/texmf-dist/tex/xelatex/polyglossia/polyglossia.sty @@ -1,7 +1,8 @@ \NeedsTeXFormat{LaTeX2e} -\ProvidesPackage{polyglossia}[2009/11/20 v1.1.0 +\ProvidesPackage{polyglossia}[2010/03/23 v1.1.1 Babel replacement for XeLaTeX] \RequirePackage{etoolbox} +\RequirePackage{makecmds} \RequirePackage{fontspec} %which itself depends on xkeyval %% This is for compatibility with Babel-aware package: @@ -19,20 +20,18 @@ {#1\@gobble}} %% the \@gobble is to prevent displaying the line nr \providecommand*{\xpg@nopatterns}[1]{% \xpg@warning{No hyphenation patterns were loaded for `#1'\MessageBreak - I will use the patterns loaded for \string\language=0\MessageBreak instead}} + I will use the patterns for \string\language=\string\l@nohyphenation\space instead}} \providecommand*{\xpg@nolang}[1]{% \xpg@warning{File gloss-#1.ldf does not exist!^^J - I will nevertheless try to use hyphenation patterns for #1.}}% + I will nevertheless try to use hyphenation patterns for #1.}}% %TODO try at least to load the hyphenation patterns for #1. \def\xpg@ill@value#1#2{% \xpg@warning{Illegal value (#1) for #2}} %% use macro if defined, else warn that it is not -\def\xpg@csifdef@warn#1{% - \ifcsundef{#1}{\PackageWarning{polyglossia}{ #1 is not defined}}% - {\expandafter\protect\csname #1\endcsname}} -%% same without warning -\def\xpg@csifdef#1{\ifcsundef{#1}{\relax}{\expandafter\protect\csname #1\endcsname}} +\def\csuse@warn#1{% + \ifcsundef{#1}{\xpg@warning{ \expandafter\string\csname #1\endcsname\space is not defined}}% + {\csname #1\endcsname}} %% ensure directionality if bidi is loaded, else ignore \def\@@ensure@dir#1{\ifcsundef{@ensure@dir}{#1}{\@ensure@dir{#1}}} @@ -71,17 +70,16 @@ \if@nobreak\ifvmode\nobreak\fi\fi}% \def\@markright####1####2####3{\@temptokena{\protect\@@ensure@maindir{####1}}% \unrestored@protected@xdef\@themark{{\the\@temptokena}% - {{\protect\@@ensure@maindir{####3}}}}}} - \else%\ifx\@tmpa\opt@disabled + {\protect\@@ensure@maindir{####3}}}}} + \else \def\local@marks##1{} \xpg@info{Option: localmarks=off} - %\fi \fi } \setkeys{polyglossia}{localmarks=on} % to reset the intercharclass of a character to "normal" -\newXeTeXintercharclass\xpg@normalclass +\newXeTeXintercharclass\xpg@normalclass %TODO %% when no patterns are available, we use \l@nohyphenation, assigned to 255 %% (suggestion by Enrico Gregorio) @@ -117,17 +115,7 @@ }% {\PackageWarning{polyglossia}{gloss-#2.ldf is already loaded!}}% %% The following settings are for the default language and script: - \ifcsundef{#2@RL}{}% - {\@rlmaintrue\@rl@footnotetrue% - \let\@@oddfoot\@oddfoot% - \let\@@evenfoot\@evenfoot% - \let\@oddfoot\@@evenfoot% - \let\@evenfoot\@@oddfoot% - \let\@@oddhead\@oddhead% - \let\@@evenhead\@evenhead% - \let\@oddhead\@@evenhead% - \let\@evenhead\@@oddhead% - }% + \ifcsundef{#2@RL}{}{\@RTLmaintrue}% this tells bidi.sty that the document is RTL \AtBeginDocument{% \selectlanguage[#1]{#2}% \selectbackgroundlanguage{#2}}% @@ -140,11 +128,17 @@ \newcommand{\resetdefaultlanguage}[2][]{% \ifcsundef{#2@loaded}{% \PackageError{polyglossia}{gloss-#2.ldf is not loaded!}}% - {\def\languagename{#2}% + {\csuse{no\xpg@main@language @globalnumbers}% disable globalnumbers of previously defined default language + \csuse{noextras@\xpg@main@language}% + \def\languagename{#2}% \ifcsundef{#2@RL}{}{\@rlmaintrue\@rl@footnotetrue}% \selectlanguage[#1]{#2}% \selectbackgroundlanguage{#2}}} +\def\familytype{rm} +\gappto\rmfamily{\def\familytype{rm}} +\gappto\sffamily{\def\familytype{sf}} +\gappto\ttfamily{\def\familytype{tt}} % This saves the normalfont for the latin script since we may change normalfont in other scripts \let\normalfontlatin=\normalfont% \let\rmfamilylatin=\rmfamily% @@ -157,7 +151,20 @@ \let\ttfamily=\ttfamilylatin% \normalfontlatin} -\def\reset@LR{\xpg@csifdef{setLR}} +\def\reset@LR{\csuse{setLR}} + +\def\selectnormalfontlatin{% + \if\normalfont\ttfamily\ttfamilylatin\else + \if\normalfont\sffamily\sffamilylatin\else + \normalfontlatin\fi\fi} + +\DeclareRobustCommand\selectfontfamilylatin{% + \def\tmp@tt{tt}\def\tmp@sf{sf}% + \ifx\familytype\tmp@tt% + \ttfamilylatin% + \else\ifx\familytype\tmp@sf% + \sffamilylatin% + \else\rmfamilylatin\fi\fi} \let\@@fterindentfalse\@afterindentfalse \def\french@indent{\let\@afterindentfalse\@afterindenttrue @@ -166,8 +173,8 @@ \@afterindentfalse} \newcommand{\selectbackgroundlanguage}[1]{% - \xpg@csifdef{selectnormalfont#1}% - \xpg@csifdef{#1@globalnumbers}% + \csuse{selectnormalfont#1}% + \csuse{#1@globalnumbers}% } \newcommand{\setotherlanguage}[2][]{% @@ -186,12 +193,12 @@ \fi \expandafter\newcommand\csname text#2\endcsname[2][]{% \ifcsdef{RL}{% - \ifcsundef{#2@RL}% - {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}% + \ifcsundef{#2@RL}% + {\@ensure@LTR{\foreignlanguage[####1]{#2}{####2}}}% {\@ensure@RTL{\foreignlanguage[####1]{#2}{####2}}}% - }{% else + }{% else \foreignlanguage[####1]{#2}{####2}% - }}% + }}% \csletcs{local#2}{text#2}% \csgdef{#2@loaded}{}% }% @@ -209,10 +216,11 @@ \docsvlist{#1}}% \def\common@language{% - \protect\language=0% - \lefthyphenmin=2\righthyphenmin=3} + \language=\z@ + \lefthyphenmin=\tw@ + \righthyphenmin=\thr@@} -\def\noextrascurrent#1{\xpg@csifdef{noextras@#1}} +\def\noextrascurrent#1{\csuse{noextras@#1}} \def\xpg@initial@setup{\ifcsundef{languagename}{}% {\noextrascurrent{\languagename}}% @@ -220,29 +228,32 @@ \AtBeginDocument{\xpg@initial@setup} -\ifcsundef{foreignlanguage}{}% - {\let\foreignlanguage\@undefined} +\providecommand{\foreignlanguage}{} -\newcommand{\foreignlanguage}[3][]{% +\renewcommand{\foreignlanguage}[3][]{% \ifcsundef{#2@loaded}{\xpg@nolang{#2}\hyphenrules{#2}}{% {\def\languagename{#2}% \setkeys{#2}{#1}% - \xpg@csifdef@warn{#2@font}% - \xpg@csifdef@warn{#2@language}% - \xpg@csifdef{date#2}% - \xpg@csifdef{#2@numbers}% + \csuse@warn{#2@font}% + \csuse@warn{#2@language}% + \csuse{date#2}% + \csuse{#2@numbers}% \use@localhyphenmins{#2}% - \xpg@csifdef{inlineextras@#2}% + \csuse{inlineextras@#2}% #3}% -}} + }% +} -\ifcsundef{selectlanguage}{}% - {\let\selectlanguage\@undefined} +%Hook that other package authors can use +%(for instance biblatex): +\newcommand*{\xpg@hook@setlanguage}{} -\newcommand{\selectlanguage}[2][]{% +\providecommand{\selectlanguage}{} +\renewcommand{\selectlanguage}[2][]{% \ifcsundef{#2@loaded}{\xpg@nolang{#2}\hyphenrules{#2}}{% \def\xpg@pop@language{% \xpg@set@language{\languagename}% + \xpg@hook@setlanguage% \let\emp@langname\@undefined}% \aftergroup\xpg@pop@language% \setkeys{#2}{#1}% @@ -259,34 +270,28 @@ \fi } -\ifcsundef{select@language}{}% - {\let\select@language\@undefined} - -\newcommand{\select@language}[1]{% +\def\select@language#1{% \xpg@initial@setup% \edef\languagename{#1}% \ifcsundef{RL}{}% {\ifcsundef{#1@RL}{\setLR}{\setRL}}% - \xpg@csifdef@warn{#1@font}% - \xpg@csifdef@warn{#1@language}% + \csuse@warn{#1@font}% + \csuse@warn{#1@language}% \use@localhyphenmins{#1}% - \xpg@csifdef{captions#1}% - \xpg@csifdef{date#1}% - \xpg@csifdef{#1@numbers}% + \csuse{captions#1}% + \csuse{date#1}% + \csuse{#1@numbers}% \local@marks{#1}% - \xpg@csifdef{blockextras@#1}% + \csuse{blockextras@#1}% } \let\xpg@pop@language\relax -\ifcsundef{otherlanguage}{}% - {\let\otherlanguage\@undefined} -\ifcsundef{endotherlanguage}{}% - {\let\endotherlanguage\@undefined} +\provideenvironment{otherlanguage}{}{} -\newenvironment{otherlanguage}[2][]{% - \selectlanguage[#1]{#2}% - }{} +\renewenvironment{otherlanguage}[2][] + {\selectlanguage[#1]{#2}} + {} \newcommand{\setlocalhyphenmins}[3]{% \expandafter\ifx\csname l@#1\endcsname\relax% @@ -303,10 +308,41 @@ \ifcsundef{#1hyphenmins}{}% {\expandafter\expandafter\expandafter\set@hyphenmins\csname #1hyphenmins\endcsname\relax}} -%% package options - -%%\DeclareOption{shorthands}{\setkeys{polyglossia}{shorthands=true}} +% FIXME: remove this eventually, say in 2012 :) +% taken from xelatex.ini, in case the xelatex format is too old +\ifcsundef{newXeTeXintercharclass}{% + \xpg@warning{Your xelatex format appears to be outdated!^^J + Please update your system and recreate it with fmtutil.} + \newcount\xe@alloc@intercharclass % allocates intercharclass + \xe@alloc@intercharclass=\thr@@ % from 4 (1,2 and 3 are used by CJK, AFAIK) + \def\xe@alloc@#1#2#3#4#5{\global\advance#1\@ne + \xe@ch@ck#1#4#2% make sure there's still room + \allocationnumber#1% + \global#3#5\allocationnumber + \wlog{\string#5=\string#2\the\allocationnumber}} + \def\xe@ch@ck#1#2#3{% + \ifnum#1<#2\else + \errmessage{No room for a new #3}% + \fi} + \def\newXeTeXintercharclass{% + \xe@alloc@\xe@alloc@intercharclass\XeTeXintercharclass\chardef\@cclv} %at most 254 + } + {} + +%% patch lastpage to avoid problem with \thepage when \@arabic is redefined for non-Latin numbers +%\@ifpackageloaded{lastpage}{% +%\xpg@info{Redefining lastpage command \string\lastpage@putlabel}% +%\def\lastpage@putlabel{\addtocounter{page}{-1}% +% \immediate\write\@auxout{\string +% \newlabel{LastPage}{{}{\number\c@page}}}% +% \addtocounter{page}{1}}}% +% {} +% +\define@boolkey{polyglossia}[system@]{babelshorthands}[false]{} + +%% Package Options %% \DeclareOption{nolocalmarks}{\setkeys{polyglossia}{localmarks=off}} +\DeclareOption{babelshorthands}{\setkeys{polyglossia}{babelshorthands=true}} \DeclareOption{quiet}{% \gdef\@latex@info#1{\relax}% no latex info \gdef\@font@info#1{\relax}% no latex font info @@ -326,13 +362,14 @@ \DeclareOption{polygreek}{\xpg@option{variant=poly}{greek}} \DeclareOption{monogreek}{\xpg@option{variant=mono}{greek}} \DeclareOption{ancientgreek}{\xpg@option{variant=ancient}{greek}} -%%% FIXME: this does not work when gloss-<option>.ldf contains a \RequirePackage command !!! -%%% let's try with \AtEndOfPackage (not tested) \DeclareOption*{% -\ifcsundef{xpg@main@language}% -{\edef\@temp{\noexpand\setdefaultlanguage{\CurrentOption}}}% -{\edef\@temp{\noexpand\setotherlanguage{\CurrentOption}}}% - \AtEndOfPackage{\@temp}} + \edef\@temp{% + \noexpand\ifcsundef{xpg@main@language}% + \noexpand\setdefaultlanguage + \noexpand\setotherlanguage + {\CurrentOption}% + }% + \expandafter\AtEndOfPackage\expandafter{\@temp}% +} \ProcessOptions* \endinput - |