diff options
author | Karl Berry <karl@freefriends.org> | 2013-05-28 00:15:30 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-05-28 00:15:30 +0000 |
commit | 1c6157c57b3a33d9b44027ccc44ef1e02f98d51c (patch) | |
tree | ac53f3e7e929f9120e3b8773c84dc5fd2d041e6d /Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty | |
parent | dbdbad08ea450f135cc574f9dc001088b0d042de (diff) |
selnolig
git-svn-id: svn://tug.org/texlive/trunk@30745 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty')
-rw-r--r-- | Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty | 251 |
1 files changed, 251 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty b/Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty new file mode 100644 index 00000000000..7d56624a157 --- /dev/null +++ b/Master/texmf-dist/tex/lualatex/selnolig/selnolig.sty @@ -0,0 +1,251 @@ +% !TeX root = selnolig.tex +% !TEX TS-program = lualatex + +% This entire package is placed under the terms of the +% LaTeX Project Public License, version 1.3 or later +% (http://www.latex-project.org/lppl.txt). +% It has the status "maintained". +% +% Author: Mico Loretan (loretan dot mico at gmail dot com) + + +% Part 1: Preliminaries +% --------------------- + +\def\selnoligpackagename{selnolig} +\def\selnoligpackageversion{0.216} +\def\selnoligpackagedate{2013/05/25} + +% Announce who we are. Issue warning message if we're +% not running under LuaLaTeX. + +\typeout{=== Package \selnoligpackagename, + Version \selnoligpackageversion, + Date \selnoligpackagedate ===} +\ProvidesPackage{selnolig}[\selnoligpackagedate] + +\RequirePackage{ifluatex} + +\ifluatex + \RequirePackage{luatexbase,luacode,expl3} +\else + \typeout{ ======================================= } + \typeout{ WARNING WARNING WARNING } + \typeout{ --------------------------------------- } + \typeout{ The ligature suppression macros of the } + \typeout{ selnolig package *require* LuaLaTeX. } + \typeout{ Because you're NOT running this package } + \typeout{ under LuaLaTeX, ligature suppression } + \typeout{ *can not* be performed. } + \typeout{=========================================} +\fi + + +% If the 'fontspec' package isn't loaded by the time +% the '\begin{document}' directive is encoutered, issue +% an error message and exit. + +\AtBeginDocument{% +\ifluatex + \@ifpackageloaded{fontspec}{}{% + \PackageError{selnolig}{% + ========================================== \MessageBreak + Error Alert Error Alert \MessageBreak + ------------------------------------------ \MessageBreak + The selnolig package *requires* the \MessageBreak + 'fontspec' package, but it hasn't been \MessageBreak + loaded. Exiting now. \MessageBreak + ===========================================} + } +\fi +} + +% Set up some fundamental Boolean variables, their +% default values, and define the user options. + +% The main language options are 'english' and 'german'. +% We provide the option 'otherlang' option just in case +% a user wants to provide ligature suppression patterns +% for languages other than English and German. + +\newif\if@english\@englishfalse +\newif\if@german\@germanfalse +\newif\if@otherlang\@otherlangfalse + +\DeclareOption{english}{\@englishtrue} +% synonymous options: + \DeclareOption{usenglish}{\@englishtrue} + \DeclareOption{ukenglish}{\@englishtrue} + \DeclareOption{USenglish}{\@englishtrue} + \DeclareOption{UKenglish}{\@englishtrue} + \DeclareOption{american}{\@englishtrue} + \DeclareOption{british}{\@englishtrue} + \DeclareOption{canadian}{\@englishtrue} + \DeclareOption{australian}{\@englishtrue} + \DeclareOption{newzealand}{\@englishtrue} + +\DeclareOption{ngerman}{\@germantrue} +% synonymous options: + \DeclareOption{german}{\@germantrue} + \DeclareOption{austrian}{\@germantrue} + \DeclareOption{naustrian}{\@germantrue} + \DeclareOption{swiss}{\@germantrue} + \DeclareOption{swissgerman}{\@germantrue} + +\DeclareOption{otherlang}{\@otherlangtrue} +% synonymous option: + \DeclareOption{otherlanguage}{\@otherlangtrue} + + +% For English, the default is to load only a fairly basic +% set of non-ligation rules pertaining to f-ligatures. +% Among them are the "standard five" (ff, fi, fl, ffi, +% and ffl) ligatures as well as the ft ligature. +% +% Two options to override this "basic" setting: +% - broadf Many more non-ligation rules for f-ligatures, +% incl. fb, fh, fj, and fk character pairs. +% - hdlig Additional ligature suppression rules for +% 'historic' and/or 'discretionary' ligatures, +% e.g., ct, sp, st, sk, th, as, is, us, fr, +% ll, et, at, and ta. + +\newif\if@broadfset\@broadfsetfalse +\DeclareOption{broadf}{\@broadfsettrue} + +\newif\if@hdligset\@hdligsetfalse +\DeclareOption{hdlig}{\@hdligsettrue} + + +% The package also provides hyphenation exception +% patterns for English and German language words. +% Loading these patterns is enabled by default. This +% can be disabled by providing the option +% 'noadditionalhyphenationpatterns'. + +\newif\if@addlhyph\@addlhyphtrue +\DeclareOption{noadditionalhyphenationpatterns}{\@addlhyphfalse} + + +% The 'basic' option automatically sets the preceding Booleans +% to 'false', even if historic and/or rare ligatures are enabled + +\DeclareOption{basic}{\@broadfsetfalse\@hdligsetfalse} + + +% Last but not least, an option to set all Boolean +% variables (other than '@addlhyph') to 'true' +% simultaneously. + +\DeclareOption{all}{% + \@englishtrue \@broadfsettrue \@hdligsettrue + \@germantrue \@otherlangtrue} + +% Finally, process all options +\ProcessOptions\relax + + + +% Part 2: Load the lua code and set up the user macros +% ---------------------------------------------------- + +\ifluatex + % Load the lua code contained in 'selnolig.lua'. + \directlua{ require("selnolig.lua") } + + % Commands to switch selnolig's routines on and off + \newcommand\selnoligon{ + \directlua{ enableselnolig() } + } + \newcommand\selnoligoff{ + \directlua{ disableselnolig() } + } + + % By default, selnolig's macros are switched on + \selnoligon + + % Record operations of selnolig package to the log + % file: Enabled via '\debugon' command + \newcommand\debugon{% + \directlua{ debug=true } + } + \newcommand\debugoff{% + \directlua{ debug=false } + } + + + % The first main user macro is called '\nolig': + \newcommand\nolig[2]{ + \directlua{ + suppress_liga( "\luatexluaescapestring{#1}", + "\luatexluaescapestring{#2}" ) + } + } + + % A second user macro allows global overriding of + % rules set by \nolig instructions: + \newcommand\keeplig[1]{ + \directlua{ + always_keep_liga( "\luatexluaescapestring{#1}" ) + } + } + +\else + % If *not* running under LuaLaTeX, provide dummy + % definitions for package's user macros. + \newcommand{\nolig}[2]{} + \newcommand{\keeplig}[1]{} + \let\selnoligon\relax + \let\selnoligoff\relax + \let\debugon\relax + \let\debugoff\relax +\fi + + +% A third user macro: '\breaklig'. This is hopefully +% easier to remember than having to type "\-\hspace{0pt}". +% (It's defined outside the \ifluatex conditional since +% it doesn't use any lua code.) + +\newcommand\breaklig{\-{\hspace{0pt}}} + + + +% Part 3: What to do if the 'english' option is set +% ------------------------------------------------- + +\if@english + % load English-language ligature suppression rules + \ifluatex + \RequirePackage{selnolig-english-patterns} + \fi + + % load additional hyphenation exception patterns + \if@addlhyph + \RequirePackage{selnolig-english-hyphex} + \fi +\fi + + +% Part 4: What to do if the 'ngerman' option is set +% ------------------------------------------------- + +\if@german + % load German-language ligature suppression rules + \ifluatex + \RequirePackage{selnolig-german-patterns} + \fi + + % load additional hyphenation exception patterns + \if@addlhyph + \RequirePackage{selnolig-german-hyphex} + \fi +\fi + + +% Part 5: What to do if the 'otherlang' option is set +% --------------------------------------------------- + +\if@otherlang + % currently nothing included +\fi |