summaryrefslogtreecommitdiff
path: root/fonts/newpx/tex/newpx.sty
blob: f26e2a5b54070eb5db4fd83b6626840fc2660093 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
\NeedsTeXFormat{LaTeX2e}


%Package to simplify loading of newpxmath with a text font family such as newpxtext for all latex engines, or for newpxtext and an otf math package.
\def\fileversion{1.536}
\def\filedate{2024/02/09}
\ProvidesPackage{newpx}[%
\filedate\space v\fileversion (Michael Sharpe) latex and unicode latex support for newpxmath and newpxtext, or for newpxtext and an otf math package]

\message{`newpx'v\fileversion,\space\filedate\space Integrated\space loading\space of\space newpxmath\space and\space a\space text\space font
\space for\space all\space latex\space engines\space (msharpe)}

\RequirePackage{fontenc,fontaxes}
\RequirePackage{ifthen,iftex,etoolbox,scalefnt,trimspaces}

\forcsvlist{\listadd\zpl@mathlst}{vecsep,amsthm,nosubscriptcorrection,subscriptcorrection,varbb,vvarbb,nosymbolsc,noamssymbols,amssymbols,uprightscript,uprightGreek,slantedGreek,frenchmath,upint,smallerops,useBImacros,varg,varvw,noOT1,fracspacing,subscriptcorrectionfile,curlybraces}

\RequirePackage{kvoptions}
\def\zpl@scale{1}
\def\newpx@helvratio{1}
\DeclareDefaultOption{
\xifinlist{\CurrentOptionKey}{\zpl@mathlst}
{% true branch for xifinlist
\expandafter\PassOptionsToPackage\expandafter{\CurrentOption}{newpxmath}}
{%  false branch for xifinlist
%\xdef\zpl@Topt{\zpl@Topt \CurrentOption,}
\expandafter\PassOptionsToPackage\expandafter%
{\CurrentOption}{newpxtext}}
\ifthenelse{\equal{scale}{\CurrentOptionKey} \OR \equal{scaled}{\CurrentOptionKey}}
{% true branch for ifthenelse
\xdef\zpl@scale{\CurrentOptionValue}
\xdef\npxmath@scaled{\CurrentOptionValue}
}{ % false branch for ifthenelse
\ifthenelse{\equal{helvratio}{\CurrentOptionKey}}
{% true branch
\xdef\newpx@helvratio{\CurrentOptionValue}
}{}}}
%\newif\ifzpl@otfmath %\zpl@otfmathfalse % default is type1 math
\DeclareBoolOption{otfmath}% creates and inits \ifnewpx@otfmath 
%{\@nameuse{if#1}\iftutex\zpl@otfmathtrue\fi\fi}
\DeclareBoolOption{nohelv}% creates and inits \ifnewpx@nohelv 
\DeclareBoolOption{nott}% creates and inits \ifnewpx@nott 

\DeclareBoolOption{type1}%[true]{}% no effect now
%{%\@nameuse{if#1}\zpl@otftextfalse\fi}

\DeclareBoolOption{type1text}%[true]{} %no effect now
%{% same as type1--use type1 for text
%\@nameuse{if#1}\zpl@otftextfalse\fi}

\DeclareBoolOption{nofontspec}%[true]{} % no effect
%{\@nameuse{if#1}\zpl@nofontspectrue\fi}

\ProcessKeyvalOptions{newpx}

\RequirePackage{xstring}% must load this after \@for
% Needed for \StrLeft and \StrRight

%Enginecheck
%iftex's \iftutex is true for LuaTeX and XeTeX
\newif\ifzpl@otftext
\iftutex\zpl@otftexttrue\fi 
%\def\zpl@Mopt{} % math options to pass
%\def\zpl@Topt{} % text options to pass

%\def\tx@divide#1#2{\strip@pt\dimexpr 1pt * (\dimexpr #1pt) / \dimexpr #2pt\relax\relax}
%\newcommand*{\zpltext@rm}{} % not understood by libertinus-otf
%\newcommand*{\zpltext@sf}{}% not understood by libertinus-otf



\def\zpl@dfltTF{newpxtext} % the default text font package name
\def\zpl@text{\let\zpl@TF=\zpl@dfltTF % the text font package name
\def\zpl@MF{newpxmath} 
%\def\zpl@id{0} % identifier for font properties
%\def\zpl@sc{zpl@scale} % macro name for scale factor in font package 
\def\zpl@minfam{zpltlf} %roman font, tabular lining fd, used in math
}
\zpl@text % set the defaults%

%\newcommand{\PassMathScale}{\ifzpl@iszero\gdef\zpltext@scale{\zplmath@scale}\gdef\zpltext@scaled{s*[\zpltext@scale]}\fi
%\PassOptionsToPackage{scaled=\zpltext@scale}{\zpl@TF}
%}
\ifnewpx@otfmath
\else % t1 math
   \ifthenelse{\not\equal{\sfdefault}{cmss}}%
      {\newpx@nohelvtrue}{}
    \ifthenelse{\not\equal{\ttdefault}{cmtt}}%
      {\newpx@notttrue}{}
    \ifnewpx@nohelv
    \else
      \renewcommand*{\sfdefault}{qhv}
      \@tempdima=\zpl@scale\p@
      \@tempdima=\newpx@helvratio\@tempdima%
      \edef\qhv@scale{\strip@pt\@tempdima}
%    \else
%      \PassOptionsToPackage{nohelv=true}{newtxtext}
    \fi
    \ifnewpx@nott\else%
      \renewcommand*{\ttdefault}{npxtt}
    \fi
%    \ifthenelse{\not\equal{\newpx@helvratio}{.94}}%
%      {\PassOptionsToPackage{helvratio=\newpx@helvratio}%
%      {newtxtext}}{}
%    \iftx@tt\else%
%      \PassOptionsToPackage{nott=true}{newtxtext}\fi

\fi
\ifzpl@otftext
  \ifnewpx@otfmath %
  \typeout{I}
    \usepackage[]{newpxtext} %may not load fontspec
    \usepackage{unicode-math} %loads amsmath
  \else %II: type1 math, otftext
  \typeout{II}
    \renewcommand*{\rmdefault}{\zpl@minfam} % Roman and Bold text for math
    \usepackage[]{newpxmath} % options will be as passed from newpx
    \usepackage[no-math]{fontspec}
    \usepackage{newpxtext}
  \fi %ifzpl@otfmath
  %\show\zpl@otftexttrue
\else % not otftext
  \typeout{IV}
% IV, type1 tex and math
    \renewcommand*{\rmdefault}{\zpl@minfam}% Roman and Bold for math
     \usepackage{newpxmath} % options will be as passed from newpx
    \usepackage{\zpl@TF} % should load tt and sans math before newpx
\fi



\endinput