diff options
author | Karl Berry <karl@freefriends.org> | 2016-05-18 21:58:47 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-05-18 21:58:47 +0000 |
commit | fd4db2fd78326629cdaa61f2bbca86682fa2819e (patch) | |
tree | 8ce47b799786f854d1f4a66efa0661f244671e9c /Master/texmf-dist/source/generic/babel-french/frenchb.dtx | |
parent | 17ee5a848b1f535a07aad806695a5c41841bd3dd (diff) |
babel-french (18may16)
git-svn-id: svn://tug.org/texlive/trunk@41244 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic/babel-french/frenchb.dtx')
-rw-r--r-- | Master/texmf-dist/source/generic/babel-french/frenchb.dtx | 393 |
1 files changed, 240 insertions, 153 deletions
diff --git a/Master/texmf-dist/source/generic/babel-french/frenchb.dtx b/Master/texmf-dist/source/generic/babel-french/frenchb.dtx index 3d3d55e8e75..d476756dad9 100644 --- a/Master/texmf-dist/source/generic/babel-french/frenchb.dtx +++ b/Master/texmf-dist/source/generic/babel-french/frenchb.dtx @@ -1,4 +1,4 @@ -%\CheckSum{3320} +%\CheckSum{3344} % %\iffalse % Tell the \LaTeX\ system who we are and write an entry on the @@ -13,14 +13,14 @@ %<ldf>\ProvidesLanguage{frenchb} %\ProvidesFile{frenchb.dtx} %<*!lua> - [2016/04/18 v3.2b French support from the babel system] + [2016/05/14 v3.2c French support from the babel system] %</!lua> %<*internal> \iffalse %</internal> %<*lua> -- --- File `frenchb.lua' generated from frenchb.dtx [2016/04/18 v3.2b] +-- File `frenchb.lua' generated from frenchb.dtx [2016/05/14 v3.2c] -- -- Copyright © 2014-2016 Daniel Flipo -- <daniel (dot) flipo (at) free (dot) fr> @@ -133,7 +133,7 @@ % \LaTeXe{} and Plain formats based on TeX, pdfTeX, LuaTeX or XeTeX % engines. % -% Changes between version 2.0 and \fileversion{} are listed in +% Changes between version 3.0 and \fileversion{} are listed in % subsection~\ref{ssec-changes} p.~\pageref{ssec-changes}. % % An extensive documentation is available in French here:\\ @@ -432,13 +432,15 @@ % to addition of spurious spaces in URLs, in MS-DOS paths or in % timetables (10:55), except if they are typed in |\texttt| or % verbatim mode. When the current font is a monospaced -% (typewriter) font, \fbo{AutoSpacePunctuation} is locally -% switched to \fbo{false}, no spurious space is added in that -% case, so the default behaviour of of \frenchb{} in that area -% should be fine in most circumstances. +% (typewriter) font, no spurious space is added in that case% +% \footnote{Unless option \fbo{OriginalTypewriter} is set, +% \cs{ttfamily} is redefined in French to switch off space +% tuning, see below.}, +% so the default behaviour of of \frenchb{} in that area should +% be fine in most circumstances. % % Choosing \fbo{AutoSpacePunctuation=false} will ensure that -% a proper space will be added before `|:;!?|' \emph{if and only +% a proper space is added before `|:;!?|' \emph{if and only % if} a (normal) space has been typed in. Those who are unsure % about their typing in this area should stick to the default % option and use the provided |\NoAutoSpacing| command @@ -449,6 +451,8 @@ % so that the same amount of space is added before any of the % four `high punctuation' characters. The default setting is % supported by the French `Imprimerie Nationale'. +% \item [OriginalTypewriter=true (false)] leaves the original +% definitions of |\ttfamily| and |\texttt{}| unchanged. % \item [LowercaseSuperscripts=false (true)]; by default \frenchb{} % inhibits the uppercasing of superscripts (for instance when % they are moved to page headers). Making this option @@ -621,7 +625,7 @@ % \cls{beamer}, \cls{memoir} and koma-script classes. % The layout of footnotes ``à la française'' should be unchanged % but footnotes' customisations offered by these classes -% (i.e. font or color changes) are now available even when option +% (i.e.\ font or color changes) are now available even when option % \fbo{FrenchFootnotes} is \fbo{true}. % % A long standing bug regarding the \pkg{xspace} package has been @@ -633,14 +637,18 @@ % v.~0.95 as included in TeXLive 2016 (LuaTeX's new glue node % structure is not compatible with previous versions). % -% \textbf{Warning to Lua(La)TeX users:} the lua code included in -% \file{frenchb.lua} v.~3.2b will \emph{not work} on older -% installations (TL2015 f.i.), so \frenchb{} reverts to active -% characters while handling high punctuation with LuaTeX engines -% older than 0.95! +% \textbf{Warning to Lua(La)TeX users:} starting with version~3.2b +% the lua code included in \file{frenchb.lua} will \emph{not work} +% on older installations (TL2015 f.i.), so \frenchb{} reverts to +% active characters while handling high punctuation with LuaTeX +% engines older than 0.95! % The best way to go is to upgrade to TL2016 or equivalent asap. % Xe(La)TeX and pdf(La)TeX users can safely use \frenchb{} v.~3.2b -% on older installations too. +% and later on older installations too. +% +% Tne internals of commands |\NoAutoSpacing|, |\ttfamilyFB|, +% |\rmfamilyFB| and |\sffamilyFB| have been completely redesigned +% in version~3.2c, they behave now consistently with all engines. % % \subsubsection*{What's new in version 3.1?} % @@ -996,19 +1004,12 @@ % alternative to active characters (`XeTeXinterchar' mechanism and % LuaTeX's callbacks). % -% With LuaTeX and XeTeX engines, \frenchb{} handles French quotes -% together with `high punctuation', a new conditional will be -% needed: -% \begin{macrocode} -\newif\ifFBAutoSpaceGuill \FBAutoSpaceGuilltrue -% \end{macrocode} -% % \changes{v3.0a}{2014/01/10}{New flag \cs{ifFB@luatex@punct} for % `high punctuation' management with LuaTeX engines.} % % \begin{macro}{\ifFB@active@punct} % \begin{macrocode} -\newif\ifFB@active@punct \FB@active@puncttrue +\newif\ifFB@active@punct \FB@active@puncttrue % \end{macrocode} % \end{macro} % @@ -1022,9 +1023,7 @@ % \begin{macrocode} \newif\ifFB@luatex@punct \ifFBLuaTeX - \ifnum\luatexversion>94 - \FB@luatex@puncttrue\FB@active@punctfalse - \else + \ifnum\luatexversion<95 \ifx\PackageWarning\@undefined \fb@warning{Please upgrade LuaTeX to version 0.95 or above!\\% frenchb will make high punctuation characters (;:!?) active\\% @@ -1035,6 +1034,8 @@ frenchb will make high punctuation characters\MessageBreak (;:!?) active with LuaTeX < 0.95;\MessageBreak reported}% \fi + \else + \FB@luatex@puncttrue\FB@active@punctfalse \fi \fi % \end{macrocode} @@ -1049,9 +1050,9 @@ % non characters: it's value will be 4095 for new engines and 255 % for older ones.} % -% The number of available character classes was increased from 256 -% to 4096 in XeTeX v.~0.99996, the class for non characters is now -% 4095 instead of 255. +% The number of available character classes has been increased +% from 256 to 4096 in XeTeX v.~0.99994, the class for +% non-characters is now 4095 instead of 255. % \begin{macrocode} \newcount\FB@nonchar \newif\ifFB@xetex@punct @@ -1059,7 +1060,7 @@ \expandafter\ifx\csname XeTeXinterchartokenstate\endcsname\relax \else \FB@xetex@puncttrue\FB@active@punctfalse - \ifdim\the\XeTeXversion\XeTeXrevision pt<0.99996pt + \ifdim\the\XeTeXversion\XeTeXrevision pt<0.99994pt \FB@nonchar=255 \relax \else \FB@nonchar=4095 \relax @@ -1080,16 +1081,27 @@ % \changes{v3.1f}{2015/05/31}{\cs{FBthinspace} is no longer a kern but % a skip (frenchb adds a nobreak penalty before it).} % -% \begin{macro}{\FBcolonskip} -% \begin{macro}{\FBthinskip} -% \changes{v3.0a}{2014/01/10}{LuaTeX requires dimensions: two new skips -% \cs{FBcolonskip} and \cs{FBthinskip}.} +% \changes{v3.2c}{2016/05/14}{Change .16667em to +% .5\cs{fontdimen2}\cs{font} in \cs{FBthinspace} +% to get a real thinspace with every font.} % % According to the I.N.\ specifications, the `:' requires an % inter-word space before it, the other three require just % a |\thinspace|. We define |\FBcolonspace| as |\space| % (inter-word space) and |\FBthinspace| as |\thinspace| (both % are user customisable). +% \begin{macrocode} +\newcommand*{\FBcolonspace}{\space} +\newcommand*{\FBthinspace}{\hskip.5\fontdimen2\font \relax} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\FBcolonskip} +% \begin{macro}{\FBthinskip} +% \changes{v3.0a}{2014/01/10}{LuaTeX requires dimensions: two new skips +% \cs{FBcolonskip} and \cs{FBthinskip}.} +% % LuaTeX requires skips instead of commands, so we define % |\FBcolonskip| and |\FBthinskip| to hold the specifications % (width/stretch/shrink) of |\space| and |\thinspace| for the @@ -1097,8 +1109,6 @@ % by the \file{frenchb.lua} script (see how p.~\pageref{lua-scaling}). % |\FBcolonskip| and |\FBthinskip| are also user customisable. % \begin{macrocode} -\newcommand*{\FBcolonspace}{\space} -\newcommand*{\FBthinspace}{\hskip .16667em \relax} \newskip\FBcolonskip \FBcolonskip=3.33pt plus 1.665pt minus 1.11pt \relax \newskip\FBthinskip @@ -1106,8 +1116,44 @@ % \end{macrocode} % \end{macro} % \end{macro} -% \end{macro} -% \end{macro} +% +% \changes{v3.2c}{2016/05/14}{Newif \cs{ifFB@spacing} and new commands +% \cs{FB@spacingon}, \cs{FB@spacingoff} to control space tuning in +% French.} +% +% With LuaTeX and XeTeX engines, \frenchb{} handles French quotes +% together with `high punctuation'; the conditional |\ifFB@spacing| +% will be used by PdfTeX and XeTeX engines to switch on or off space +% tuning before high punctuation and inside French quotes. +% A matching attribute will be defined later for LuaTeX. +% \begin{macrocode} +\newif\ifFB@spacing \FB@spacingtrue +% \end{macrocode} +% +% \begin{macro}{\FB@spacing@off} +% \begin{macro}{\FB@spacing@on} +% Two internal commands to switch on and off all space tuning +% for all six characters `;:!?«»'. +% They will be triggered by user command |\NoAutoSpacing| and by +% font family switching commands |\ttfamilyFB| |\rmfamilyFB| and +% |\sffamilyFB|. These four commands will now behave the same with +% any engine (up to version 3.2b, results were engine dependent). +% \begin{macrocode} +\newcommand*{\FB@spacing@on}{% + \ifFB@luatex@punct + \FB@spacing=1 \relax + \else + \FB@spacingtrue + \fi} +\newcommand*{\FB@spacing@off}{% + \ifFB@luatex@punct + \FB@spacing=0 \relax + \else + \FB@spacingfalse + \fi} +% \end{macrocode} +% \end{macro} +% \end{macro} % % \subsubsection{Punctuation with LuaTeX} % \label{sssec-punct-luatex} @@ -1135,6 +1181,8 @@ % \changes{v3.2b}{2016/04/18}{Load ltluatex.tex for plain LuaTeX to % ensure \cs{newattribute} is defined.} % +% \changes{v3.2c}{2016/05/14}{New LuaTeX attribute \cs{FB@spacing}.} +% % The following |\directlua| call ensures compatibility with LaTeX % releases prior to 2015/10/01: the |\localleftbox| primitive% % \footnote{used by \cs{frquote}, see p.~\pageref{cs:localleftbox}.} @@ -1145,7 +1193,7 @@ \directlua{tex.enableprimitives("", tex.extraprimitives("omega"))} % \end{macrocode} % -% We define two LuaTeX attributes to control spacing in French +% We define three LuaTeX attributes to control spacing in French % for `high punctuation' and quotes, making sure that % |\newattribute| is defined. % \begin{macrocode} @@ -1157,6 +1205,18 @@ % \begin{macrocode} \input ltluatex.tex \fi +% \end{macrocode} +% |\FB@spacing=0| switches off any space tuning both before high +% punctuation characters and inside French quotes (i.e.\ function +% |french_punctuation| doesn't alter the node list at all). +% |\FB@addDPspace=0| switches off automatic insertion of spaces +% before high punctuation characters (but typed spaces are still +% turned into nobreak thin- or word-spaces). +% |\FB@addGUILspace| will be set to~1 by option \fbo{og=«, fg=»}, +% thus enabling automatic insertion of proper spaces after `«' and +% before `»'. +% \begin{macrocode} + \newattribute\FB@spacing \FB@spacing=1 \relax \newattribute\FB@addDPspace \FB@addDPspace=1 \relax \newattribute\FB@addGUILspace \FB@addGUILspace=0 \relax \ifLaTeXe @@ -1174,14 +1234,16 @@ %</ldf> %<*lua> % \fi -% \file{frenchb.lua} holds Lua code to deal with `high punctuation' -% and quotes. This code is based on suggestions from Paul Isambert. +% This is \file{frenchb.lua}. It holds Lua code to deal with `high +% punctuation' and quotes. This code is based on suggestions from +% Paul Isambert. % +% \begin{macro}{frenchb.lua} % First we define two flags to control spacing before French `high % punctuation' (thin space or inter-word space). % -% \changes{v3.1a}{2014/06/16}{frenchb.lua: codes 0x13 and 0x14 added -% for French quotes in T1-encoding.} +% \changes{v3.1a}{2014/06/16}{Codes 0x13 and 0x14 added for French +% quotes in T1-encoding.} % % \begin{macrocode} local FB_punct_thin = @@ -1229,8 +1291,8 @@ local FB_guil_null = {[0xA0] = true, [0x202F] = true} % \end{macrocode} -% \changes{v3.1g}{2015/06/17}{frenchb.lua: node HLIST added; node TEMP -% added for the first node of \cs{hbox}es.} +% \changes{v3.1g}{2015/06/17}{Node HLIST added; node TEMP added +% for the first node of \cs{hbox}es.} % % Local definitions for nodes: % \begin{macrocode} @@ -1273,15 +1335,15 @@ local guilsh = guil10.shrink/65536/1.11 % lcircle1.pfb for which |font.getfont(fid)| does not return % a proper font table, in such cases the function returns |nil|): % -% \changes{v3.1l}{2016/02/13}{frenchb.lua: font.getfont(fid) possibly +% \changes{v3.1l}{2016/02/13}{font.getfont(fid) possibly % returns nil even for a positive fid (i.e. AMS lcircle1.pfb). % Reported by François Legendre.} % -% \changes{v3.1m}{2016/02/16}{frenchb.lua: new\_glue\_scaled returns +% \changes{v3.1m}{2016/02/16}{new\_glue\_scaled returns % nil in case of invalid font table (i.e. lcircle1.pfb). In such % cases frenchb leaves the node list unchanged.} % -% \changes{v3.2b}{2016/04/18}{frenchb.lua: glue\_spec removed; +% \changes{v3.2b}{2016/04/18}{glue\_spec removed; % starting with LuaTeX 0.95, glue specifications fit in glue.} % % \begin{macrocode} @@ -1310,10 +1372,11 @@ local function new_glue_scaled (fid,width,stretch,shrink) end end % \end{macrocode} -% Let's catch LuaTeX attributes |\FB@addDPspace| and -% |\FB@addGUILspace|. Constant |FR=lang.id(french)| will be +% Let's catch LuaTeX attributes |\FB@spacing|, |\FB@addDPspace| +% and |\FB@addGUILspace|. Constant |FR=lang.id(french)| will be % defined by command |\activate@luatexpunct|. % \begin{macrocode} +local FBspacing = luatexbase.attributes['FB@spacing'] local addDPspace = luatexbase.attributes['FB@addDPspace'] local addGUILspace = luatexbase.attributes['FB@addGUILspace'] local has_attribute = node.has_attribute @@ -1328,7 +1391,7 @@ local has_attribute = node.has_attribute % the current glyph (|item|) and of the previous one (|prev|) or the % next one (|next|). % -% \changes{v3.1b}{2014/09/16}{frenchb.lua: add a check for null fid +% \changes{v3.1b}{2014/09/16}{Add a check for null fid % in french\_punctuation (Tikz \cs{nullfont}). % Bug pointed out by Paul Gaborit.} % @@ -1338,8 +1401,12 @@ local function french_punctuation (head) local lang = item.lang local char = item.char local fid = item.font + local FRspacing = has_attribute(item, FBspacing) + FRspacing = FRspacing and FRspacing > 0 local SIG = has_attribute(item, addGUILspace) - if lang == FR and FB_punct_left[char] and fid > 0 then + SIG = SIG and SIG >0 + if lang == FR and FRspacing and + FB_punct_left[char] and fid > 0 then local prev = item.prev local prev_id, prev_subtype, prev_char if prev then @@ -1351,12 +1418,12 @@ local function french_punctuation (head) end % \end{macrocode} % -% \changes{v3.0c}{2014/04/18}{frenchb.lua: null glues should not +% \changes{v3.0c}{2014/04/18}{Null glues should not % trigger space insertion before high ponctuation. Bug pointed out % by Benoit Rivet for the `lstlisting' environment of the listings % package.} % -% \changes{v3.1c}{2014/10/25}{frenchb.lua: Previous bug fix for null +% \changes{v3.1c}{2014/10/25}{Previous bug fix for null % glues (v3.0c) did not work properly. Fixed now (I hope!). % Pointed out by Jacques André.} % @@ -1375,12 +1442,12 @@ local function french_punctuation (head) % \emph{true}, the amount of spacing to be typeset before them % is controlled by |\FBthinskip| (|thinwd|, |thinst|, |thinsh|) or % |\FBcolonskip| (|colnwd|, |colnst|, |colnsh|) respectively. -% Two options: if a space has been typed in before (turned to +% Two options: if a space has been typed in before (turned into % \emph{glue} in the node list), we remove the \emph{glue} and add a % nobreak penalty and the required \emph{glue}. % Otherwise (|auto| option), the penalty and the required % \emph{glue} are inserted if attribute |\FB@addDPspace| is set, -% unless one of these three condition is met: +% unless one of these three conditions is met: % a) the previous character is part of type |FB_punct_null| (this % avoids spurious spaces in strings like |(!)| or |??|), % b) a null glue (actually glues <= 1 sp for tabulars) preceeds the @@ -1428,16 +1495,16 @@ local function french_punctuation (head) % b) `»' is the first glyph of an |\hbox{}| or a paragraph, nothing % is done, this is controlled by the |addgl| flag. % -% \changes{v3.1a}{2014/06/18}{frenchb.lua: added flag addgl which must -% also be true when prev or next is not a char (i.e. kern0 in +% \changes{v3.1a}{2014/06/18}{Added flag addgl which must also be true +% when prev or next is not a char (i.e. kern0 in % «\cs{texttt}\{a\}»).} % -% \changes{v3.1g}{2015/06/26}{frenchb.lua: flag addgl set to false for -% `»' at the beginning of an \cs{hbox} or a paragraph or a tabular +% \changes{v3.1g}{2015/06/26}{flag addgl set to false for `»' +% at the beginning of an \cs{hbox} or a paragraph or a tabular % `l' and `c' columns.} % % \begin{macrocode} - elseif SIG and SIG > 0 then + elseif SIG then local addgl = (prev_char and not FB_guil_null[prev_char]) or (not prev_char and prev_id ~= TEMP and @@ -1469,16 +1536,16 @@ local function french_punctuation (head) % a nobreak penalty so that finally the penalty preceeds the % \emph{glue}. % -% \changes{v3.1a}{2014/06/18}{frenchb.lua: look ahead when next is a kern +% \changes{v3.1a}{2014/06/18}{Look ahead when next is a kern % (i.e. in « \cs{texttt}\{a\} »).} % -% \changes{v3.1g}{2015/06/26}{frenchb.lua: flag addgl set to false for +% \changes{v3.1g}{2015/06/26}{Flag addgl set to false for % `«' at the end of an \cs{hbox} or a paragraph or when followed by % a null glue (i.e. springs).} % % \begin{macrocode} - if lang == FR and FB_punct_right[char] and fid > 0 - and SIG and SIG > 0 then + if lang == FR and FRspacing and FB_punct_right[char] + and fid > 0 and SIG then local next = item.next local next_id, next_subtype, next_char, nextnext, kern_wd if next then @@ -1534,6 +1601,7 @@ local function french_punctuation (head) end return french_punctuation % \end{macrocode} +% \end{macro} % \iffalse %</lua> %<*ldf> @@ -1746,6 +1814,9 @@ return french_punctuation % using \cs{babel@savevariable} and \cs{babel@save}, % \cs{XeTeXcharclass}(es) using \cs{FB@savevariable@loop}.} % +% \changes{v3.2c}{2016/05/14}{Switch \cs{ifFB@spacing} added to all +% \cs{XeTeXinterchartoks} commands.} +% % \begin{macrocode} \newcommand*{\FB@xetex@punct@french}{% \babel@savevariable{\XeTeXinterchartokenstate}% @@ -1766,13 +1837,17 @@ return french_punctuation \def\shorthandon##1{}% % \end{macrocode} % Let's now set the classes and interactions between classes. +% When false, the flag |\ifFB@spacing| switches off any interaction +% between classes (this flag is controlled by user-level command +% |\NoAutoSpacing|; this flag is also set to false when the current +% font is a typewriter font). % \begin{macrocode} \XeTeXinterchartokenstate=1 \XeTeXcharclass `\: = \FB@punctthick \XeTeXinterchartoks \z@ \FB@punctthick = {% - \ifhmode\FDP@colonspace\fi}% + \ifFB@spacing\ifhmode\FDP@colonspace\fi\fi}% \XeTeXinterchartoks \FB@guilf \FB@punctthick = {% - \FDP@colonspace}% + \ifFB@spacing\FDP@colonspace\fi}% % \end{macrocode} % Small glues such as ``glue 1sp'' in tabular `l' columns or ``glue % 0 plus 1 fil'' in tabular `c' columns or \env{lstlisting} @@ -1783,38 +1858,42 @@ return french_punctuation % cannot be omitted. % \begin{macrocode} \XeTeXinterchartoks \FB@nonchar \FB@punctthick = {% - \ifhmode - \ifdim\lastskip>1sp - \unskip\penalty\@M\FBcolonspace - \else - \FDP@colonspace - \fi - \fi}% + \ifFB@spacing + \ifhmode + \ifdim\lastskip>1sp + \unskip\penalty\@M\FBcolonspace + \else + \FDP@colonspace + \fi + \fi + \fi}% \bbl@for\FB@char {`\;,`\!,`\?}% {\XeTeXcharclass\FB@char=\FB@punctthin}% \XeTeXinterchartoks \z@ \FB@punctthin = {% - \ifhmode\FDP@thinspace\fi}% + \ifFB@spacing\ifhmode\FDP@thinspace\fi\fi}% \XeTeXinterchartoks \FB@guilf \FB@punctthin = {% - \FDP@thinspace}% + \ifFB@spacing\FDP@thinspace\fi}% \XeTeXinterchartoks \FB@nonchar \FB@punctthin = {% - \ifhmode - \ifdim\lastskip>1sp - \unskip\penalty\@M\FBthinspace - \else - \FDP@thinspace - \fi - \fi}% + \ifFB@spacing + \ifhmode + \ifdim\lastskip>1sp + \unskip\penalty\@M\FBthinspace + \else + \FDP@thinspace + \fi + \fi + \fi}% \XeTeXinterchartoks \FB@guilo \z@ = {% - \ifFBAutoSpaceGuill\FBguillspace\fi}% + \ifFB@spacing\FBguillspace\fi}% \XeTeXinterchartoks \FB@guilo \FB@nonchar = {% - \ifFBAutoSpaceGuill\FBguillspace\ignorespaces\fi}% + \ifFB@spacing\FBguillspace\ignorespaces\fi}% \XeTeXinterchartoks \z@ \FB@guilf = {% - \ifFBAutoSpaceGuill\FBguillspace\fi}% + \ifFB@spacing\FBguillspace\fi}% \XeTeXinterchartoks \FB@punctthin \FB@guilf = {% - \ifFBAutoSpaceGuill\FBguillspace\fi}% + \ifFB@spacing\FBguillspace\fi}% \XeTeXinterchartoks \FB@nonchar \FB@guilf = {% - \ifFBAutoSpaceGuill\unskip\FBguillspace\fi}% + \ifFB@spacing\unskip\FBguillspace\fi}% % \end{macrocode} % This will avoid spurious spaces in (!), [?] and with Unicode % nobreakspaces (U+00A0, U+202F): @@ -1865,8 +1944,12 @@ return french_punctuation % changed from 0pt to 1sp for active punctuation for consistency % with XeTeX and LuaTeX.} % +% \changes{v3.2c}{2016/05/14}{Switch \cs{ifFB@spacing} added to the +% four French shorthands.} +% % \begin{macrocode} \declare@shorthand{french}{;}{% + \ifFB@spacing \ifhmode \ifdim\lastskip>1sp \unskip\penalty\@M\FBthinspace @@ -1874,14 +1957,16 @@ return french_punctuation \FDP@thinspace \fi \fi + \fi % \end{macrocode} % Now we can insert a |;| character. % \begin{macrocode} - \string;} + \string;} % \end{macrocode} % The next three definitions are very similar. % \begin{macrocode} \declare@shorthand{french}{!}{% + \ifFB@spacing \ifhmode \ifdim\lastskip>1sp \unskip\penalty\@M\FBthinspace @@ -1889,8 +1974,10 @@ return french_punctuation \FDP@thinspace \fi \fi - \string!} + \fi + \string!} \declare@shorthand{french}{?}{% + \ifFB@spacing \ifhmode \ifdim\lastskip>1sp \unskip\penalty\@M\FBthinspace @@ -1898,8 +1985,10 @@ return french_punctuation \FDP@thinspace \fi \fi - \string?} + \fi + \string?} \declare@shorthand{french}{:}{% + \ifFB@spacing \ifhmode \ifdim\lastskip>1sp \unskip\penalty\@M\FBcolonspace @@ -1907,7 +1996,8 @@ return french_punctuation \FDP@colonspace \fi \fi - \string:} + \fi + \string:} % \end{macrocode} % When the active characters appear in an environment where their % French behaviour is not wanted they should give an `expected' @@ -2008,10 +2098,12 @@ return french_punctuation % In \LaTeXe{} |\ttfamily| (and hence |\texttt|) will be redefined % `AtBeginDocument' as |\ttfamilyFB| so that no space % is added before the four |; : ! ?| characters, even if -% \fbo{AutoSpacePunctuation} is \fbo{true}. |\rmfamily| and -% |\sffamily| need to be redefined also (|\ttfamily| is not always -% used inside a group, its effect can be cancelled by |\rmfamily| or -% |\sffamily|). +% \fbo{AutoSpacePunctuation} is \fbo{true}. When +% \fbo{AutoSpacePunctuation} is \fbo{false}, the eventually typed +% spaces are left unchanged (not turned into thinspaces, no penalty +% added). |\rmfamily| and |\sffamily| need to be redefined also +% (|\ttfamily| is not always used inside a group, its effect can be +% cancelled by |\rmfamily| or |\sffamily|). % % These redefinitions can be canceled if necessary, for instance to % recompile older documents, see option \fbo{OriginalTypewriter} @@ -2021,6 +2113,10 @@ return french_punctuation % automatic spaces inside French guillemets entered as characters % (see \cs{frenchbsetup}).} % +% \changes{v3.2c}{2016/05/14}{New definitions of \cs{ttfamilyFB} and +% co, common to all engines, based on \cs{FB@spacing@off} +% and\cs{FB@spacing@on}.} +% % To be consistent with what is done for the |; : ! ?| % characters, |\ttfamilyFB| also switches off insertion of spaces % inside French guillemets \emph{when they are typed in as @@ -2030,28 +2126,9 @@ return french_punctuation % % \begin{macrocode} \ifLaTeXe - \DeclareRobustCommand\ttfamilyFB{% - \FBAutoSpaceGuillfalse - \ifFB@luatex@punct\FB@addGUILspace=0 \fi - \noautospace@beforeFDP\ttfamilyORI}% - \DeclareRobustCommand\rmfamilyFB{% - \FBAutoSpaceGuilltrue - \ifFB@luatex@punct\FB@addGUILspace=1 \fi - \ifFBAutoSpacePunctuation - \autospace@beforeFDP - \else - \noautospace@beforeFDP - \fi - \rmfamilyORI}% - \DeclareRobustCommand\sffamilyFB{% - \FBAutoSpaceGuilltrue - \ifFB@luatex@punct\FB@addGUILspace=1 \fi - \ifFBAutoSpacePunctuation - \autospace@beforeFDP - \else - \noautospace@beforeFDP - \fi - \sffamilyORI}% + \DeclareRobustCommand\ttfamilyFB{\FB@spacing@off \ttfamilyORI} + \DeclareRobustCommand\rmfamilyFB{\FB@spacing@on \rmfamilyORI} + \DeclareRobustCommand\sffamilyFB{\FB@spacing@on \sffamilyORI} \fi % \end{macrocode} % \end{macro} @@ -2062,25 +2139,21 @@ return french_punctuation % suggested by MPG.} % % \begin{macro}{\NoAutoSpacing} -% The following command will disable automatic spacing for high +% The following command disables automatic spacing for high % punctuation and French quote characters; it also switches off % active punctuation characters (if any). % It is engine independent (works for TeX, LuaTeX and % XeTeX based engines) and is meant to be used inside a group. % -% \changes{v3.2b}{2016/04/18}{\cs{noautospace@beforeFDP} added to -% \cs{NoAutoSpacing} in case of active punctuation. -% \cs{NoAutoSpacing} made robust.} +% \changes{v3.2b}{2016/04/18}{\cs{NoAutoSpacing} made robust.} +% +% \changes{v3.2c}{2016/05/14}{New definition based on +% \cs{FB@spacing@off} common to all engines.} % -% In case |\NoAutoSpacing| is used in moving arguments (footnotes, -% headers, etc.) |\noautospace@beforeFDP| will do the job (catcode -% changes are not taken into account, |\shorthandoff{;:!?}| does -% nothing). % \begin{macrocode} -\DeclareRobustCommand*{\NoAutoSpacing}{\FBAutoSpaceGuillfalse - \ifFB@active@punct\noautospace@beforeFDP\shorthandoff{;:!?}\fi - \ifFB@xetex@punct\XeTeXinterchartokenstate=0 \fi - \ifFB@luatex@punct\FB@addDPspace=0 \FB@addGUILspace=0 \fi +\DeclareRobustCommand*{\NoAutoSpacing}{% + \FB@spacing@off + \ifFB@active@punct\shorthandoff{;:!?}\fi } % \end{macrocode} % \end{macro} @@ -2155,7 +2228,8 @@ return french_punctuation % % LuaTeX which requires skips; |\FBguillskip| is computed from % |\FBguillspace| for the |lmr10| font, its dimensions will -% be scaled by \file{frenchb.lua} for the current font. +% be scaled by \file{frenchb.lua} for the current font and used +% after `«' and before `»' when option \fbo{og=«, fg=»} is set. % \begin{macrocode} \newskip\FBguillskip \FBguillskip=2.664pt plus 0.500pt minus 0.888pt \relax @@ -2163,27 +2237,31 @@ return french_punctuation plus.3\fontdimen3\font minus.8\fontdimen4\font} % \end{macrocode} -% |\FBguillspace| is not used with LuaTeX. +% For efficiency reasons, |\FB@og| and |\FB@fg| relie on +% |\FBguillspace| with LuaTeX engines (|\FB@spacing| is set +% to~0 locally). % \begin{macrocode} \ifFB@luatex@punct \DeclareRobustCommand*{\FB@og}{\leavevmode - \bgroup\FB@addGUILspace=1 \guillemotleft\egroup} + \bgroup\FB@spacing=0 \guillemotleft\egroup + \FBguillspace} \DeclareRobustCommand*{\FB@fg}{\ifdim\lastskip>\z@\unskip\fi - \bgroup\FB@addGUILspace=1 \guillemotright\egroup} + \FBguillspace + \bgroup\FB@spacing=0 \guillemotright\egroup} \fi % \end{macrocode} -% With XeTeX, |\FBAutoSpaceGuill| is set to |false| locally to +% With XeTeX, |\ifFB@spacing| is set to |false| locally to % prevent the quotes characters from adding space when option % \fbo{og=«, fg=»} is set. % characters. % \begin{macrocode} \ifFB@xetex@punct \DeclareRobustCommand*{\FB@og}{\leavevmode - \bgroup\FBAutoSpaceGuillfalse\guillemotleft\egroup + \bgroup\FB@spacingfalse\guillemotleft\egroup \FBguillspace} \DeclareRobustCommand*{\FB@fg}{\ifdim\lastskip>\z@\unskip\fi \FBguillspace - \bgroup\FBAutoSpaceGuillfalse\guillemotright\egroup} + \bgroup\FB@spacingfalse\guillemotright\egroup} \fi \ifFB@active@punct \DeclareRobustCommand*{\FB@og}{\leavevmode @@ -3165,7 +3243,7 @@ return french_punctuation % No warning with the \cls{beamer} class which defines % |\beamer@makecaption| (customised below) instead of % |\@makecaption|. No warning either if |\@makecaption| is -% undefined (i.e. \cls{letter}). +% undefined (i.e.\ \cls{letter}). % \begin{macrocode} \@ifclassloaded{beamer}{\@FBwarning@capsepfalse}{} \ifdefined\@makecaption\else\@FBwarning@capsepfalse\fi @@ -3380,12 +3458,12 @@ return french_punctuation % occurs \emph{before} reading the stuff postponed by \frenchb{} % `AtBeginDocument'. Reexecuting |\extrasfrench{}| is an option % which was used up to v2.6h, it has been dropped in v3.0a because -% of its side-effects (f.i. |\babel@save| and |\babel@savevariable| +% of its side-effects (f.i.\ |\babel@save| and |\babel@savevariable| % did not work for French). % % \begin{macro}{\frenchbsetup} % Let's now define this command which reads and sets the options -% to be processed either immediately (i.e. just after setting the +% to be processed either immediately (i.e.\ just after setting the % key) or later (at |\begin{document}|) by |\FBprocess@options|. % \fbsetup{} can only be called in the preamble. % @@ -3430,11 +3508,6 @@ return french_punctuation % French becomes the document's main language, so % GlobalLayoutFrench applies.} % -% \changes{v2.3a}{2008/10/10}{New option: OriginalTypewriter. Now -% frenchb switches to \cs{noautospace@beforeFDP} when a tt-font is -% in use. When OriginalTypewriter is set to true, frenchb behaves -% as in pre-2.3 versions.} -% % \changes{v2.4a}{2009/11/23}{New option SuppressWarning.} % % \changes{v2.6a}{2013/01/30}{New options ListOldLayout, @@ -3464,7 +3537,6 @@ return french_punctuation }% \@onlypreamble\frenchbsetup % \end{macrocode} -% \end{macro} % % We define a collection of conditionals with their defaults % (true or false). @@ -3722,9 +3794,6 @@ return french_punctuation % automatic spaces inside French guillemets coded as characters % (see \cs{frenchbsetup}).} % -% \changes{v2.5c}{2011/01/16}{The code meant for XeTeX also works for -% LuaTeX, we just need to change the test.} -% % \changes{v2.5g}{2011/12/31}{When \cs{ifFB@xetex@punct} is true, % `og' and `fg' options now set XeTeXcharclasses of these characters % to \cs{FB@guilo} and \cs{FB@guilf}. Otherwise French @@ -3737,6 +3806,9 @@ return french_punctuation % quotes in T1-encoding. Support for older versions of LuaTeX and % XeTeX dropped.} % +% \changes{v3.2c}{2016/05/03}{Add a warning about options og/fg for old +% XeTeX or LuaTeX engines requiring active characters.} +% % \begin{macrocode} \define@key{FB}{og}{% \ifFBunicode @@ -3761,13 +3833,22 @@ return french_punctuation \XeTeXcharclass"A0 = \FB@guilnul \XeTeXcharclass"202F = \FB@guilnul \fi +% \end{macrocode} +% Issue a warning with older Unicode engines requiring active +% characters. +% \begin{macrocode} + \ifFB@active@punct + \FBWarning{frenchb.ldf}% + {Option og=« not supported with this version + of\MessageBreak LuaTeX/XeTeX; reported}% + \fi \else % \end{macrocode} % This is for conventional TeX engines: % \begin{macrocode} \newcommand*{\FB@@og}{% \iflanguage{french}% - {\ifFBAutoSpaceGuill\FB@og\ignorespaces + {\ifFB@spacing\FB@og\ignorespaces \else\guillemotleft \fi}% {\guillemotleft}}% @@ -3826,10 +3907,15 @@ return french_punctuation \XeTeXcharclass"A0 = \FB@guilnul \XeTeXcharclass"202F = \FB@guilnul \fi + \ifFB@active@punct + \FBWarning{frenchb.ldf}% + {Option fg=» not supported with this version + of\MessageBreak LuaTeX/XeTeX; reported}% + \fi \else \newcommand*{\FB@@fg}{% \iflanguage{french}% - {\ifFBAutoSpaceGuill\FB@fg + {\ifFB@spacing\FB@fg \else\guillemotright \fi}% {\guillemotright}}% @@ -3858,6 +3944,7 @@ return french_punctuation }% } % \end{macrocode} +% \end{macro} % % \begin{macro}{\FBprocess@options} % |\FBprocess@options| will be executed at |\begin{document}|: @@ -4744,7 +4831,7 @@ return french_punctuation % % The next command prints the footnote mark according to the % specifications of the French `Imprimerie Nationale'. -% Keep in mind that |\@thefnmark| might be empty (i.e. in +% Keep in mind that |\@thefnmark| might be empty (i.e.\ in % AMS classes' titles)! % \begin{macrocode} \providecommand*{\insertfootnotemarkFB}{% |