summaryrefslogtreecommitdiff
path: root/fonts/clearsans/latex/ClearSans.sty
blob: 36deab09b5eaefb45b48860bc23c06fd064dcf63 (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{ClearSans}
    [2022/09/15 (Bob Tennent)  Supports Clear-Sans fonts for all LaTeX engines.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifclear@ttf 
\ifxetex
  \clear@ttftrue
\else\ifluatex
  \clear@ttftrue
\else  % [pdf]LaTeX
  \clear@ttffalse
\fi\fi

\newif\ifclear@default \clear@defaultfalse
\newif\ifclear@medium  \clear@mediumfalse

\newcommand*{\ClearSans@scale}{1}
\DeclareOptionX{scaled}{\renewcommand*{\ClearSans@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\ClearSans@scale}{#1}}

\DeclareOptionX{sfdefault}{\clear@defaulttrue}
\DeclareOptionX{type1}{\clear@ttffalse}
\DeclareOptionX{medium}{\clear@mediumtrue}
\DeclareOptionX{regular}{\clear@mediumfalse}

\ProcessOptionsX\relax

\ifclear@ttf
  \def\clear@boldstyle{Bold}
  \ifclear@medium\def\clear@boldstyle{Medium}\fi

\else % type1

  \def\bfseries@sf{b}
  \def\mdseries@sf{m}
  \ifclear@medium\def\bfseries@sf{sb}\fi
\fi

\ifclear@ttf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes,mweights}
\fi

\ifclear@ttf
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \ClearSans@scale ,
        Extension = .ttf }
  \setsansfont
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-\clear@boldstyle , 
        BoldItalicFont = *-\clear@boldstyle Italic ]
      {ClearSans}
  % grab current family in case of subsequent change:
  \let\clearfamily\sfdefault  
  \ifclear@default\renewcommand*\familydefault{\clearfamily}\fi
  \newfontfamily\clear
      [ UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont       = *-\clear@boldstyle , 
        BoldItalicFont = *-\clear@boldstyle Italic 
      ]
      {ClearSans}
  \newfontfamily\clearlight
      [ UprightFont    = *-Light ,
        BoldFont       = *-\clear@boldstyle , 
        BoldItalicFont = *-\clear@boldstyle Italic ,
      ]
      {ClearSans}
  \newfontfamily\clearthin
      [ UprightFont    = *-Thin ,
        BoldFont       = *-\clear@boldstyle , 
        BoldItalicFont = *-\clear@boldstyle Italic 
      ]
      {ClearSans}
\else % type1
  \def\clearfamily{ClearSans-TLF}
  \newcommand*\clear{\fontfamily{\clearfamily}\selectfont}
  \def\sfdefault{\clearfamily}
  \ifclear@default\edef\familydefault{\sfdefault}\edef\seriesdefault{\mdseries@sf}\fi
  \newcommand*\clearlight{\fontseries{l}\selectfont}
  \newcommand*\clearthin{\fontseries{el}\selectfont}
\fi

\DeclareTextFontCommand{\textsfl}{\clearlight}
\DeclareTextFontCommand{\textsft}{\clearthin}

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

\endinput