summaryrefslogtreecommitdiff
path: root/info/mathtrip/src/ChoixPolice.sty
blob: ef2b066c4d2b4cfaac28a44af7b50ba0bcbd27fd (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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
%This style file allows to easily switch between many fonts.
%It is particularly useful when working with 16bits TeX
%but it can be used with normal TeX too (with less
%font choices).
%
%This style uses options to determine the fonts to use.
%                lmodern (or nothing) to choose the default font "lmmodern".
%                cmunicode              to use the "cmunicode" fonts. This fonts
%                                       has been created with all the CM fonts for 8bits TeX
%                                       and it is quite nice. THe characters are similar to lmmodern
%                                       with more glyphs (greek, cyrillic IPA) and no math font.
%                                       L'aspect des caractères est similaire à latin Modern.
%                                       Some of the characters are based on the good fonts from BlueSky.
%                didot                  to use GFS Didot with Asana Math for mathematic.
%                                       When 8bits TeX is used, the package "gfsdidot" is loaded.
%                lucida                 to use lucida (mathematic and standard)
%                stix                   to use STIX2 fonts (Mathematic and Standard)
%                cambria                to use Cambria with Cambria Math
%                                       Calibri is used for the sans serif font.
%                dejavu                 to use DejaVu (serif) and the math fonts from GUST foundry.
%                dejavusans             to use DejaVu Sans for text and Math. To complement
%                                       the LucidaBrightOT is used. When 8bits TeX is used,
%                                       the package "arev" is loaded.
%                neohellenic            to use GFS Neo Hellenic with GFSNeoHellenicMath.
%
%
%
%
% — Normally, other sahpe (tt or sans) are Latin Modern or DejaVu. 
%
% — Fonts "Latin Modern", "GFS Didot" and "Asana" are provided
%   (in usul directories) with all TeX distributions.
% — The fonts «STIX» version 2 (similar to Times Roman)
%   should be installed, after being downloaded from site
%   «http://www.stixfonts.org/», in the usual directories of TeX.
% — The fonts family "Lucida" should be bought at TUG
%   (https://www.tug.org) and installed in usual TeX directories.
% — The fonts "Cambria", "Cambria Math" and "Calibri" should be installed
%   as system fonts. This is generally the case when Excel is installed.
%
% — For the TeX 8bits, the fonts lmmodern is used except when gfsdidot or arev is loaded.
%   To use an other fonts, one can load the correct package after this style.
%   Par exemple, \usepackage[charter]{mathdesign}
%
% — This code has been tested with XeLateX (TeX 16bits) and pdflatex (TeX 8bits).
\chardef\PoliceLatinModern=0
\chardef\PoliceDidot=1
\chardef\PoliceLucida=2
\chardef\PoliceStixII=3
\chardef\PoliceCambria=4
\chardef\PoliceDejaVu=5
\chardef\PoliceCmUnicode=6
\chardef\PoliceDejavuSans=7
\chardef\PoliceNeoHellenic=8
%Useful to have an invalid value for a font. A such value can be used
%as an initializer or a delimiter of list
\chardef\PoliceInvalide=254 

%The default font used to typeset the document if the wanted font
%is not found. If one change this font, he should change
%the macros '\PoliceParDefaut' and '\MainFontDocText' accordingly.
\chardef\PoliceDocumentParDefaut=\PoliceLatinModern
%The real font of the document
\chardef\PoliceDocument\PoliceDocumentParDefaut
%The wanted font of the document. This macro and the previous one
%have the same value if the font is found but might differ
%if the default font is used when the wanted font cannot be found.
\chardef\PoliceDesiree\PoliceLatinModern
\DeclareOption{lmodern}{\chardef\PoliceDocument\PoliceLatinModern
                        \chardef\PoliceDesiree\PoliceLatinModern}
\DeclareOption{didot}{\chardef\PoliceDocument\PoliceDidot
                      \chardef\PoliceDesiree\PoliceDidot}
\DeclareOption{lucida}{\chardef\PoliceDocument\PoliceLucida
                       \chardef\PoliceDesiree\PoliceLucida}
\DeclareOption{stix}{\chardef\PoliceDocument\PoliceStixII
                     \chardef\PoliceDesiree\PoliceStixII}
\DeclareOption{cambria}{\chardef\PoliceDocument\PoliceCambria
                        \chardef\PoliceDesiree\PoliceCambria}
\DeclareOption{dejavu}{\chardef\PoliceDocument\PoliceDejaVu
                       \chardef\PoliceDesiree\PoliceDejaVu}
\DeclareOption{cmunicode}{\chardef\PoliceDocument\PoliceCmUnicode
                          \chardef\PoliceDesiree\PoliceCmUnicode}
\DeclareOption{dejavusans}{\chardef\PoliceDocument\PoliceDejavuSans
                           \chardef\PoliceDesiree\PoliceDejavuSans}
\DeclareOption{neohellenic}{\chardef\PoliceDocument\PoliceNeoHellenic
                            \chardef\PoliceDesiree\PoliceNeoHellenic}
\ProcessOptions

\usepackage{iftex}

%
%-------------------------------------Macros provided by the style--------------------------
%

%This macro provides the default settings when no font is specified (for TeX Unicode only).
%The default is to use the font Latin Modern and generally since it is
%the current default from pdfTeX, XeTeX and LuaTeX, almost nothing
%should be done.
%
%Since this fonts does not provide the greek character, these one are taken
%from the very similar CM Unicode font.
%
%This Macro has no parameter.
%
%This macro modify the global variable/macro "\PoliceDocument"
\newcommand\PoliceParDefaut{%
   \iftutex %16 bits TeX
           %The default font is Latin Modern, always defined with 16 bits TeX.
           %However, Greek is missing from Latin Modern. It will be taken from
           %the almost identical font CM Unicode.
	         %The command «\greekfont» is used with "polyglossia" and
	         %probably "babel".
	   \newfontfamily\greekfont[Script=Greek]{cmunrm.otf}[%
           Extension=.otf,%
           UprightFont=*,%
           BoldFont=cmunbx,%
           ItalicFont=cmunti,%
           BoldItalicFont=cmunbi]%
      \else %8bits TeX
	     \RequirePackage{lmodern}%
      \fi
      \chardef\PoliceDocument\PoliceDocumentParDefaut
}

%This macros contain the text to describe
%the default main font of the document.
%
%The macro has no parameter
\newcommand\MainFontDocText{%
   \iftutex{Latin Modern (Unicode)}\else{Latin Modern (\TeX)}\fi
}
    
%This macro typeset the name of the current set of fonts used to format
%the document.
%The name is similar to the option choosen but generally more suitable to be
%typeset in a document.
%
%To know, programmatically, the current font of the document, it's much
%better to use the macro "\PoliceDocument".
%
%The macro has no parameter.
\newcommand\MainDocFontName[1][\PoliceDocument]{
   \iftutex
      \ifcase#1%
       %Latin Modern
          \MainFontDocText
      \or
      %Didot
          GFS Didot, Asana Math%
      \or
      %Lucida
          Lucida%
      \or
      %Stix version 2 
          Stix 2%
      \or
      %Cambria
          Cambria, Cambria Math%
      \or
      %DejaVu
          DejaVu, TeX Gyre DejaVu Math%
      \or
      %CMUnicode
          CMUnicode, Latin Modern Math%
      \or
      %DejaVuSans
      \IfFontExistsTF{LucidaBrightMathOT.otf}{%
          DejaVu Sans,  Lucida Bright Math%
      }{%
          DejaVu Sans,  DejaVu Sans Math%
      }%
      \or
      %NeoHellenic
          GFS NeoHellenic%
      \else
          \MainFontDocText
      \fi
     \else
        %TeX standard
        \ifx\PoliceDocument\PoliceDejavuSans
        %Arev
            Arev (\TeX)%
        \else
          \ifx\PoliceDocument\PoliceDidot
          %Didot
              GFS Didot (\TeX)%
          \else
   	   %The default, lmmodern
              \MainFontDocText
          \fi
        \fi
     \fi
}

%This macro setup the definition to setup a font (in almost
%all the possible modes: Text, Math, Greek etc) in a 16 Bits LaTeX (lualatex,xelatex)
%and to setup the default font in 8bit TeX.
%
%The macro has 3 parameters:
%     1) the name of the font in a form usable by the command
%        "\IfFontExistsTF" of the package "fontspec"
%     2) the set of command to define the fonts to be used
%     3) a set of commands used as a fallback in the case of the font
%        is unavailable on a system
%
%Only the second parameter is used with 8 bits TeX.
\newcommand\ChoixPolice[3]{%
   \iftutex %TeX 16 bits
      \IfFontExistsTF{#1}{#2}{%Font wanted not found
          \wlog{The font #1 is not found. The font '\MainFontDocText' will be used instead.}%
          #3}%
   \else %TeX 8bits
    #2%
   \fi
}

%The following macros define the commands to be able to use the different
%available fonts in a document. Since they are so many fonts available, only
%the fonts with mathemathecal counterpart are defined.
\newcommand\ChoixDidot{%
   \ChoixPolice{GFSDidot.otf}{%
      \setmathfont{Asana-Math.otf}%
      \setmainfont{GFSDidot}[%
           Extension=.otf,%
           UprightFont=*,%
           BoldFont=*Bold,%
   	   ItalicFont=*Italic,%
   	   BoldItalicFont=*BoldItalic%
      ]%
   	 \setsansfont{DejaVuSans}[%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
   	   Scale = MatchLowercase%
        ]%
      \setmonofont{DejaVuSansMono}[% main typewriter%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
   }{\PoliceParDefaut}%
}
\newcommand\ChoixLucida{%
  \ChoixPolice{LucidaBrightOT.otf}{%
      % Slightly reduce the size.
      %\defaultfontfeatures{Scale=.92}
      \setmathfont{LucidaBrightMathOT.otf}%
      \setmathfont[version=bold]{LucidaBrightMathOT-Demi.otf}%
      %
      % The explicit .otf extension tells the engines to find the font via%
      % filenames in the TeX trees, rather than as system-installed fonts.%
      %
      \setmainfont{LucidaBrightOT}[% main rm%
           Extension=.otf,%
           UprightFont=*,%
           ItalicFont=*-Italic,%
           BoldFont=*-Demi,%
           BoldItalicFont=*-DemiItalic,%
        ]%
      %
      \setsansfont{LucidaSansOT}[% main sans%
           Extension=.otf,%
           UprightFont=*,%
           ItalicFont=*-Italic,%
           BoldFont=*-Demi,%
           BoldItalicFont=*-DemiItalic,%
        ]%
      %
      \setmonofont{LucidaSansTypewriterOT.otf}[% main typewriter%
           Extension=.otf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
      %
      %
      % The specialized one-off fonts:%
      \newfontface\LucidaBlackletter{LucidaBlackletterOT.otf}%
      \newfontface\LucidaCalligraphy{LucidaCalligraphyOT.otf}%
      \newfontface\LucidaHandwriting{LucidaHandwritingOT.otf}%
   }{\PoliceParDefaut}%
}
\newcommand\ChoixStix{%
  \ChoixPolice{STIX2Text-Regular.otf}{% 
      %Stix version 2 (the first version working with TeX)
      \setmathfont{STIX2Math.otf}%
      \setmainfont{STIX2Text}[%
           Extension=.otf,%
           UprightFont=*-Regular,%
           ItalicFont=*-Italic,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldItalic,%
        ]%
	 \setsansfont{DejaVuSans}[%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
      \setmonofont{DejaVuSansMono}[% main typewriter%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
	 %The macro "\greekfont" is used with "polyglossia" and "babel"%
	 \newfontfamily\greekfont[Script=Greek]{LinLibertine_R.otf}[%
	      Extension=.otf,%
          UprightFont=*,%
          BoldFont=LinLibertine_RB,%
	      ItalicFont=LinLibertine_RI,%
	      BoldItalicFont=LinLibertine_RBI]%
     }{\PoliceParDefaut}%
}
\newcommand\ChoixCambria{%
    \ChoixPolice{Cambria}{%
          \setmathfont{Cambria Math}%
	      \setmainfont{Cambria}%
	      \setsansfont{Calibri}%
          \setmonofont{DejaVuSansMono}[% main typewriter%
              Extension=.ttf,%
              UprightFont=*,%
              ItalicFont=*-Oblique,%
              BoldFont=*-Bold,%
              BoldItalicFont=*-BoldOblique,%
           ]%
    }{\PoliceParDefaut}%
}
\newcommand\ChoixDejaVu{%
    \ChoixPolice{DejaVuSerif.ttf}{%
     \setmathfont{texgyredejavu-math.otf}%
	 \setmainfont{DejaVuSerif}[%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Italic,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldItalic,%
        ]%
	 \setsansfont{DejaVuSans}[%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
      \setmonofont{DejaVuSansMono}[% main typewriter%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
   }{\PoliceParDefaut}%
}
\newcommand\ChoixCMUnicode{%
     \ChoixPolice{cmunrm.otf}{%
	%Latin Modern is used for math. For the rest, the CM Unicode (very similar to Latin
    %Modern is used). CM Unicode has more characters than Latin Modern
      \setmainfont{cmunrm}[%
           Extension=.otf,%
           UprightFont=*,%
           BoldFont=cmunbx,%
	   ItalicFont=cmunti,%
	   BoldItalicFont=cmunbi]%
      \setsansfont{cmunss}[%
           Extension=.otf,%
           UprightFont=*,%
           BoldFont=cmunsx,%
	   ItalicFont=cmunsi,%
	   BoldItalicFont=cmunso]%
      \setmonofont{cmuntt}[%
           Extension=.otf,%
           UprightFont=*,%
           BoldFont=cmuntb,%
	   ItalicFont=cmunst,%
	   BoldItalicFont=cmuntx]%
    }{\PoliceParDefaut}%
}
\newcommand\ChoixDejaVuSans{%
     \ChoixPolice{DejaVuSans.ttf}{%
      \IfFontExistsTF{LucidaBrightMathOT.otf}{%
         \setmathfont{LucidaBrightMathOT.otf}%Font color match better with dejaVuSans
      }{%
         \setmathfont{DejaVuSans.ttf}%
      }%
      \setmathfont{DejaVuSans.ttf}[range=up]%
      \setmathfont{DejaVuSans.ttf}[range=bb->bfsfup]%
      \setmathfont{DejaVuSans-Oblique.ttf}[range=it]%
      \setmathfont{DejaVuSansMono.ttf}[range=tt]%
      \setmathfont{DejaVuSans-Bold.ttf}[range=bfup]%
      \setmathfont{DejaVuSans-BoldOblique.ttf}[range=bfit]%
      \setmainfont{DejaVuSerif}[%
         Extension=.ttf,%
         UprightFont=*,%
         ItalicFont=*-Italic,%
         BoldFont=*-Bold,%
         BoldItalicFont=*-BoldItalic,%
         ]%
      \setsansfont{DejaVuSans}[%
         Extension=.ttf,%
         UprightFont=*,%
         ItalicFont=*-Oblique,%
         BoldFont=*-Bold,%
         BoldItalicFont=*-BoldOblique,%
      ]%
      \setmonofont{DejaVuSansMono}[% main typewriter%
         Extension=.ttf,%
         UprightFont=*,%
         ItalicFont=*-Oblique,%
         BoldFont=*-Bold,%
         BoldItalicFont=*-BoldOblique,%
      ]%
      \renewcommand\familydefault{\sfdefault}%
     }{\PoliceParDefaut}%
}
\newcommand\ChoixNeohellenic{%
      \ChoixPolice{GFSNeohellenic.otf}{%
      %Load GFS Neo Hellenic as the sans font and use the GFS Neo Hellenic
      %for math. Do some specific adaptation for the GFS Neo Hellenic at 12pt.
      \RequirePackage{gfsneohellenicot}%
      \setmonofont{DejaVuSansMono}[% main typewriter%
           Extension=.ttf,%
           UprightFont=*,%
           ItalicFont=*-Oblique,%
           BoldFont=*-Bold,%
           BoldItalicFont=*-BoldOblique,%
        ]%
      \renewcommand\familydefault{\sfdefault}%
      }{\PoliceParDefaut}%
}
%
%--------------------------------------Code executed when loading style----------------------
%
\iftutex
   \usepackage{unicode-math}
   \usepackage{fontspec}
   \defaultfontfeatures{Ligatures=TeX}
   \ifcase\PoliceDocument
       %Latin Modern is the default font
       \PoliceParDefaut
    \or
       \ChoixDidot
    \or
       \ChoixLucida
    \or
       \ChoixStix
    \or
       \ChoixCambria
    \or
	   \ChoixDejaVu
    \or
       \ChoixCMUnicode
    \or
       \ChoixDejaVuSans
    \or
       \ChoixNeohellenic
    \else
       \PoliceParDefaut
    \fi
  \else
     %TeX standard
     \RequirePackage{amssymb}
     \ifx\PoliceDocument\PoliceDejavuSans
         \RequirePackage{arev}
     \else
       \ifx\PoliceDocument\PoliceDidot
          \RequirePackage{gfsdidot}
       \else
	      \PoliceParDefaut
       \fi
     \fi
  \fi