diff options
author | Karl Berry <karl@freefriends.org> | 2019-01-09 22:44:11 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-01-09 22:44:11 +0000 |
commit | cb2b57ca95d65bf9d9d21ec4a0109380f1e50fc0 (patch) | |
tree | 48c9056564b4dba8e32b6d00f7c22cefc3de1a2f /Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx | |
parent | 94380fc2b70b1177954ffb6f51328f62ea0d07a8 (diff) |
fontspec (9jan19)
git-svn-id: svn://tug.org/texlive/trunk@49650 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx | 209 |
1 files changed, 209 insertions, 0 deletions
diff --git a/Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx b/Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx new file mode 100644 index 00000000000..2df1d18f3fe --- /dev/null +++ b/Master/texmf-dist/source/latex/fontspec/fontspec-code-patches.dtx @@ -0,0 +1,209 @@ +%%^^A%% fontspec-code-patches.dtx -- part of FONTSPEC <wspr.io/fontspec> + +% \section{Patching code} +% +% \begin{macrocode} +%<*fontspec> +% \end{macrocode} +% +% \subsection{\cmd\-} +% +% \begin{macro}{\-} +% This macro is courtesy of Frank Mittelbach and the \LaTeXe\ source code. +% \begin{macrocode} +\DeclareRobustCommand{\-} + { + \discretionary + { + \char\ifnum\hyphenchar\font<\z@ + \xlx@defaulthyphenchar + \else + \hyphenchar\font + \fi + }{}{} + } +\def\xlx@defaulthyphenchar{`\-} +% \end{macrocode} +% \end{macro} +% +% +% \subsection{Verbatims} +% +% Many thanks to Apostolos Syropoulos for discovering this problem and writing the redefinion of \LaTeX's |verbatim| environment and \cs{verb*} command. +% +% \begin{macro}{\fontspec_visible_space:} +% Print \unichar{2423}{Open box}, which is used to visibly display a space character. +% \begin{macrocode} +\cs_new:Nn \fontspec_visible_space: + { + \@@_primitive_font_glyph_if_exist:NnTF \font {"2423} + { \char"2423\scan_stop: } + { \fontspec_visible_space_fallback: } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fontspec_visible_space_fallback:} +% If the current font doesn't have \unichar{2423}{Open box}, use Latin Modern Mono instead. +% \begin{macrocode} +\cs_new:Nn \fontspec_visible_space_fallback: + { + { + \usefont{\g_fontspec_encoding_tl}{lmtt}{\f@series}{\f@shape} + \textvisiblespace + } + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fontspec_print_visible_spaces:} +% Helper macro to turn spaces (\verb|^^20|) active and print visible space instead. +% \begin{macrocode} +\group_begin: +\char_set_catcode_active:n{"20}% +\cs_gset:Npn\fontspec_print_visible_spaces:{% +\char_set_catcode_active:n{"20}% +\cs_set_eq:NN^^20\fontspec_visible_space:% +}% +\group_end: +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\verb} +% \begin{macro}{\verb*} +% Redefine \cmd\verb\ to use \cmd\fontspec_print_visible_spaces:. +% \begin{macrocode} +\def\verb + { + \relax\ifmmode\hbox\else\leavevmode\null\fi + \bgroup + \verb@eol@error \let\do\@makeother \dospecials + \verbatim@font\@noligs + \@ifstar\@@sverb\@verb + } +\def\@@sverb{\fontspec_print_visible_spaces:\@sverb} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% It's better to put small things into \cmd\AtBeginDocument, so here we go: +% \begin{macrocode} +\AtBeginDocument + { + \fontspec_patch_verbatim: + \fontspec_patch_moreverb: + \fontspec_patch_fancyvrb: + \fontspec_patch_listings: + } +% \end{macrocode} +% +% \begin{environment}{verbatim*} +% With the \pkg{verbatim} package. +% \begin{macrocode} +\cs_set:Npn \fontspec_patch_verbatim: + { + \@ifpackageloaded{verbatim} + { + \cs_set:cpn {verbatim*} + { + \group_begin: \@verbatim \fontspec_print_visible_spaces: \verbatim@start + } + } +% \end{macrocode} +% This is for vanilla \LaTeX. +% \begin{macrocode} + { + \cs_set:cpn {verbatim*} + { + \@verbatim \fontspec_print_visible_spaces: \@sxverbatim + } + } + } +% \end{macrocode} +% \end{environment} +% +% \begin{environment}{listingcont*} +% This is for \pkg{moreverb}. +% The main |listing*| environment inherits this definition. +% \begin{macrocode} +\cs_set:Npn \fontspec_patch_moreverb: + { + \@ifpackageloaded{moreverb} + { + \cs_set:cpn {listingcont*} + { + \cs_set:Npn \verbatim@processline + { + \thelisting@line \global\advance\listing@line1\relax + \the\verbatim@line\par + } + \@verbatim \fontspec_print_visible_spaces: \verbatim@start + } + }{} + } +% \end{macrocode} +% \end{environment} +% +% \pkg{listings} and \pkg{fancvrb} make things nice and easy: +% \begin{macrocode} +\cs_set:Npn \fontspec_patch_fancyvrb: + { + \@ifpackageloaded{fancyvrb} + { + \cs_set_eq:NN \FancyVerbSpace \fontspec_visible_space: + }{} + } +% \end{macrocode} +% +% \begin{macrocode} +\cs_set:Npn \fontspec_patch_listings: + { + \@ifpackageloaded{listings} + { + \cs_set_eq:NN \lst@visiblespace \fontspec_visible_space: + }{} + } +% \end{macrocode} +% +% \subsection{\cs{oldstylenums}} +% +% +% \begin{macro}{\oldstylenums} +% \begin{macro}{\liningnums} +% This command obviously needs a redefinition. +% And we may as well provide the reverse command. +% \begin{macrocode} +\RenewDocumentCommand \oldstylenums {m} + { + { \addfontfeature{Numbers=OldStyle} #1 } + } +\NewDocumentCommand \liningnums {m} + { + { \addfontfeature{Numbers=Lining} #1 } + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% +% \begin{macrocode} +%</fontspec> +% \end{macrocode} + + +\endinput + +% /© +% ------------------------------------------------ +% The FONTSPEC package <wspr.io/fontspec> +% ------------------------------------------------ +% Copyright 2004-2019 Will Robertson, LPPL "maintainer" +% Copyright 2009-2015 Khaled Hosny +% Copyright 2013 Philipp Gesang +% Copyright 2013-2016 Joseph Wright +% ------------------------------------------------ +% This package is free software and may be redistributed and/or modified under +% the conditions of the LaTeX Project Public License, version 1.3c or higher +% (your choice): <http://www.latex-project.org/lppl/>. +% ------------------------------------------------ +% ©/ |