summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/plex/plex-mono.sty
blob: 7ca785a4c221a72a91a4b9888ba7f6dc304162b3 (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{plex-mono}
    [2019/10/23  (Bob Tennent) Style file for IBMPlexMono fonts]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifplexmono@otf 
\ifxetex
  \plexmono@otftrue
\else\ifluatex
  \plexmono@otftrue
\else  % [pdf]LaTeX
  \plexmono@otffalse
\fi\fi


\newcommand*{\IBMPlexMono@scale}{1}
\DeclareOptionX{scale}{\renewcommand*{\IBMPlexMono@scale}{#1}}

\newif\ifplexmono@ligatures \plexmono@ligaturestrue

\newif\ifplexmono@text \plexmono@textfalse
\newif\ifplexmono@textmd \plexmono@textmdfalse
\newif\ifplexmono@semibold \plexmono@semiboldfalse
\newif\ifplexmono@medium \plexmono@mediumfalse
\newif\ifplexmono@thin \plexmono@thinfalse
\newif\ifplexmono@light \plexmono@lightfalse
\newif\ifplexmono@extralight \plexmono@extralightfalse

\DeclareOptionX{type1}{\plexmono@otffalse}

\DeclareOptionX{thin}{\plexmono@thintrue}
\DeclareOptionX{t}{\plexmono@thintrue}
\DeclareOptionX{extralight}{\plexmono@extralighttrue}
\DeclareOptionX{el}{\plexmono@extralighttrue}
\DeclareOptionX{light}{\plexmono@lighttrue}
\DeclareOptionX{l}{\plexmono@lighttrue}
\DeclareOptionX{text}{\plexmono@texttrue}
\DeclareOptionX{tx}{\plexmono@texttrue}
\DeclareOptionX{textmd}{\plexmono@textmdtrue}
\DeclareOptionX{txmd}{\plexmono@textmdtrue}
\DeclareOptionX{medium}{\plexmono@mediumtrue}
\DeclareOptionX{m}{\plexmono@mediumtrue}
\DeclareOptionX{semibold}{\plexmono@semiboldtrue}
\DeclareOptionX{sb}{\plexmono@semiboldtrue}

\ProcessOptionsX\relax

\ifplexmono@otf
  \RequirePackage{fontspec}
  \def\plexmono@medstyle{Regular}
  \ifplexmono@thin\def\plexmono@medstyle{Thin}
  \else\ifplexmono@light\def\plexmono@medstyle{Light}
  \else\ifplexmono@extralight\def\plexmono@medstyle{ExtraLight}
  \else\ifplexmono@text\def\plexmono@medstyle{Text}
  \else\ifplexmono@textmd\def\plexmono@medstyle{Medium}
  \fi\fi\fi\fi\fi
  \def\plexmono@boldstyle{Bold}
  \ifplexmono@semibold\def\plexmono@boldstyle{SemiBold}
  \else\ifplexmono@medium\def\plexmono@boldstyle{Medium}
  \fi\fi
\else % type1
  \RequirePackage{fontenc,fontaxes,mweights}
  \def\mdseries@tt{m}
  \ifplexmono@thin\def\mdseries@tt{ul}
  \else\ifplexmono@light\def\mdseries@tt{l}
  \else\ifplexmono@extralight\def\mdseries@tt{el}
  \else\ifplexmono@textmd\def\mdseries@tt{text}
  \fi\fi\fi\fi

  \def\bfseries@tt{b}
  \ifplexmono@semibold\def\bfseries@tt{sb}
  \else\ifplexmono@text\def\bfseries@tt{text}
  \else\ifplexmono@medium\def\bfseries@tt{medium}
  \fi\fi\fi

\ifplexmono@otf
  \def\plexmono@regular{Regular}
  \ifxetex\XeTeXtracingfonts=1\fi
  \ifplexmono@ligatures
    \defaultfontfeatures{
          Ligatures = TeX ,
          HyphenChar=None,
          Scale     = \IBMPlexMono@scale ,
          Extension = .otf }
  \else
    \defaultfontfeatures{
          Scale     = \IBMPlexMono@scale ,
          Extension = .otf }
  \fi
  \setmonofont 
      [ UprightFont    = *-\plexmono@medstyle ,
        ItalicFont     = *-\ifx\plexmono@medstyle\plexmono@regular 
                              Italic
                           \else\plexmono@medstyle Italic\fi ,
        BoldFont       = *-\plexmono@boldstyle , 
        BoldItalicFont = *-\plexmono@boldstyle Italic ]
      {IBMPlexMono}
  \newfontfamily\plexmono
        [ UprightFont    = *-\plexmono@medstyle ,
          ItalicFont     = *-\ifx\plexmono@medstyle\plexmono@regular 
                              Italic
                           \else\plexmono@medstyle Italic\fi ,
          BoldFont       = *-\plexmono@boldstyle , 
          BoldItalicFont = *-\plexmono@boldstyle Italic ]
        {IBMPlexMono}

\else % type1
  \def\plexmonofamily{IBMPlexMono-TLF}
  \newcommand*\plexmono{\fontfamily{\plexmonofamily}\selectfont}
  \def\ttdefault{\plexmonofamily}
\fi

\ifplexmono@otf
  % turn off defaults in case other fonts are selected:
  \defaultfontfeatures{}
\fi

\endinput