From ffd652038baef26fb84de26fce9991a02e875485 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 Oct 2019 20:58:49 +0000 Subject: polyglossia (28oct19) git-svn-id: svn://tug.org/texlive/trunk@52555 c570f23f-e606-0410-a88d-b1316a301751 --- .../tex/latex/polyglossia/gloss-french.ldf | 172 ++++++++++++++++----- 1 file changed, 130 insertions(+), 42 deletions(-) (limited to 'Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf') diff --git a/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf b/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf index fdffd36cf9d..8cb0731d2df 100644 --- a/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf +++ b/Master/texmf-dist/tex/latex/polyglossia/gloss-french.ldf @@ -3,12 +3,43 @@ \PolyglossiaSetup{french}{% language=French, script=Latin, + langtag=FRA, hyphennames={french,francais}, frenchspacing=true, indentfirst=true, hyphenmins={2,2}, fontsetup=true} +\def\french@variant{french} +\define@choicekey*+{french}{variant}[\val\nr]{french,canadian,acadian}[french]{% + \ifcase\nr\relax + % french: + \def\french@variant{french}% + \or + % canadian: + \def\french@variant{canadien}% + \SetLanguageKeys{french}{babelname=canadien}% + \xpg@ifdefined{canadien}{}% + {\xpg@warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak + I will use the standard patterns for French instead}% + \adddialect\l@canadien\l@french\relax}% + \or + % acadian: + \def\french@variant{acadian}% + \SetLanguageKeys{french}{babelname=canadien}% + \xpg@ifdefined{acadian}{}% + {\xpg@warning{No hyphenation patterns were loaded for "French (Canada)"\MessageBreak + I will use the standard patterns for French instead}% + \adddialect\l@acadian\l@french\relax}% + \fi + \xpg@info{Option: French, variant=\val}% +}{\xpg@warning{Unknown French variant `#1'}} + + +\def\french@language{% + \polyglossia@setup@language@patterns{\french@variant} +}% + \ifluatex \newluatexattribute\xpg@frpt % \directlua{polyglossia.load_frpt()}% @@ -22,36 +53,77 @@ \fi \def\xpg@unskip{\ifhmode\ifdim\lastskip>\z@\unskip\fi\fi} -\def\xpg@nospace#1{#1} - -\ifx\@makefntext\undefined\else - \let\nofrench@makefntext\@makefntext - \long\def\french@makefntext#1{\parindent1em \noindent\quad\ifx\@thefnmark\empty\else\@thefnmark.\space\fi #1} - \let\@makefntext\french@makefntext - \define@boolkey{french}[french@]{frenchfootnote}[true]{% - \def\@tmpa{#1} - \def\@tmptrue{true} - \ifx\@tmpa\@tmptrue - \let\@makefntext\french@makefntext - \else - \let\@makefntext\nofrench@makefntext - \fi - } -\fi +% Save original footnote definition +\let\xpg@orig@makefntext\@makefntext + +\define@boolkey{french}[french@]{frenchfootnote}[true]{% + \AfterPreamble{% + \ifdefstring{\xpg@main@language}{french}{% + \iffrench@frenchfootnote + \ifx\@makefntext\undefined\else + \long\def\french@makefntext##1{% + \parindent1em \noindent\quad% + \ifx\@thefnmark\empty\else% + \@thefnmark.\space\fi ##1% + } + \let\@makefntext\french@makefntext + \fi + \else + \let\@makefntext\xpg@orig@makefntext + \fi + }{\xpg@warning{Option 'frenchfootnote' only supported if French is main language!}}% + }% +} + +\define@boolkey{french}[french@]{autospacing}[true]{} +\french@autospacingtrue + +\newif\iffrench@autospaceguillemets +\define@boolkey{french}[french@]{autospaceguillemets}[true]{} +\french@autospaceguillemetstrue -\newif\iffrench@automaticspacesaroundguillemets +% Backwards compatibility \define@boolkey{french}[french@]{automaticspacesaroundguillemets}[true]{% - %\def\tmp@true{true}% - %\def\@tmpa{#1}% - %\ifx\@tmpa\tmp@true + \iffrench@automaticspacesaroundguillemets + \setkeys{french}{autospaceguillemets=true}% + \else + \setkeys{french}{autospaceguillemets=false}% + \fi +} + +% name is for compatibility with babel +\let\french@ttfamilyORI\ttfamily +\DeclareRobustCommand\french@ttfamilyFB{\nofrench@punctuation\french@ttfamilyORI} + +% Allow to switch on autospacing in ttfamily context +\define@boolkey{french}[french@]{autospacetypewriter}[true]{} +\french@autospacetypewriterfalse + +% This is how babel-french has it +\define@boolkey{french}[french@]{OriginalTypewriter}[true]{% + \iffrench@OriginalTypewriter + \setkeys{french}{autospacetypewriter=false}% + \else + \setkeys{french}{autospacetypewriter=true}% + \fi +} + +\def\french@fontsetup{% + \unless\iffrench@autospacetypewriter + \let\ttfamily\french@ttfamilyFB + \fi +} + + +\def\nofrench@fontsetup{% + \let\ttfamily\french@ttfamilyORI } -\french@automaticspacesaroundguillemetstrue \def\french@punctuation{% \lccode"2019="2019 \ifluatex - \global\xpg@frpt=1\relax % + \xpg@frpt=1\relax % \directlua{polyglossia.activate_frpt()}% \else \XeTeXinterchartokenstate=1 @@ -73,24 +145,24 @@ \XeTeXcharclass `\[ \french@closebrackets \XeTeXcharclass `\{ \french@openbrackets \XeTeXcharclass `\} \french@closebrackets - \XeTeXinterchartoks \z@ \french@punctthin = {\nobreak\thinspace}% + \XeTeXinterchartoks \z@ \french@punctthin = {\thinspace}% \XeTeXinterchartoks \z@ \french@punctthick = {\nobreakspace}% - \XeTeXinterchartoks \xpg@boundaryclass \french@punctthin = {\xpg@unskip\nobreak\thinspace}% + \XeTeXinterchartoks \xpg@boundaryclass \french@punctthin = {\xpg@unskip\thinspace}% \XeTeXinterchartoks \xpg@boundaryclass \french@punctthick = {\xpg@unskip\nobreakspace}% - \XeTeXinterchartoks \french@punctguillstart \z@ = {\nobreakspace}% "«a" -> "« a" - % \XeTeXinterchartoks \z@ \french@punctguillstart = {\nobreakspace}% "a«" unchanged? - % \XeTeXinterchartoks \french@punctguillend \z@ = {\nobreakspace}% "»a" unchanged? - \XeTeXinterchartoks \z@ \french@punctguillend = {\nobreakspace}% "a»" -> "a »" - \iffrench@automaticspacesaroundguillemets - \XeTeXinterchartoks \french@punctguillstart \xpg@boundaryclass = {\nobreakspace\xpg@nospace\relax}% "« " -> "«~" - \XeTeXinterchartoks \xpg@boundaryclass \french@punctguillend = {\xpg@unskip\nobreakspace}% " »" -> "~»" - \fi - \XeTeXinterchartoks \french@punctguillend \french@punctthin = {\nobreak\thinspace}% "»;" -> "» ;" - \XeTeXinterchartoks \french@punctguillend \french@punctthick = {\nobreakspace}% "»:" -> "» :" - \XeTeXinterchartoks \french@punctthin \french@punctguillend = {\nobreakspace}% "?»" -> "? »" + \iffrench@autospaceguillemets + \XeTeXinterchartoks \french@punctguillstart \z@ = {\thinspace}% "«a" -> "«\,a" + % \XeTeXinterchartoks \z@ \french@punctguillstart = {\nobreakspace}% "a«" unchanged? + % \XeTeXinterchartoks \french@punctguillend \z@ = {\nobreakspace}% "»a" unchanged? + \XeTeXinterchartoks \z@ \french@punctguillend = {\thinspace}% "a»" -> "a\,»" + \XeTeXinterchartoks \french@punctguillstart \xpg@boundaryclass = {\thinspace\ignorespaces}% "« " -> "«\," + \XeTeXinterchartoks \xpg@boundaryclass \french@punctguillend = {\xpg@unskip\thinspace}% " »" -> "\,»" + \fi + \XeTeXinterchartoks \french@punctguillend \french@punctthin = {\thinspace}% "»;" -> "»\,;" + \XeTeXinterchartoks \french@punctguillend \french@punctthick = {\nobreakspace}% "»:" -> "» :" + \XeTeXinterchartoks \french@punctthin \french@punctguillend = {\thinspace}% "?»" -> "?\,»" \XeTeXinterchartoks \french@openbrackets \french@punctthin = {\xpg@unskip}% "(?" -> "(?" and not "( ?" \XeTeXinterchartoks \french@punctthin \french@closebrackets = {\xpg@unskip}% "?)" -> "?)" (code not need, just for symetry with previous one) - \XeTeXinterchartoks \french@closebrackets \french@punctthin = {\nobreak\thinspace}% ")?" -> ") ?" + \XeTeXinterchartoks \french@closebrackets \french@punctthin = {\thinspace}% ")?" -> ")\,?" \XeTeXinterchartoks \french@closebrackets \french@punctthick = {\nobreakspace}% "):" -> ") :" \fi } @@ -98,7 +170,7 @@ \def\nofrench@punctuation{% \lccode"2019=\z@ \ifluatex - \global\xpg@frpt=0\relax % + \xpg@frpt=0\relax % % Though it would make compilation slightly faster, it is not possible to % safely uncomment the following line. Imagine the following case: you start % a paragraph by some french text, then, in the same paragraph, you change @@ -152,6 +224,7 @@ \def\headtoname{}% \def\proofname{Démonstration}% } + \def\datefrench{% \def\today{\ifx\ier\undefined\def\ier{er}\fi \ifnum\day=1\relax 1\ier% @@ -164,15 +237,30 @@ \def\noextras@french{% \nofrench@punctuation% - } + \nofrench@fontsetup% +} \def\blockextras@french{% - \french@punctuation% - } + \iffrench@autospacing + \french@punctuation% + \fi + \french@fontsetup% +} \def\inlineextras@french{% - \french@punctuation% - } + \iffrench@autospacing + \french@punctuation% + \fi + \french@fontsetup% +} + +\def\NoAutoSpacing{% + \nofrench@punctuation% +} + +\def\AutoSpacing{% + \french@punctuation% +} \def\ier{\textsuperscript{er}} \def\iers{\textsuperscript{ers}} -- cgit v1.2.3