| 1 |
%% This is part of the OpTeX project, see http://petr.olsak.net/optex |
| 2 |
|
| 3 |
\_famdecl [Fraunces] \Fraunces {Display, "Old Style" soft serif typeface} |
| 4 |
{\wonky} {\rm \bf \it \bi} {Bonum} |
| 5 |
{[Fraunces-VariableFont_SOFT,WONK,opsz,wght]} |
| 6 |
{\_def\_fontnamegen {[Fraunces-\_currV VariableFont_SOFT,WONK,opsz,wght]:-liga;% |
| 7 |
axis={wght=\_f_getwght{+300},opsz=\_the\_f_opsz,soft=\_the\_f_soft};\_wonkyV\_fontfeatures}} |
| 8 |
|
| 9 |
% \_f_getwght{+300} returns \the\wght but if \bf or \bi is processed then it returns \wght+300. |
| 10 |
\_def \_f_getwght#1{\_if b\_ea\_ignoresecond\_famv \_the\_numexpr \_f_wght#1\_relax \_else \_the\_f_wght \_fi} |
| 11 |
|
| 12 |
\_wlog{\_detokenize{% |
| 13 |
Modifiers:^^J |
| 14 |
\wonky ..... alternative strokes^^J |
| 15 |
\thin ...... \rm, \it = Thin, \bf, \bi = Normal^^J |
| 16 |
\light ..... \rm, \it = Light, \bf, \bi = Medium^^J |
| 17 |
\normal .... \rm, \it = Normal, \bf, \bi = Bold^^J |
| 18 |
\bolder .... \rm, \it = Medium, \bf, \bi = Black^^J% |
| 19 |
Variable font parameters:^^J |
| 20 |
\wght ...... 100--1000 (default 400): weight of the strokes^^J |
| 21 |
\opsz ...... 6--144 (default 14): optical size modification^^J |
| 22 |
\ssoft ..... 0--100 (default 0): softness of serifs^^J |
| 23 |
Use \wght=650 \ssoft=50 (for example). It acts like others font modifiers.^^J% |
| 24 |
Extended variants:^^J |
| 25 |
\tf \ti .... Thin, ThinItalic^^J |
| 26 |
\lf \li .... Light, LightItalic^^J |
| 27 |
\mf \mi .... Medium, MediumItalic^^J |
| 28 |
\kf \ki .... Black, BlackItalic^^J |
| 29 |
}} |
| 30 |
|
| 31 |
\_ifx\_f_wght\_undefined \_newcount\_f_wght \_f_wght=400 \_newpublic \_let\wght=\_f_wght \_fi |
| 32 |
\_ifx\_f_opsz\_undefined \_newcount\_f_opsz \_f_opsz=14 \_newpublic \_let\opsz=\_f_opsz \_fi |
| 33 |
\_ifx\_f_soft\_undefined \_newcount\_f_soft \_f_soft=0 \_newpublic \_let\ssoft=\_f_soft \_fi |
| 34 |
|
| 35 |
\_moddef \resetmod {\_fsetV wonky={} \_fvars {} {} Italic- Italic- } |
| 36 |
\_moddef \wonky {\_fsetV wonky=+ss01; } |
| 37 |
\_moddef \thin {\_f_wght=100 } |
| 38 |
\_moddef \light {\_f_wght=250 } |
| 39 |
\_moddef \normal {\_f_wght=400 } |
| 40 |
\_moddef \medium {\_f_wght=550 } |
| 41 |
\_let\_thinM=\thin \_let\_lightM=\light \_let\_mediumM=\medium |
| 42 |
|
| 43 |
\_famvardef \tf {\_thinM \_rm} |
| 44 |
\_famvardef \ti {\_thinM \_it} |
| 45 |
\_famvardef \lf {\_lightM \_rm} |
| 46 |
\_famvardef \li {\_lightM \_it} |
| 47 |
\_famvardef \mf {\_mediumM \_rm} |
| 48 |
\_famvardef \mi {\_mediumM \_it} |
| 49 |
\_famvardef \kf {\_mediumM \_bf} |
| 50 |
\_famvardef \ki {\_mediumM \_bi} |
| 51 |
|
| 52 |
\_initfontfamily % new font family must be initialized |
| 53 |
|
| 54 |
\_loadmath {[texgyrebonum-math]} |
| 55 |
|
| 56 |
\_endcode |
| 57 |
|
| 58 |
This is an example of a font-file used for a variable fonts. |
| 59 |
|
| 60 |
\begitems |
| 61 |
* Declare counters with the same names as parameters of axis. |
| 62 |
* Use `\_ifx\_...\_undefined` in order to more font-files with variable fonts can be loaded. |
| 63 |
* Use `axis={...}` in font features area in the `\_fontnamegen` macro. |
| 64 |
* Print about axis parameters of given font to the log using `\_wlog`. |
| 65 |
* The `\_f_getwght` macro should be declared same in all font-files with variable fonts. |
| 66 |
It enables \bf and \bi variants implemented as the given shift of the current wght parameter. |
| 67 |
* You can declare more variants by `\famvardef`. |
| 68 |
* You can declare font modifiers and font variants using values of axis parameters. |
| 69 |
\enditems |