summaryrefslogtreecommitdiff
path: root/macros/luatex/latex/novel/lualatex/novel-DropCap.sty
diff options
context:
space:
mode:
Diffstat (limited to 'macros/luatex/latex/novel/lualatex/novel-DropCap.sty')
-rw-r--r--macros/luatex/latex/novel/lualatex/novel-DropCap.sty223
1 files changed, 223 insertions, 0 deletions
diff --git a/macros/luatex/latex/novel/lualatex/novel-DropCap.sty b/macros/luatex/latex/novel/lualatex/novel-DropCap.sty
new file mode 100644
index 0000000000..7d418b45f5
--- /dev/null
+++ b/macros/luatex/latex/novel/lualatex/novel-DropCap.sty
@@ -0,0 +1,223 @@
+%%
+%% This is file `novel-DropCap.sty', part of `novel' document class.
+%% Copyright (C) 2017-2023 Robert Allgeyer.
+%%
+%% It is based on `lettrine.sty', part of `lettrine' package,
+%% Copyright (C) 1999-2015 Daniel Flipo.
+%%
+%% The license for this file is that same for `lettrine':
+%
+% This program can be distributed and/or modified under the terms
+% of the LaTeX Project Public License either version 1.3c of this
+% license or (at your option) any later version.
+% The latest version of this license is in
+% http://www.latex-project.org/lppl.txt
+% and version 1.3c or later is part of all distributions of LaTeX
+% version 2005/12/01 or later.
+%
+%%
+\ProvidesFile{novel-DropCap.sty}%
+ [2023/02/08 v1.80 (Drop Caps)]
+\NeedsTeXFormat{LaTeX2e}[1999/12/01]
+%
+%
+
+%
+\newcounter{NDCDefaultLines}
+\setcounter{NDCDefaultLines}{3}
+\newcounter{NDCDefaultDepth}
+\newdimen\NDCDefaultVoffset
+\newdimen\NDCDefaultHoffset
+\newcommand*{\NDCDefaultScale}{1}
+\newcommand*{\NDCDefaultBloat}{1}
+\newdimen\NDCDefaultGap
+\gsetlength{\NDCDefaultGap}{0.25em} % approx. width of normal space
+\newsavebox{\NDC@dropcapbox}
+\newsavebox{\NDC@normalXbox}
+\newcounter{NDC@lines}
+\newcounter{NDC@depth}
+\newdimen\NDC@antewidth
+\newdimen\NDC@Pindent
+\newdimen\NDC@Gap % equivalent to lettrine findent
+\newdimen\NDC@Nindent % not a user setting
+\newdimen\NDC@voffset
+\newdimen\NDC@hoffset
+\newdimen\NDC@first
+\newdimen\NDC@next
+\newdimen\NDC@height
+\newcommand*{\NDC@ante}{}
+\newcommand*{\NDC@bloat}{}
+\newcommand*{\NDC@scale}{}
+\def\@getNDCheight{% offsets do not affect height:
+ \@tempdima=\baselineskip
+ \setlength{\NDC@height}{\value{NDC@lines}\@tempdima}% local
+ \addtolength{\NDC@height}{-\@tempdima}%
+ \sbox{\NDC@normalXbox}{X}% Normal capital X, rather than something else.
+ \addtolength{\NDC@height}{\ht\NDC@normalXbox}%
+ \setlength{\NDC@height}{\NDC@scale\NDC@height}% local
+} %
+\newcommand*{\NDC@char}{%
+ \@getNDCheight%
+ % Measures drop cap capital X, rather than something else:
+ \sbox{\@tempboxa}{%
+ \NDC@charstyle\fontsize{\NDC@height}{\NDC@height}\selectfont X%
+ }%
+ \@tempcntb=\ht\@tempboxa%
+ \@tempcnta=\NDC@height%
+ \multiply\@tempcnta by 100%
+ \divide\@tempcntb by 100%
+ \divide\@tempcnta by \@tempcntb%
+ \advance\@tempcnta by -9999%
+ \ifnum\@tempcnta>0%
+ \def\@tempa{1.\the\@tempcnta}%
+ \else%
+ \def\@tempa{1}%
+ \fi%
+ \NDC@charstyle\fontsize{\@tempa\NDC@height}{\@tempa\NDC@height}\selectfont
+} %
+\define@key{NDC}{lines}{\setcounter{NDC@lines}{#1}}
+\define@key{NDC}{depth}{\setcounter{NDC@depth}{#1}}
+\define@key{NDC}{hoffset}{\setlength{\NDC@hoffset}{#1}}
+\define@key{NDC}{voffset}{\setlength{\NDC@voffset}{#1}}
+\define@key{NDC}{ante}{\renewcommand*{\NDC@ante}{#1}} % Like `lettrine' ante,
+\define@key{NDC}{ante*}{\renewcommand*{\NDC@ante}{% Like `lettrine' ante, but
+ \setlength\NDC@antewidth{\widthof{#1}}% auto-hangs the ante in left margin.
+ \addtolength\NDC@antewidth{0.2em}% provides breathing room
+ \stake\hspace{-\NDC@antewidth}#1\hspace{0.2em}}% restores alignment
+}
+\define@key{NDC}{gap}{\setlength{\NDC@Gap}{#1}}
+\define@key{NDC}{bloat}{\renewcommand*{\NDC@bloat}{#1}}
+\define@key{NDC}{scale}{\renewcommand*{\NDC@scale}{#1}}
+\newdimen\NDCboxwidth
+\newdimen\NDCboxheight
+\newdimen\NDCboxdepth
+%
+\DeclareDocumentCommand \NDC@boxcap { m }{%
+ \begingroup%
+ % The model letter has no upper diacritical.
+ \def\@NDCmodel{}%
+ \IfSubStr{ÀÁÂÃÄÅĀĂ}{#1}{\def\@NDCmodel{A}}{}%
+ \IfSubStr{ĆĈĊČ}{#1}{\def\@NDCmodel{C}}{}%
+ \IfSubStr{Ď}{#1}{\def\@NDCmodel{D}}{}%
+ \IfSubStr{ÈÉÊËĒĔĖĚ}{#1}{\def\@NDCmodel{E}}{}%
+ \IfSubStr{ĜĞĠ}{#1}{\def\@NDCmodel{G}}{}%
+ \IfSubStr{Ĥ}{#1}{\def\@NDCmodel{H}}{}%
+ \IfSubStr{ÌÍÎÏĨĪĬİ}{#1}{\def\@NDCmodel{I}}{}%
+ \IfSubStr{Ĵ}{#1}{\def\@NDCmodel{J}}{}%
+ \IfSubStr{Ĺ}{#1}{\def\@NDCmodel{L}}{}%
+ \IfSubStr{ÑŃŇ}{#1}{\def\@NDCmodel{N}}{}%
+ \IfSubStr{ÒÓÔÕÖŌŎŐ}{#1}{\def\@NDCmodel{O}}{}%
+ \IfSubStr{ŔŘ}{#1}{\def\@NDCmodel{R}}{}%
+ \IfSubStr{ŚŜŠ}{#1}{\def\@NDCmodel{S}}{}%
+ \IfSubStr{Ť}{#1}{\def\@NDCmodel{T}}{}%
+ \IfSubStr{ÙÚÛÜŨŪŬŮŰ}{#1}{\def\@NDCmodel{U}}{}%
+ \IfSubStr{Ŵ}{#1}{\def\@NDCmodel{W}}{}%
+ \IfSubStr{ÝŶŸ}{#1}{\def\@NDCmodel{Y}}{}%
+ \IfSubStr{ŹŻŽ}{#1}{\def\@NDCmodel{Z}}{}%
+ \IfSubStr{DŽ}{#1}{\def\@NDCmodel{DZ}}{}% diglyph
+ \setlength\fboxsep{0.16\@SetFontSize}%
+ \setlength\fboxrule{0.02\@SetFontSize}%
+ \ifthenelse{\equal{\@NDCmodel}{}}{%
+ \framebox{\phantom{|}#1\phantom{|}}%
+ }{%
+ \framebox{\phantom{|\@NDCmodel}\llap{\smash{#1}}\phantom{|}}%
+ }%
+ \endgroup%
+}% end boxcap
+%
+\DeclareDocumentCommand \dropcap { s O{} m } {%
+ \@tempTFfalse%
+ \IfSubStr{#3}{png}{\@tempTFtrue}{}%
+ \IfSubStr{#3}{PNG}{\@tempTFtrue}{}%
+ \IfSubStr{#3}{jpg}{\@tempTFtrue}{}%
+ \IfSubStr{#3}{JPG}{\@tempTFtrue}{}%
+ \IfSubStr{#3}{jpeg}{\@tempTFtrue}{}%
+ \IfSubStr{#3}{JPEG}{\@tempTFtrue}{}%
+ \setcounter{NDC@lines}{\value{NDCDefaultLines}}%
+ \setcounter{NDC@depth}{\value{NDCDefaultDepth}}%
+ \setlength{\NDC@hoffset}{\NDCDefaultHoffset}%
+ \renewcommand*{\NDC@bloat}{\NDCDefaultBloat}%
+ \renewcommand*{\NDC@scale}{\NDCDefaultScale}%
+ \setlength{\NDC@voffset}{\NDCDefaultVoffset}%
+ \renewcommand*{\NDC@ante}{}%
+ \setlength{\NDC@Gap}{\NDCDefaultGap}%
+ \setlength{\NDC@Nindent}{0pt}%
+ \setkeys{NDC}{#2}%
+ \if@tempTF%
+ \def\@dropthisthing{\InlineImage[0em,b]{#3}}%
+ \else%
+ \IfBooleanTF{#1}%
+ {\def\@dropthisthing{\NDC@boxcap{#3}}}%
+ {\def\@dropthisthing{#3}}%
+ \fi%
+ \ifnum\value{NDC@lines}=1%
+ \par\noindent%
+ \NDC@ante%
+ \@dropthisthing%
+ \else%
+ \sbox{\NDC@normalXbox}{X}% Normal capital X.
+ \sbox{\NDC@dropcapbox}{\scalebox{\NDC@bloat}[1]{\NDC@char\@dropthisthing}}%
+ \@tempdima=\baselineskip%
+ \setlength{\NDC@first}{-\value{NDC@lines}\@tempdima}%
+ \addtolength{\NDC@first}{\@tempdima}%
+ \sbox{\@tempboxa}{X}%
+ \addtolength{\NDC@first}{-\ht\@tempboxa}%
+ \addtolength{\NDC@first}{\NDC@voffset}%
+ \addtolength{\NDC@first}{\ht\NDC@dropcapbox}%
+ \addtolength{\NDC@voffset}{-\value{NDC@lines}\@tempdima}%
+ \addtolength{\NDC@voffset}{\@tempdima}%
+ \par%
+ \setlength{\NDC@Pindent}{\wd\NDC@dropcapbox}%
+ \addtolength{\NDC@Pindent}{\NDC@hoffset}%
+ \settowidth{\NDC@first}{\NDC@ante}%
+ \addtolength{\NDC@Pindent}{\NDC@first}%
+ \addtolength{\NDC@Pindent}{\NDC@Gap}%
+ \setlength{\NDC@first}{\linewidth}%
+ \addtolength{\NDC@first}{-\NDC@Pindent}%
+ \addtolength{\NDC@Nindent}{\NDC@Pindent}%
+ \setlength{\NDC@next}{\linewidth}%
+ \addtolength{\NDC@next}{-\NDC@Nindent}%
+ \addtolength{\NDC@Pindent}{\rightmargin}%
+ \addtolength{\NDC@Nindent}{\rightmargin}%
+ \setlength{\NDCboxwidth}{\wd\NDC@dropcapbox}%
+ \setlength{\NDCboxheight}{\ht\NDC@dropcapbox}%
+ \setlength{\NDCboxdepth}{\dp\NDC@dropcapbox}%
+ \addtocounter{NDC@lines}{1}%
+ \addtocounter{NDC@lines}{\value{NDC@depth}}%
+ \def\NDC@parshape{\c@NDC@lines \the\NDC@Pindent \the\NDC@first}%
+ \@tempcnta=\tw@%
+ \@whilenum \@tempcnta<\c@NDC@lines\do{%
+ \edef\NDC@parshape{\NDC@parshape \the\NDC@Nindent \the\NDC@next}%
+ \advance\@tempcnta\@ne}%
+ \edef\NDC@parshape{\NDC@parshape \rightmargin \the\linewidth}%
+ \noindent%
+ \parshape=\NDC@parshape\relax%
+ \smash{%
+ \llap{%
+ \mbox{\NDC@ante}%
+ \raisebox{\NDC@voffset}{\usebox{\NDC@dropcapbox}}%
+ \hskip\the\NDC@Gap%
+ }%
+ }%
+ \fi%
+}% end @NDCdropcap
+%%
+
+
+%% In case the user prefers `lettrine':
+\gdef\@ActivateDropCaps{% called by `novel.cls' \AtBeginDocument
+ \@ifpackageloaded{lettrine}{%
+ \global\LettrineOnGridtrue % Necessary.
+ \gsetlength\DiscardVskip{10\nbs} % effectively infinite
+ }{ % For test purposes only:
+ \providecommand\lettrine[3][]{##2##3} % echoes its mandatory arguments
+ }%
+}% end \@ActivateDropCaps
+
+
+
+%%
+\endinput
+%%
+%% End of file `novel-DropCap.sty'.
+