%% $Id: dejavu-otf.sty 556 2017-09-18 06:22:29Z herbert $
%%
%% This file is distributed under the terms of the LaTeX Project Public
%% License from CTAN archives in directory  macros/latex/base/lppl.txt.
%% Either version 1.3 or, at your option, any later version.
%%
% Copyright 2017 Herbert Voss hvoss@tug.org
%%
\ProvidesPackage{dejavu-otf}[%
  2017/12/05 v. 0.04 (Herbert Voss) Supports DejaVu OpenType for lualatex/xelatex.] 
%
\RequirePackage{ifxetex,ifluatex,xkeyval,textcomp}
\RequirePackage{unicode-math}  % support opentype math fonts
                               % loads itself fontspec
%
\newif\ifDejaVu@usefilenames \DejaVu@usefilenamesfalse
\DeclareOptionX{usefilenames}[true]{\@nameuse{DejaVu@usefilenames#1}}

\newif\ifDejaVu@mono  \DejaVu@monotrue
\newif\ifDejaVu@serif \DejaVu@seriftrue
\newif\ifDejaVu@sans  \DejaVu@sanstrue
\newif\ifDejaVu@math  \DejaVu@mathtrue

\DeclareOptionX{mono}[true]{\@nameuse{DejaVu@mono#1}}
\DeclareOptionX{sans}[true]{\@nameuse{DejaVu@sans#1}}
\DeclareOptionX{serif}[true]{\@nameuse{DejaVu@serif#1}}
\DeclareOptionX{math}[true]{\@nameuse{DejaVu@math#1}}
%
\providecommand\DejaVuRM@features{Scale=0.92}%  Roman
\providecommand\DejaVuSS@features{Scale=0.92}%  SansSerif
\providecommand\DejaVuTT@features{Scale=MatchLowercase,FakeStretch=0.9}%  Typewriter
\providecommand\DejaVuMM@features{}%            Math regular
\providecommand\DejaVuMMbold@features{}%        Math bold
\providecommand\DejaVu@DefaultFeatures{}
\DeclareOptionX{RM}{\renewcommand*{\DejaVuRM@features}{#1}}
\DeclareOptionX{SS}{\renewcommand*{\DejaVuSS@features}{#1}}
\DeclareOptionX{TT}{\renewcommand*{\DejaVuTT@features}{#1}}
\DeclareOptionX{MM}{\renewcommand*{\DejaVuMM@features}{#1}}
\DeclareOptionX{MMbold}{\renewcommand*{\DejaVuMMbold@features}{#1}}
\DeclareOptionX{DefaultFeatures}{\def\DejaVu@DefaultFeatures{#1}}

\ProcessOptionsX\relax

\defaultfontfeatures{Ligatures=TeX,RawFeature={-smcp},\DejaVu@DefaultFeatures}% default in fontspec
%
\ifDejaVu@usefilenames
%
  \ifDejaVu@serif
    \setmainfont{DejaVuSerif}[% main rm
      \DejaVuRM@features,
           Extension = .ttf,
          UprightFont= *,
            BoldFont = *-Bold,
          ItalicFont = *-Italic,
      BoldItalicFont = *-BoldItalic,
    ]
  \fi
%
  \ifDejaVu@sans
    \setsansfont{DejaVuSans}[% main sans
           Extension = .ttf,
      \DejaVuSS@features,
          UprightFont= *,
            BoldFont = *-Bold,
           ItalicFont= *-Oblique,
      BoldItalicFont = *-BoldOblique,
    ]
  \fi
%
  \ifDejaVu@mono
    \setmonofont{DejaVuSansMono}[% main typewriter
        UprightFont = *,
           Extension = .ttf,
            BoldFont = *-Bold,
           ItalicFont= *-Oblique,
      BoldItalicFont = *-BoldOblique,
      \DejaVuTT@features,
    ]
  \fi
%
  % Setting math
  % First we have to expand the feature macros:
  \ifDejaVu@math
    \edef\Set@MathNormal{\noexpand\setmathfont{texgyredejavu-math.otf}[AutoFakeBold=1.4,\DejaVuMM@features,version=normal]}%
    \Set@MathNormal
%    \ifxetex
%      \edef\Set@MathBold{\noexpand\setmathfont{texgyredejavu-math.otf}[AutoFakeBold=2,\DejaVuMMbold@features,version=bold]}%
%      \Set@MathBold
%    \fi
  \fi
%
  \newfontfamily\DejaVuSerifCondensed{DejaVuSerifCondensed}[% 
      \DejaVuRM@features,
           Extension = .ttf,
          UprightFont= *,
            BoldFont = *-Bold,
          ItalicFont = *-Italic,
      BoldItalicFont = *-BoldItalic,
    ]
  \newfontfamily\DejaVuSansCondensed{DejaVuSansCondensed}[% 
           Extension = .ttf,
      \DejaVuSS@features,
          UprightFont= *,
            BoldFont = *-Bold,
           ItalicFont= *-Oblique,
      BoldItalicFont = *-BoldOblique,
    ]
  \newfontfamily\DejaVuSansLight{DejaVuSans-ExtraLight}[% 
           Extension = .ttf,
      \DejaVuSS@features,
            BoldFont = *-Bold,
           ItalicFont= *-Oblique,
      BoldItalicFont = *-BoldOblique,
    ]

\else
%-----------------------------------------  symbolic names ----------------------------
\typeout {Using symbolic names for the DejaVu font}%
\ifDejaVu@serif
  \setmainfont{DejaVu Serif}[% main rm
    \DejaVuRM@features,
        UprightFont= *,
          BoldFont = * Bold,
        ItalicFont = * Italic,
    BoldItalicFont = * Bold Italic,
    SmallCapsFont  = *, %
%    SmallCapsFeatures={Letters=SmallCaps},
%    UprightFeatures = { SmallCapsFont={ <sc> }},
%    BoldFeatures = { SmallCapsFont={ <bf sc> }},
%    ItalicFeatures = { SmallCapsFont={ <it sc> }},
%    BoldItalicFeatures = { SmallCapsFont={ <bf it sc> }},
  ]
\fi
%
\ifDejaVu@sans
  \setsansfont{DejaVu Sans}[% main sans
    \DejaVuSS@features,
        UprightFont= *,
          BoldFont = * Bold,
         ItalicFont= * Oblique,
    BoldItalicFont = * Bold Oblique,
%    SmallCapsFont  = *, %
%    SmallCapsFeatures={Letters=SmallCaps},
  ]
\fi
%
\ifDejaVu@mono
  \setmonofont{DejaVu Sans Mono}[
        UprightFont= *,
    \DejaVuTT@features,
          BoldFont = * Bold,
         ItalicFont= * Oblique,
    BoldItalicFont = * Bold Oblique,
  ]
\fi
%
% Setting math
% First we have to expand the feature macros:
\ifDejaVu@math
  \ifxetex
    \edef\Set@MathNormal{\noexpand\setmathfont{texgyredejavu-math.otf}[AutoFakeBold=1,\DejaVuMMbold@features]}%
  \else
    \edef\Set@MathNormal{\noexpand\setmathfont{TeXGyreDejaVuMath-Regular}[\DejaVuMM@features]%
                         \noexpand\setmathfont{TeXGyreDejaVuMath-Regular}[\DejaVuMM@features,version=bold]%
    }%
  \fi
  \Set@MathNormal
\fi

  \newfontfamily\DejaVuSerifCondensed{DejaVu Serif Condensed}[% 
      \DejaVuRM@features,
          UprightFont= *,
            BoldFont = * Bold,
          ItalicFont = * Italic,
      BoldItalicFont = * Bold Italic,
    ]
  \newfontfamily\DejaVuSansCondensed{DejaVu Sans Condensed}[% 
      \DejaVuSS@features,
          UprightFont= *,
            BoldFont = * Bold,
           ItalicFont= * Oblique,
      BoldItalicFont = * Bold Oblique,
    ]
  \newfontfamily\DejaVuSansLight{DejaVu Sans ExtraLight}[% 
      \DejaVuSS@features,
    ]


\fi

\endinput


