%%
%% This is file `GfsDidotSourire.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% GfsDidotSourire.dtx  (with options: `package')
%% ----------------------------------------------------------------
%% GfsDidotSourire --- Command to use the Gfs Didot fonts in the documents
%%                     of Sourire Informatique.
%% E-mail: tech.support@sourire.ch
%% Released under the LaTeX Project Public License v1.3c or later
%% See http://www.latex-project.org/lppl.txt
%% ----------------------------------------------------------------
\RequirePackage{xparse,expl3,l3keys2e}
\ProvidesExplPackage {GfsDidotSourire} {2020-08-11} {1.0}
                     {Provide commands to setup and manipulate the Gfs
                      Didot font within the documents produced by Sourire
                      Informatique.}
\AtBeginDocument{\ExplSyntaxOff}
\tl_const:Nn \c__GfsDidotSO_GfsDidotRm_tl {GFSDidot}
\tl_const:Nn \c__GfsDidotSO_GfsDidotSf_tl {GFSNeohellenic}
\tl_const:Nn \c__GfsDidotSO_LucidaSfIt_tl {LucidaSansOT-Italic}
\tl_const:Nn \c__GfsDidotSO_LucidaSfItBx_tl {LucidaSansOT-DemiItalic}
\tl_const:Nn \c__GfsDidotSO_LucidaExtension_tl {.otf}
\tl_const:Nn \c__GfsDidotSO_lmSfIt_tl {lmsans10-oblique}
\tl_const:Nn \c__GfsDidotSO_lmSfItBx_tl {lmsans10-boldoblique}
\tl_const:Nn \c__GfsDidotSO_lmExtension_tl {.otf}
\tl_const:Nn \c__GfsDidotSO_MathRm_tl {Asana-Math}
\tl_const:Nn \c__GfsDidotSO_MathSf_tl {GFSNeohellenicMath}
\tl_const:Nn \c__GfsDidotSO_MathExtension_tl {.otf}
\tl_const:Nn \c__GfsDidotSO_GfsDidotTt_tl {DejaVuSansMono}
\str_const:Nn \c__GfsDidotSO_HtmlMode_str {HTML}
\str_const:Nn \c__GfsDidotSO_PapierMode_str {PAPIER}
\str_const:Nn \c__GfsDidotSO_NoneMode_str {AUCUN}
\cs_set:Npx \GfsDidotModeHtml { \str_use:N \c__GfsDidotSO_HtmlMode_str }
\cs_set:Npx \GfsDidotModePapier { \str_use:N \c__GfsDidotSO_PapierMode_str }
\cs_set:Npx \GfsDidotModeNone { \str_use:N \c__GfsDidotSO_NoneMode_str }
\bool_new:N \g__GfsDidotSO_NeoHellenicOnly_bool
\bool_set_false:N \g__GfsDidotSO_NeoHellenicOnly_bool
\bool_new:N \g__GfsDidotSO_greekfont_bool
\bool_set_true:N \g__GfsDidotSO_greekfont_bool
\bool_new:N \g__GfsDidotSO_DefAuto_bool
\bool_set_true:N \g__GfsDidotSO_DefAuto_bool
\bool_new:N \g__GfsDidotSO_MathFonts_bool
\bool_set_true:N \g__GfsDidotSO_MathFonts_bool
\tl_new:N \g__GfsDidotSO_mode_str
\tl_set:Nx \g__GfsDidotSO_mode_str { \c__GfsDidotSO_PapierMode_str }
\tl_set:Nx \l__GfsDidotSO_mode_str { \c__GfsDidotSO_PapierMode_str }
\tl_new:N \g__GfsDidotSO_SfItReplSpec_tl
\tl_new:N \g__GfsDidotSO_MathFontName_tl
\tl_set:Nx \g__GfsDidotSO_MathFontName_tl { \tl_use:N \c__GfsDidotSO_MathRm_tl }
\tl_new:N \g__GfsDidotSO_gfsdidotRmSpec_tl
\tl_new:N \g__GfsDidotSO_gfsdidotSfSpec_tl
\tl_new:N \g__GfsDidotSO_gfsdidotTtSpec_tl
\tl_new:N \g__GfsDidotSO_GreekRmSpec_tl
\tl_new:N \g__GfsDidotSO_GreekSfSpec_tl
\tl_new:N \g__GfsDidotSO_GreekTtSpec_tl
\tl_new:N \g__GfsDidotSO_SfItReplLuSpec_tl
\tl_new:N \g__GfsDidotSO_SfItReplLmSpec_tl
\tl_new:N \g__GfsDidotSO_MathFontSpec_tl
\tl_set:Nx \g__GfsDidotSO_gfsdidotRmSpec_tl
{
           Extension=.otf,
           UprightFont=*,
           BoldFont=*Bold,
           ItalicFont=*Italic,
           BoldItalicFont=*BoldItalic,
}
\tl_set:Nx \g__GfsDidotSO_gfsdidotSfSpec_tl
{
         Extension=.otf,
         UprightFont=*,
         BoldFont=*Bold,
         BoldItalicFont=*BoldIt,
         ItalicFont=*It,
         RawFeature=+pnum,% variable width numbers
         WordSpace={0.75,0.75,1},
         Scale=MatchLowercase,
}
\tl_set:Nx \g__GfsDidotSO_gfsdidotTtSpec_tl
{
           Extension=.ttf,
           UprightFont=*,
           BoldFont=*-Bold,
           ItalicFont=*-Oblique,
           BoldItalicFont=*-BoldOblique,
           Scale=MatchLowercase,
}
\tl_set:Nx \g__GfsDidotSO_GreekRmSpec_tl
{
          Script=Greek,
          \tl_use:N \g__GfsDidotSO_gfsdidotRmSpec_tl
}
\tl_set:Nx \g__GfsDidotSO_GreekSfSpec_tl
{
          Script=Greek,
          \tl_use:N \g__GfsDidotSO_gfsdidotSfSpec_tl
}
\tl_set:Nx \g__GfsDidotSO_GreekTtSpec_tl
{
          Script=Greek,
          \tl_use:N \g__GfsDidotSO_gfsdidotTtSpec_tl
}
\tl_set:Nx \g__GfsDidotSO_SfItReplLuSpec_tl
{
         ItalicFont=\tl_use:N \c__GfsDidotSO_LucidaSfIt_tl
                    \tl_use:N \c__GfsDidotSO_LucidaExtension_tl,
         BoldItalicFont=\tl_use:N \c__GfsDidotSO_LucidaSfItBx_tl
                        \tl_use:N \c__GfsDidotSO_LucidaExtension_tl,
         Scale = MatchLowercase,
}
\tl_set:Nx \g__GfsDidotSO_SfItReplLmSpec_tl
{
         ItalicFont=\tl_use:N \c__GfsDidotSO_lmSfIt_tl
                    \tl_use:N \c__GfsDidotSO_lmExtension_tl,
         BoldItalicFont=\tl_use:N \c__GfsDidotSO_lmSfItBx_tl
                        \tl_use:N \c__GfsDidotSO_lmExtension_tl,
         Scale = MatchLowercase,
}
\tl_set:Nx \g__GfsDidotSO_MathFontSpec_tl
{
         Extension=.otf,
         Scale = MatchLowercase,
}
\tl_set:Nx \g__GfsDidotSO_SfItReplSpec_tl { \tl_use:N \g__GfsDidotSO_SfItReplLuSpec_tl }
\cs_new:Npn \__GfsDidotSO_ifModeSpecifiable:nTF #1#2#3 {
   \group_begin:
       \cs_set:Npx \ModeProductionDoc { #1 }
       \cs_set:Npn \ModeSpecifiable { #2 }
       \cs_set:Npn \ModeNonSpecifiable { #3 }
       \str_if_eq:VVTF \ModeProductionDoc \c__GfsDidotSO_NoneMode_str
                         { \ModeNonSpecifiable }
                         { \ModeSpecifiable }
}
\cs_new:Npn \__GfsDidotSO_tutex_p: { \sys_if_engine_luatex_p: ||
                            \sys_if_engine_xetex_p:}
\cs_new:Npn \__GfsDidotSO_fontspec_p: { ! (\cs_if_free_p:N \setfontface &&
                                  \cs_if_free_p:N \setfontfamily ) }
\DeclareDocumentCommand \GfsDidotSetup { m }
{ \keys_set:nn { GfsDidotSourire } { #1 } }
\DeclareDocumentCommand \DefCmdGfsDidot { O{\c__GfsDidotSO_NoneMode_str} }
{
\bool_if:nTF { \__GfsDidotSO_tutex_p: } {%TeX Unicode
   \bool_if:nTF {\__GfsDidotSO_fontspec_p:} {
       \setfontfamily\GfsDidotRm{\tl_use:N \c__GfsDidotSO_GfsDidotRm_tl}%
                     [\tl_use:N \g__GfsDidotSO_gfsdidotRmSpec_tl,Scale=MatchLowercase,]
       \bool_if:nF { \g__GfsDidotSO_NeoHellenicOnly_bool }{%
           \tl_gput_right:Nx \g__GfsDidotSO_gfsdidotSfSpec_tl
                             { \g__GfsDidotSO_SfItReplSpec_tl }%
       }
       \setfontfamily\GfsDidotSf{\tl_use:N \c__GfsDidotSO_GfsDidotSf_tl}%
                     [\tl_use:N \g__GfsDidotSO_gfsdidotSfSpec_tl,%
                                Scale=MatchLowercase,]%
       \setfontfamily\GfsDidotTt{\tl_use:N\c__GfsDidotSO_GfsDidotTt_tl}%
                         [\tl_use:N \g__GfsDidotSO_gfsdidotTtSpec_tl,%
                                    Scale=MatchLowercase,]%
      \bool_if:nT { \g__GfsDidotSO_greekfont_bool }{%
        \setfontfamily\greekfont{\tl_use:N \c__GfsDidotSO_GfsDidotRm_tl}%
                          [ \tl_use:N \g__GfsDidotSO_GreekRmSpec_tl ]
        \setfontfamily\greekfontsf{\tl_use:N \c__GfsDidotSO_GfsDidotSf_tl}%
                          [ \tl_use:N \g__GfsDidotSO_GreekSfSpec_tl ]
        \setfontfamily\greekfonttt{\tl_use:N \c__GfsDidotSO_GfsDidotTt_tl}%
                          [ \tl_use:N \g__GfsDidotSO_GreekTtSpec_tl ]
      }%
   }%
   {%No "fontspec": normally impossible, "fontspec"
    %is always loaded!
      \bool_if:nT { \g__GfsDidotSO_greekfont_bool }{%
        \DeclareDocumentCommand\greekfont{}{\relax}
        \DeclareDocumentCommand\greekfontsf{}{\relax}
        \DeclareDocumentCommand\greekfonttt{}{\relax}
      }
        \DeclareDocumentCommand\GfsDidotRm{}{\rmfamily}
        \DeclareDocumentCommand\GfsDidotSf{}{\sffamily}
        \DeclareDocumentCommand\GfsDidotTt{}{\ttfamily}
   }
   }{% TeX standards
      \bool_if:nT { \g__GfsDidotSO_greekfont_bool }{%
        \DeclareDocumentCommand\greekfont{}{\relax}
        \DeclareDocumentCommand\greekfontsf{}{\relax}
        \DeclareDocumentCommand\greekfonttt{}{\relax}
      }
      \DeclareDocumentCommand\GfsDidotRm{}{\rmfamily}
      \DeclareDocumentCommand\GfsDidotSf{}{\sffamily}
      \DeclareDocumentCommand\GfsDidotTt{}{\ttfamily}
   }
}
\DeclareDocumentCommand \PoliceGfsDidot { O{\c__GfsDidotSO_NoneMode_str} }
{
   \bool_if:nTF { \__GfsDidotSO_tutex_p: } {%TeX Unicode
      \setmainfont{\tl_use:N \c__GfsDidotSO_GfsDidotRm_tl}%
                  [\tl_use:N \g__GfsDidotSO_gfsdidotRmSpec_tl]
       \bool_if:nF { \g__GfsDidotSO_NeoHellenicOnly_bool }{%
           \tl_gput_right:Nx \g__GfsDidotSO_gfsdidotSfSpec_tl { \g__GfsDidotSO_SfItReplSpec_tl }
       }
         \setsansfont{\tl_use:N \c__GfsDidotSO_GfsDidotSf_tl}%
                     [\tl_use:N \g__GfsDidotSO_gfsdidotSfSpec_tl]
         \setmonofont{\tl_use:N\c__GfsDidotSO_GfsDidotTt_tl}%
                      [\tl_use:N \g__GfsDidotSO_gfsdidotTtSpec_tl]%
         \DefCmdGfsDidot
   }{%
     \DefCmdGfsDidot
   }%
}
\DeclareDocumentCommand \PoliceGfsDidotMath { O{\c__GfsDidotSO_NoneMode_str} }
{
   \bool_if:nTF { \__GfsDidotSO_tutex_p: } {%TeX Unicode
      \bool_if:nTF { \g__GfsDidotSO_MathFonts_bool }
                   { \use:x {
                      \setmathfont { \tl_use:N \g__GfsDidotSO_MathFontName_tl }
                      [\tl_use:N \g__GfsDidotSO_MathFontSpec_tl]
                     }
                   }
                   { \relax }%
   }{%
     \relax
  }%
}
\keys_define:nn { GfsDidotSourire }
{
   NeoHellenicOnly       .bool_set:N = \g__GfsDidotSO_NeoHellenicOnly_bool,
   math-fonts            .bool_set:N = \g__GfsDidotSO_MathFonts_bool,
   polygrec              .bool_set:N = \g__GfsDidotSO_greekfont_bool,
   math .choice:,
      math / assana      .code:n = \tl_set:Nx \g__GfsDidotSO_MathFontName_tl
                                   { \tl_use:N \c__GfsDidotSO_MathRf_tl },
      math / neohellenic .code:n = \tl_set:Nx \g__GfsDidotSO_MathFontName_tl
                                   { \tl_use:N \c__GfsDidotSO_MathSf_tl },
   SfItRepl .choice:,
      SfItRepl / lucida .code:n = \tl_set:Nx \g__GfsDidotSO_SfItReplSpec_tl
                                             { \tl_use:N \g__GfsDidotSO_SfItReplLuSpec_tl },
      SfItRepl / lm     .code:n = \tl_set:Nx \g__GfsDidotSO_SfItReplSpec_tl
                                             { \tl_use:N \g__GfsDidotSO_SfItReplLmSpec_tl },
   def .choice:,
      def / auto        .code:n =  \bool_gset_true:N  \g__GfsDidotSO_DefAuto_bool,
      def / manuel      .code:n =  \bool_gset_false:N  \g__GfsDidotSO_DefAuto_bool,
   mode .choice:,
      mode / PAPIER     .code:n =  \tl_gset:Nx \g__GfsDidotSO_mode_str {#1},
      mode / HTML       .code:n =  \tl_gset:Nx \g__GfsDidotSO_mode_str {#1},
}
\ProcessKeysOptions { GfsDidotSourire }
\bool_if:nTF { \__GfsDidotSO_tutex_p: } {
   \RequirePackage{fontspec}
   \bool_if:nT { \g__GfsDidotSO_MathFonts_bool }
               { \RequirePackage{unicode-math} }
}
      {\RequirePackage{DejaVuSansMono}
       \RequirePackage{gfsneohellenic}
       \RequirePackage{gfsdidot}}
\bool_log:N \g__GfsDidotSO_NeoHellenicOnly_bool
\bool_log:N \g__GfsDidotSO_DefAuto_bool
\bool_log:N \g__GfsDidotSO_greekfont_bool
\bool_log:N \g__GfsDidotSO_MathFonts_bool
\str_log:N \g__GfsDidotSO_mode_str
\tl_log:N \c__GfsDidotSO_GfsDidotRm_tl
\tl_log:N \g__GfsDidotSO_gfsdidotRmSpec_tl
\tl_log:N \g__GfsDidotSO_GreekRmSpec_tl
\tl_log:N \c__GfsDidotSO_GfsDidotSf_tl
\tl_log:N \g__GfsDidotSO_gfsdidotSfSpec_tl
\tl_log:N \g__GfsDidotSO_GreekSfSpec_tl
\tl_log:N \c__GfsDidotSO_GfsDidotTt_tl
\tl_log:N \g__GfsDidotSO_gfsdidotTtSpec_tl
\tl_log:N \g__GfsDidotSO_GreekTtSpec_tl
\tl_log:N \g__GfsDidotSO_MathFontName_tl
\tl_log:N \g__GfsDidotSO_MathFontSpec_tl
\bool_if:NT \g__GfsDidotSO_DefAuto_bool {%
    \AtBeginDocument{%
         \PoliceGfsDidot[\tl_use:N  \g__GfsDidotSO_mode_str]%
         \PoliceGfsDidotMath[\tl_use:N  \g__GfsDidotSO_mode_str]%
    }
}
%% 
%% Copyright (C) 2020 by Alain Aubord <alain.aubord@sourire.ch>
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License (LPPL), either
%% version 1.3c of this license or (at your option) any later
%% version.  The latest version of this license is in the file:
%% 
%% http://www.latex-project.org/lppl.txt
%% 
%% This work is "maintained" (as per LPPL maintenance status) by
%% tex.support@sourire.ch.
%% 
%% This work consists of the file  GfsDidotSourire.dtx
%% and the derived files           GfsDidotSourire.ins,
%%                                 prtGfsDidotSourire.sty,
%%                                 testSimpleGfsDidot.tex,
%%                                 testGfsDidot.tex,
%%                                 GfsDidotSourire.pdf and
%%                                 GfsDidotSourire.sty.
%%
%% End of file `GfsDidotSourire.sty'.
