diff options
Diffstat (limited to 'fonts/cochineal/tex/cochineal.sty')
-rw-r--r-- | fonts/cochineal/tex/cochineal.sty | 352 |
1 files changed, 209 insertions, 143 deletions
diff --git a/fonts/cochineal/tex/cochineal.sty b/fonts/cochineal/tex/cochineal.sty index c298f3216c..f0b04db520 100644 --- a/fonts/cochineal/tex/cochineal.sty +++ b/fonts/cochineal/tex/cochineal.sty @@ -1,130 +1,66 @@ %% cochineal.sty %% \NeedsTeXFormat{LaTeX2e} -\def\fileversion{1.076} -\def\filedate{2022/01/31} +\def\fileversion{1.08} +\def\filedate{2023/11/13} \ProvidesPackage{cochineal} [\filedate\space v\fileversion.] -\RequirePackage[T1]{fontenc} -\RequirePackage{ifxetex,ifluatex,xkeyval,etoolbox,textcomp} +\RequirePackage{iftex,xkeyval,etoolbox,textcomp,mweights} \RequirePackage{xstring,ifthen,scalefnt} % for \textfrac -\IfFileExists{mweights.sty}{\RequirePackage{mweights}}{} \DeclareEncodingSubset{TS1}{Cochineal-*}{0} - +%\iftrue %KOMA check \newif\ifcoch@KOMA \@ifundefined{KOMAClassName}{}{\coch@KOMAtrue} \@ifundefined{ver@scrextend.sty}{}{\coch@KOMAtrue} % Engine check -\newif\ifcoch@otf -\ifxetex - \coch@otftrue -\else\ifluatex - \coch@otftrue -\else % [pdf]LaTeX - \coch@otffalse -\fi\fi - -\ifcoch@otf% - \RequirePackage{fontspec} - \ifxetex\XeTeXtracingfonts=1\fi - \ifluatex % avoid possibly uncorrected "system" fonts - \directlua{fonts.names.set_location_precedence{ - "local", "texmf", "system" }} - \fi - \def\coch@base{Cochineal} - \newcommand{\textfrac}[3][]{{% - \mbox{% - \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] - {\textlf{#1}\kern.02em}{}% - \textsu{#2\char"2044}% numerator - \textde{\kern-.154em\char"2044 #3}% denominator -}}} - -\else % type1 - \RequirePackage{fontaxes} - \fa@naming@exception{figures}{{superior}{proportional}}{Sup} - \fa@naming@exception{figures}{{superior}{tabular}}{Sup} - \def\sufigures{\@nomath\sufigures - \fontfigurestyle{superior}\selectfont} - \DeclareTextFontCommand{\textsu}{\sufigures} - \let\textsuperior\textsu - \let\nustyle\sufigures - \let\sustyle\sufigures - - \fa@naming@exception{figures}{{inferior}{proportional}}{Inf} - \fa@naming@exception{figures}{{inferior}{tabular}}{Inf} - \def\infigures{\@nomath\infigures - \fontfigurestyle{inferior}\selectfont} - \DeclareTextFontCommand{\textinf}{\infigures} - \let\textinferior\textinf - - \fa@naming@exception{figures}{{denominators}{proportional}}{Dnom} - \fa@naming@exception{figures}{{denominators}{tabular}}{Dnom} - \def\defigures{\@nomath\defigures - \fontfigurestyle{denominators}\selectfont} - \DeclareTextFontCommand{\textde}{\defigures} - \let\textdenominators\textde - \let\destyle\defigures - - \newcommand{\textfrac}[3][]{% like \textfrac[1]{7}{8} - \mbox{% - \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] - {\textlf{#1}\kern.05em}{}% - \textsu{#2}% numerator - \StrRight{#2}{1}[\@digit@]% - % look for 1, 2, 6, 7 - \ifcase\@digit@% 0 - \or\kern.03em% 1 - \or\kern.02em% 2 - \or%\kern-.01em% 3 - \or%\kern-.01em% 4 - \or%\kern.01em% 5 - \or\kern.01em% 6 - \or\kern-.08em% 7 - \fi% - \kern\Cochineal@foresolidus{\fontencoding{TS1}\selectfont\char"2F}% - \kern\Cochineal@aftsolidus% - \StrLeft{#3}{1}[\@digit@]% - % look for 1, 4, 7 - \ifcase\@digit@% 0 - \or%\kern -.02em% 1 - \or% 2 - \or% 3 - \or\kern -.03em% 4 - \or% 5 - \or% 6 - \or\kern .02em% 7 - \fi% - \textde{#3}% denominator [#3] - }%mbox -} % textfrac -\fi - -\IfFileExists{xkeyval.sty}{ - \RequirePackage{xkeyval} - }{ - \let\DeclareOptionX\DeclareOption - \let\ExecuteOptionsX\ExecuteOptions - \let\ProcessOptionsX\ProcessOptions +\newif\ifcoch@otftext +\iftutex\coch@otftexttrue +\else + \RequirePackage[T1]{fontenc} + \renewcommand*{\familydefault}{\rmdefault} +\fi +\newif\ifcoch@otfmath + +%\newif\ifcoch@nofontspec + +% newtx check +\newif\ifntx@newtx +\@ifpackageloaded{newtx}{% run from newtx.sty +\ntx@newtxtrue +\let\ifcoch@otfmath=\ifntx@otfmath}% +{% not run from newtx.sty + %\newif\ifntx@otftext% + %\newif\ifntx@otfmath % default is type1 math + %iftex's \iftutex returns true for LuaTeX and XeTeX, not [pdf]latex + %\iftutex\ntx@otftexttrue\fi % default is otf text for unicode latex + %\newif\ifntx@nofontspec % default is to load fontspec iftutex + % might have been defined in newtx.sty + \def\ntx@id{5} % make it appear that newtxtext was chosen in newtx } -%%%%Start Options + +%\let\coch@otftext\ntx@otftext +%\iftrue +%%%%%%%%%% Start Options \newif\ifcoch@lining\coch@liningtrue \newif\ifcoch@tabular\coch@tabulartrue % default is tabular lining figures -\DeclareOptionX{type1}[true]{% -\@nameuse{if#1}\coch@otffalse\fi -} -\DeclareOptionX{nofontspec}[true]{% -\@nameuse{if#1}\coch@otffalse\fi +%\DeclareOptionX{type1text}[true]{}% use type1 packages for text +%\@nameuse{if#1}\coch@otftextfalse\fi +%} +\DeclareOptionX{type1}[true]{}% use type1 packages for text +%\@nameuse{if#1}\coch@otftextfalse\fi +%} +\DeclareOptionX{nofontspec}[true]{% not used any more +%\@nameuse{if#1}\coch@nofontspectrue\fi } \def\coch@defaultfeatures{} \DeclareOptionX{defaultfeatures}{\def\coch@defaultfeatures{#1}} %Figure style options -\edef\coch@dfltfigurestyle{lf} -\edef\coch@dfltfigurealign{t} +\def\coch@dfltfigurestyle{lf} +\def\coch@dfltfigurealign{t} \DeclareOptionX{lining}[true]{% \@nameuse{coch@lining#1} @@ -169,7 +105,7 @@ } %Scale -\newcommand*{\Cochineal@scale}{1} +\providecommand*{\Cochineal@scale}{1}% Might have been defined in newtx \DeclareOptionX{scale}{\renewcommand*{\Cochineal@scale}{#1}} \DeclareOptionX{scaled}{\renewcommand*{\Cochineal@scale}{#1}} @@ -201,7 +137,6 @@ \def\coch@defaultfeatures{} \newcount\coch@cnt \coch@cnt=0 - %\DeclareOptionX{lining}{\edef\Cochineal@figurestyle{LF}} %\DeclareOptionX{lf}{\edef\Cochineal@figurestyle{LF}} %\DeclareOptionX{oldstyle}{\edef\Cochineal@figurestyle{OsF}} @@ -216,19 +151,117 @@ \DeclareOptionX{altJ}{\advance\coch@cnt\tw@} \DeclareOptionX{oldSS}{\advance\coch@cnt\@ne} \DeclareOptionX{theoremfont}{\@Cochineal@thrmtrue} -\DeclareOptionX{thmtabular}{\edef\Cochineal@@thmtab{t}} -\DeclareOptionX{thmlining}{\edef\Cochineal@@thmlin{l}} -\DeclareOptionX{swashQ}{\edef\Cochineal@@swashQ{-swash}\coch@swashQtrue} +\DeclareOptionX{otfmath}{\coch@otfmathtrue} +\DeclareOptionX{thmtabular}{\def\Cochineal@@thmtab{t}} +\DeclareOptionX{thmlining}{\def\Cochineal@@thmlin{l}} +\DeclareOptionX{swashQ}{\def\Cochineal@@swashQ{-swash}\coch@swashQtrue} \DeclareOptionX{sups}{\@Cochineal@supstrue} \DeclareOptionX{scosf}{\@Cochineal@scosftrue} -\DeclareOptionX{bold}{\edef\bfseries@rm{b}} -\DeclareOptionX{regular}{\edef\mdseries@rm{m}} +\DeclareOptionX{bold}{\def\bfseries@rm{b}} +\DeclareOptionX{regular}{\def\mdseries@rm{m}} \DeclareOptionX{foresolidus}{\gdef\Cochineal@foresolidus{#1}} \DeclareOptionX{aftsolidus}{\gdef\Cochineal@aftsolidus{#1}} \ExecuteOptionsX{lining,tabular} \ProcessOptionsX\relax -\ifcoch@otf +% Check for conflict between nofontspec and others +%\ifcoch@nofontspec +% \iftutex +% \coch@otftextfalse +% \fi +%\fi +%\edef\coch@scaled{s*[\coch@scale]}% used in fd files + +\iftutex + \ifcoch@otfmath + \RequirePackage{fontspec} + \else + \RequirePackage[no-math]{fontspec} + \fi +% %\ifxetex\XeTeXtracingfonts=1\fi + \ifluatex % avoid possibly uncorrected "system" fonts + \directlua{fonts.names.set_location_precedence{ + "local", "texmf", "system" }} + \fi + \def\coch@base{Cochineal} +% + \newcommand{\textfrac}[3][]{{% + \mbox{% + \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] + {\textlf{#1}\kern.02em}{}% + \textsu{#2\char"2044}% numerator + \textde{\kern-.154em\char"2044 #3}% denominator +}}} + +\else % type1 + \RequirePackage{fontaxes} + \fa@naming@exception{figures}{{superior}{proportional}}{Sup} + \fa@naming@exception{figures}{{superior}{tabular}}{Sup} +% \def\sufigures{\@nomath\sufigures +% \fontfigurestyle{superior}\selectfont} +% \DeclareTextFontCommand{\textsu}{\sufigures} +% \let\textsuperior\textsu +% \let\nustyle\sufigures +% \let\sustyle\sufigures + \DeclareRobustCommand{\sustyle}{% + \not@math@alphabet\sustyle\relax + \fontfamily{Cochineal-Sup}\selectfont} + \DeclareTextFontCommand{\textsu}{\sustyle} + \let\sufigures=\sustyle + \let\nustyle=\sustyle + \let\nufigures=\sustyle + + \fa@naming@exception{figures}{{inferior}{proportional}}{Inf} + \fa@naming@exception{figures}{{inferior}{tabular}}{Inf} + \def\infigures{\@nomath\infigures + \fontfigurestyle{inferior}\selectfont} + \DeclareTextFontCommand{\textinf}{\infigures} + \let\textinferior\textinf + + \fa@naming@exception{figures}{{denominators}{proportional}}{Dnom} + \fa@naming@exception{figures}{{denominators}{tabular}}{Dnom} + \def\defigures{\@nomath\defigures + \fontfigurestyle{denominators}\selectfont} + \DeclareTextFontCommand{\textde}{\defigures} + \let\textdenominators\textde + \let\destyle\defigures + + \newcommand{\textfrac}[3][]{% like \textfrac[1]{7}{8} + \mbox{% + \ifthenelse{\not\equal{#1}{}}%Test for integer portion [optional #1] + {\textlf{#1}\kern.05em}{}% + \textsu{#2}% numerator + \StrRight{#2}{1}[\@digit@]% + % look for 1, 2, 6, 7 + \ifcase\@digit@% 0 + \or\kern.03em% 1 + \or\kern.02em% 2 + \or%\kern-.01em% 3 + \or%\kern-.01em% 4 + \or%\kern.01em% 5 + \or\kern.01em% 6 + \or\kern-.08em% 7 + \fi% + \kern\Cochineal@foresolidus{\fontencoding{TS1}\selectfont\char"2F}% + \kern\Cochineal@aftsolidus% + \StrLeft{#3}{1}[\@digit@]% + % look for 1, 4, 7 + \ifcase\@digit@% 0 + \or%\kern -.02em% 1 + \or% 2 + \or% 3 + \or\kern -.03em% 4 + \or% 5 + \or% 6 + \or\kern .02em% 7 + \fi% + \textde{#3}% denominator [#3] + }%mbox +} % textfrac +\fi + + +\ifcoch@otftext \def\coch@dflt{} \ifcoch@swashQ \edef\coch@dflt{Style = Swash , @@ -297,7 +330,8 @@ {\tosfstyle #1}% }% to get tosf -\ifcoch@otf +\ifcoch@otftext + \def\coch@nft{\if t\Cochineal@thmtab Monospaced% \else Proportional\fi} \def\coch@sty{\if l\Cochineal@thmlin Lining% @@ -306,22 +340,38 @@ \slshape}{\addfontfeatures{Numbers = {\coch@nft,\coch@sty}, RawFeature=+salt}\itshape} % for theorems \DeclareTextFontCommand{\textsl}{\slshape} - \DeclareTextFontCommand{% - \oldstylenums}{\addfontfeatures{Numbers=OldStyle}} - \DeclareTextFontCommand{% - \liningnums}{\addfontfeatures{Numbers=Lining}} - \DeclareTextFontCommand{% - \tabularnums}{\addfontfeatures{Numbers=Tabular}} - \DeclareTextFontCommand{% - \proportionalnums}{\addfontfeatures{Numbers=Proportional}} - \DeclareTextFontCommand{% - \osfstyle}{\addfontfeatures{Numbers={Proportional,OldStyle}}} - \DeclareTextFontCommand{% - \tosfstyle}{\addfontfeatures{Numbers={Tabular,OldStyle}}} - \DeclareTextFontCommand{% - \tlfstyle}{\addfontfeatures{Numbers={Tabular,Lining}}} - \DeclareTextFontCommand{% - \lfstyle}{\addfontfeatures{Numbers={Proportional,Lining}}} + \DeclareRobustCommand{\lfstyle}{% + \not@math@alphabet\lfstyle\relax + \addfontfeatures{Numbers={Proportional,Lining}}% + } + \DeclareRobustCommand{\tlfstyle}{% + \not@math@alphabet\tlfstyle\relax + \addfontfeatures{Numbers={Monospaced,Lining}}% + } + \DeclareRobustCommand{\osfstyle}{% + \not@math@alphabet\osfstyle\relax + \addfontfeatures{Numbers={Proportional,OldStyle}}% + } + \DeclareRobustCommand{\tosfstyle}{% + \not@math@alphabet\tosfstyle\relax + \addfontfeatures{Numbers={Monospaced,OldStyle}}% + } + \DeclareRobustCommand{\oldstylenums}{% + \not@math@alphabet\oldstylenums\relax + \addfontfeatures{Numbers=OldStyle}% + } + \DeclareRobustCommand{\liningnums}{% + \not@math@alphabet\liningnums\relax + \addfontfeatures{Numbers=Lining}% + } + \DeclareRobustCommand{\tabularnums}{% + \not@math@alphabet\tabularnums\relax + \addfontfeatures{Numbers=Monospaced}% + } + \DeclareRobustCommand{\proportionalnums}{% + \not@math@alphabet\proportionalnums\relax + \addfontfeatures{Numbers=Proportional}% + } \newfontfamily\cochTLF [ %IgnoreFontspecFile , Numbers = {Monospaced,Lining}, @@ -369,13 +419,17 @@ \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}} \providecommand\defigures{\addfontfeatures{RawFeature=+dnom}} \providecommand\infigures{\addfontfeatures{VerticalPosition=ScientificInferior}} + \let\destyle\defigures + \let\nustyle\sufigures + \let\sustyle\sufigures \DeclareTextFontCommand{\textsu}{\sufigures} \let\textsuperior\textsu + \let\textnu\textsu \DeclareTextFontCommand{\textde}{\defigures} \let\textdenominator\textde \DeclareTextFontCommand{\textinf}{\infigures} \let\textinferior\textinf - + \renewcommand*{\textcircled}[1]{\hmode@bgroup \ooalign{% \hfil \raise .37ex\hbox {{\cochTOsF\addfontfeatures{RawFeature=+smcp}\def\x{\lowercase{#1}}\scalefont{.72}\x}}\hfil \crcr \symbol{"25EF}}% @@ -385,16 +439,29 @@ % \newcommand{\coch@altQ}{{\addfontfeatures{RawFeature=+ss03}}} % \newcommand{\coch@altJ}{{\addfontfeatures{RawFeature=+ss02}}} % \newcommand{\coch@oldSS}{{\addfontfeatures{RawFeature=+ss01}}} - \if@Cochineal@sups % - \usepackage{realscripts} - %\newfontfamily\Timessu{TeXGyreTermesX} - - \ifcoch@KOMA - \setkomafont{footnotelabel}{\normalfont} - \else - \renewcommand\footnotemarkfont{\normalfont} - \fi - \fi + \ifcoch@KOMA + \setkomafont{footnotelabel}{\normalfont} + \setkomafont{footnotereference}{\normalfont} + \else + %\DeclareRobustCommand*\textsuperscript[1]{% + % {\@textsuperscript#1}} + \def\@textsuperscript#1{{\normalfont\sustyle #1}} + %\renewcommand{\footnotemarkfont}{\normalfont} + \fi + %\if@Cochineal@sups % + %\else + \RequirePackage{realscripts} + %\fi +% \if@Cochineal@sups % +% \usepackage{realscripts} +% %\newfontfamily\Timessu{TeXGyreTermesX} +% +% \ifcoch@KOMA +% \setkomafont{footnotelabel}{\normalfont} +% \else +% \renewcommand\footnotemarkfont{\normalfont} +% \fi +% \fi \else % type1 % \DeclareRobustCommand\thfamily % new family for theorem font @@ -455,7 +522,7 @@ \fi \AtEndPreamble{% - \ifcoch@otf + \ifcoch@otftext \ifcoch@lining \def\coch@figurestyle{Lining} \else @@ -520,7 +587,6 @@ \renewcommand*{\rmdefault}{Cochineal-\Cochineal@figurealign% \Cochineal@figurestyle} \normalfont - \renewcommand*{\familydefault}{\rmdefault} % \ifCochineal@thrm % \theoremstyle{plain} |