summaryrefslogtreecommitdiff
path: root/fonts/garamond-libre/latex/garamondlibre.sty
blob: 0b1e7eaab9544099bfc3f8eb189a5c3add537378 (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
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{GaramondLibre}
    [2022/09/16 (Bob Tennent and autoinst)  Style file for GaramondLibre fonts.]

\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}

\newif\ifgaramondlibre@otf 
\ifxetex
  \garamondlibre@otftrue
\else\ifluatex
  \garamondlibre@otftrue
\else  % [pdf]LaTeX
  \garamondlibre@otffalse
\fi\fi

\newif\ifgaramondlibre@lining \garamondlibre@liningtrue

\newcommand*{\GaramondLibre@scale}{1}
\RequirePackage{xkeyval}
\DeclareOptionX{scaled}{\renewcommand*{\GaramondLibre@scale}{#1}}
\DeclareOptionX{scale}{\renewcommand*{\GaramondLibre@scale}{#1}}
\DeclareOptionX{type1}{\garamondlibre@otffalse}
\DeclareOptionX{oldstyle}{\garamondlibre@liningfalse}
\DeclareOptionX{osf}{\garamondlibre@liningfalse}
\DeclareOptionX{lining}{\garamondlibre@liningtrue}
\DeclareOptionX{lf}{\garamondlibre@liningtrue}


\ProcessOptionsX\relax

\ifgaramondlibre@otf
  \ifgaramondlibre@lining
    \def\garamondlibre@figurestyle{Lining}
  \else
    \def\garamondlibre@figurestyle{OldStyle} 
  \fi
\else % type1
  \ifgaramondlibre@lining
    \def\garamondlibre@figurestyle{LF}
  \else
    \def\garamondlibre@figurestyle{OsF}
  \fi
\fi

\ifgaramondlibre@otf
\else
  \def\bfseries@rm{b}
  \def\mdseries@rm{m}
\fi

\ifgaramondlibre@otf
  \RequirePackage{fontspec}
\else
  \RequirePackage{fontenc,fontaxes,mweights}
\fi

\ifgaramondlibre@otf
  \defaultfontfeatures{
        Ligatures = TeX ,
        Scale     = \GaramondLibre@scale ,
        Extension = .otf }
  \setmainfont[
        Numbers       = {\garamondlibre@figurestyle},
        UprightFont    = *-Regular ,
        ItalicFont     = *-Italic ,
        BoldFont    = *-Bold ,
        BoldItalicFont = *-BoldItalic,
      ]
      {GaramondLibre}
  \providecommand\sufigures{\addfontfeatures{VerticalPosition=Superior}}
  \providecommand\infigures{\addfontfeatures{VerticalPosition=Inferior}}

  \providecommand{\swashshape}{\itshape\addfontfeatures{ItalicFeatures={Style=Swash}}}
  \DeclareTextFontCommand{\textsw}{\swashshape}

  \providecommand\ornaments{\addfontfeatures{Numbers=Lining,Ornament}}
  \DeclareTextFontCommand{\textornaments}{\ornaments}

  \DeclareTextFontCommand{\oldstylenums}{\addfontfeatures{Numbers=OldStyle}}
  \DeclareTextFontCommand{\liningnums}{\addfontfeatures{Numbers=Lining}}

\else % type1

  \def\garamondlibre@family{GaramondLibre-\garamondlibre@figurestyle}
  \renewcommand*\rmdefault{\garamondlibre@family}
  \edef\seriesdefault{\mdseries@rm}

  \DeclareRobustCommand\swshape{\not@math@alphabet\swshape\relax
      \fontprimaryshape\itdefault\fontsecondaryshape\swdefault\selectfont}
  \fa@naming@exception{shape}{{n}{sw}}{nw}
  \fa@naming@exception{shape}{{it}{sw}}{sw}

  \fa@naming@exception{figures}{{superior}{proportional}}{Sup}
  \fa@naming@exception{figures}{{superior}{tabular}}{Sup}
  \def\sufigures{\@nomath\sufigures
      \fontfigurestyle{superior}\selectfont}

  \fa@naming@exception{figures}{{inferior}{proportional}}{Inf}
  \fa@naming@exception{figures}{{inferior}{tabular}}{Inf}
  \def\infigures{\@nomath\infigures
      \fontfigurestyle{inferior}\selectfont}

  \fa@naming@exception{figures}{{ornament}{proportional}}{Orn}
  \fa@naming@exception{figures}{{ornament}{tabular}}{Orn}
  \def\ornaments{\@nomath\ornaments
      \fontencoding{U}\fontfigurestyle{ornament}\selectfont}
  \DeclareTextFontCommand{\textornaments}{\ornaments}
  \providecommand{\ornament}[1]{\textornaments{\char##1}}


  \DeclareTextFontCommand{\oldstylenums}{\fontfamily{GaramondLibre-OsF}\selectfont}
  \DeclareTextFontCommand{\liningnums}{\fontfamily{GaramondLibre-LF}\selectfont}
  \DeclareTextFontCommand{\textsw}{\swshape}

\fi

\DeclareTextFontCommand{\textsu}{\sufigures}
\DeclareTextFontCommand{\textin}{\infigures}
\newcommand*\garamondlibrelgr{\fontencoding{LGR}\fontfamily{GaramondLibre-LF}\selectfont}


\ifgaramondlibre@otf
  \defaultfontfeatures{}
\fi

\endinput