summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/xcharter/XCharter.sty
blob: 5b42fe765cd9df99c9e470badef997747dc746b2 (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
%% XCharter is an extension of the Bitstream Charter fonts, adding osf,  
% small caps and superior figures. Generated 2013/10/27 by Michael Sharpe.
%%
\NeedsTeXFormat{LaTeX2e}

\def\fileversion{1.06}
\def\filedate{2014/11/05}

\ProvidesPackage{XCharter}[\filedate\space v\fileversion]

\message{`XCharter' v\fileversion, \filedate\space Text macros for XCharter, an extension of Charter (msharpe)}

\RequirePackage[LY1,T1]{fontenc}
\RequirePackage{textcomp}
\IfFileExists{mweights.sty}{\RequirePackage{mweights}}{}
\RequirePackage{etoolbox}
\IfFileExists{fontaxes.sty}{
    \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
}{}
\DeclareRobustCommand{\lfstyle}{%
  \not@math@alphabet\lfstyle\relax
  \fontfamily{XCharter-TLF}\selectfont }
\DeclareRobustCommand{\osfstyle}{%
  \not@math@alphabet\osfstyle\relax
  \fontfamily{XCharter-TOsF}\selectfont }
\def\textlf#1{{\lfstyle #1}}
%\def\textosf#1{{\osfstyle #1}}

\newcommand*{\XCharter@scale}{1}
\IfFileExists{xkeyval.sty}{
    \RequirePackage{xkeyval}
    \DeclareOptionX{scale}{\renewcommand*{\XCharter@scale}{##1}}
    \DeclareOptionX{scaled}{\renewcommand*{\XCharter@scale}{##1}}
}{
    \let\DeclareOptionX\DeclareOption
    \let\ExecuteOptionsX\ExecuteOptions
    \let\ProcessOptionsX\ProcessOptions
}
\let\orig@footnote=\thefootnote
\let\orig@makefnmark=\@makefnmark

\def\XCharter@altone{1}% default is to use 1, not I
\newif\if@XCh@sups
\DeclareOptionX{lf}{\edef\XCharter@figurestyle{TLF}}
\DeclareOptionX{lining}{\edef\XCharter@figurestyle{TLF}}
\DeclareOptionX{oldstyle}{\edef\XCharter@figurestyle{TOsF}%
\edef\XCharter@altone{1}}
\DeclareOptionX{oldstyleI}{\edef\XCharter@figurestyle{TOsF}%
\edef\XCharter@altone{}}
\DeclareOptionX{osf}{\edef\XCharter@figurestyle{TOsF}\edef\XCharter@altone{1}}
\DeclareOptionX{osfI}{\edef\XCharter@figurestyle{TOsF}\edef\XCharter@altone{}}
\DeclareOptionX{sups}{\@XCh@supstrue}

\edef\bfseries@rm{b}
\edef\mdseries@rm{m}
\ExecuteOptionsX{lining}
\ProcessOptionsX\relax

\def\useosf{\edef\XCharter@figurestyle{TOsF}\def\XCharter@altone{1}}
\def\useosfI{\edef\XCharter@figurestyle{TOsF}\def\XCharter@altone{}}
\@onlypreamble\useosf
\@onlypreamble\useosfI

\newcommand{\textosfI}[1]{\oldstylenums{#1}}% to get XCharter osfI
\newcommand{\textosf}[1]{{\fontencoding{T1}\fontfamily{XCharterx}\selectfont #1}}% to get XCharter osf
\renewcommand*{\bfdefault}{b}
\renewcommand*{\scdefault}{sc}% for better compatibility with mathdesign

% The following are provided so that we may access osf in any mode
% osfx corresponds to small 1 rather than small I
\DeclareFontFamily{T1}{XCharterx}{}

\DeclareFontShape{T1}{XCharterx}{m}{n}{
   <-> s*[\XCharter@scale]  XCharter1-Roman-tosf-t1
}{}
\DeclareFontShape{T1}{XCharterx}{m}{it}{
   <-> s*[\XCharter@scale]  XCharter1-Italic-tosf-t1
}{}
\DeclareFontShape{T1}{XCharterx}{b}{n}{
   <-> s*[\XCharter@scale]  XCharter1-Bold-tosf-t1
}{}
\DeclareFontShape{T1}{XCharterx}{b}{it}{
   <-> s*[\XCharter@scale]  XCharter1-BoldItalic-tosf-t1
}{}


\renewcommand*{\rmdefault}{XCharter-TLF}
\renewcommand*{\familydefault}{\rmdefault}


\if@XCh@sups %
 \ifdefined\sufigures
  \def\f@@tn@te{footnote}
  \def\@makefnmark{%
    \ifx\@mpfn\f@@tn@te%not in a minipage
      \ifx\thefootnote\orig@footnote%
        \hbox{\sufigures\hspace*{.04em}\@thefnmark\hspace*{.04em}}%
      \else%
        \orig@makefnmark%
      \fi%
    \else%
      \orig@makefnmark%
    \fi}%
 \fi%
\fi

\AtEndPreamble{%
\renewcommand*{\rmdefault}{XCharter-\XCharter@figurestyle}
\normalfont}


\endinput