diff options
Diffstat (limited to 'macros/luatex/optex/f-heros.opm')
-rw-r--r-- | macros/luatex/optex/f-heros.opm | 191 |
1 files changed, 191 insertions, 0 deletions
diff --git a/macros/luatex/optex/f-heros.opm b/macros/luatex/optex/f-heros.opm new file mode 100644 index 0000000000..7e466432a3 --- /dev/null +++ b/macros/luatex/optex/f-heros.opm @@ -0,0 +1,191 @@ +%% This is part of OpTeX project, see http://petr.olsak.net/optex + +\_fontdecl [Heros] \Heros {TeX Gyre Heros fonts based on Helvetica} + {\caps \cond} {\rm \bf \it \bi} {TX} + "[texgyreheros-regular]" + +\_wlog{\_detokenize{% +Modifiers:^^J + \caps ...... caps & small caps^^J + \cond ...... condensed variants^^J +}} + +\_protected\_def \Heros {% + \_def \_currfamily {Heros}% + \_def \_fontnamegen {"[texgyreheros\_condV-\_currV]:\_capsV\_fontfeatures"}% + \_resetmod +} +\_moddef \resetmod {\_fsetV caps={},cond={} \_fvars regular bold italic bolditalic } +\_moddef \caps {\_fsetV caps=+smcp;+onum; } +\_moddef \nocaps {\_fsetV caps={} } +\_moddef \cond {\_fsetV cond=cn } +\_moddef \nocond {\_fsetV cond={} } + +\_initfontfamily % new font family must be initialized + +\_endcode + + +The usage of font \OpTeX/ selection system is described in the +fonts-select.opm file. + + +\sec How to write font-macro-file for \OpTeX/ like this file +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The font-macro-file declares a font family for selecting a font from such +family at arbitrary size and with various shapes. Unicode fonts (OTF) +are preferred. If we want to write such font file, we need to keep following +rules. + +\begitems +* Use +\begtt +\_fontdecl [<Name of family>] \<Main-command> {<comments>} + {<modifiers>} {<variant selectors>} {<comments about math fonts>} + "<font-for-testing>" +\endtt + as first command in this file. This writes information about font family at + terminal and prevents loading such file twice. Moreover, it probes + existence of `<font-for-testing>` in your system. If it isn't exist, the + file loading is skipped with a warning on the terminal. + The \_ifexistfam macro returns false in such case. +* You can use `\_wlog{\_detokenize{...` to write aditional information into + log file. +* Define `\<Main-command>` (the commend `\Heros` here) as a `\_protected` + macro. This macro initializes the family and it must do: + \begitems + * Define `\_currfamily` as a short name of the font family. It must be + exactly the same as `<Main-command>` name but without backslash + (it is case sensitive). + * Define `\_fontfeatures` if they are something special. + * Define `\_fontnamegen` as a template of generic font name used as file + names (or font names) of OTF fonts. The rules about `\_fontnamegen` macro + are documented below. + * Use \_resetmod modifier to initialize values. + \enditems +* You can declare optical sizes using `\_regoptsizes` if there are more font files + with different optical sizes (like in Latin Modern). See `f-lmfonts.ofm` + file for more information about this special feature. +* Declare font modifiers using `\_moddef` if they are present. The + \_resetmod must be declared in each font family. +* Check if all your declared modifiers does not produce any space in + horizontal mode. For example check: X\caps Y, the letters XY must + be printed without any space. Do the same test with \<Main-command> + before releasing your font file, for example X\Heros Y. +* Run `\_initfontfamily` in order to start the family. +\enditems + +The font file must declare `\_fontnamegen` macro which must expand (at +expand processor level only) to a file name of loaded font (or to its font +name) and to optional fontfeatures appended. The font selection +system uses this macro at primitive level in the following sense: + +\begtt + \font \_fontnamegen \space \_sizespec +\endtt + +For example, using macros from `f-heros.opm` the `\font` command expands its +parameters to: + +\begtt + \font "[texgyreheros-regular]:+tlig;" at10pt +\endtt + +if the `\rm` variant is processed and if no additional font modifiers are +activated. Of course, you need to know something about fontname syntax for +extended `\font` primitive used with OTF fonts. The `"` characters are at +outside boundary of font name. The `[` `]` brackets tell us that the file +name (no font name) is specified inside such brackets. This file (with +additional `.otf` extension) must be accessible in your filesystem. Without +spaces, there are font features appended to file name (or font name) divided +by semicolon. The `+tlig` font feature means that TeX like ligatures +(minus minus = endash, for example) are active. Normal ligatures are active +by default. You can list font features of given font by +`otfinfo -f fontfile.otf`. + +You can use any expandable macros or expandable primitives in `\fontnamegen` +macro. The simple macros in it with names `\_<word>V` are preferred. They +expand typically to their content. The macro `\_fsetV <word>=<content>` +(terminated by a space) is equivalent to `\def\_<word>V{<content>}` and you +can use it in font modifiers. You can use the `\_fsetV` macro in more +general form: + +\begtt + \_fsetV <wordA>=<valueA>,<wordB>=<valueB> ...etc. terminated by a space +\endtt + +with obvious result `\def\_<wordA>V{<valueA>}\def\_<wordB>V{<valueB>} etc. + +There is one special macro `\_currV` which expands to one of four variants +depending on which variant selector is in process. Four strings can be +saved by `\_fvars rm-variant bf-variant it-variant bi-varaiant` (all four strings +must be terminated by a space). One of these +string is used as expansion output of `\_currV` macro. Because we store + +\begtt + \_fvars regular bold italic bolditalic +\endtt + +in `\resetmod` modifier then the `\_currV` expands (for example) +to `italic` if the `\it` variant selector is in process. + +Example: if both modifiers `\caps` and `\cond` were applied from this family +Heros and `\bf` variant is needed at 11pt then + +\begtt + \font "[texgyreheroscn-bold]:+smcp;+tlig;" at11pt +\endtt + +is processed. We assume that a font file texgyreheroscn-bold.otf is present +in your TeX system. + +Define all modifiers using `\_moddef` macro. +The `\_moddef` macro does more things than simple `\_def`: + +\begitems +* The modifier macros are defined as `\_protected`. +* The modifier macros are defined as family-dependent. If user loads more + families then `\LMfonts \caps` does somewhat different job than + `\Heros \caps`, for example. +\enditems + +Finally the `\_initfontfamily` must be run. It runs \<Main-command>. +So, the `\_resetmod` macro (declared as `\resetmod`) is processed. Finally it +runs `\_rm`, so first font from new family is loaded and is ready to use it. + +\secc Name conventions +%--------------------- + +Create modificators, new variants and `\<Main-command>` only as public, i.e. +without `_` prefix. We assume that if user re-defines them then he/she need +not them, so we have no problems. + +If you need to declare your private modifier (because it is used in another +modifiers or macros, for example), use the name `\_wordM`. You can be +sure that such name does not influence the private name space used by \OpTeX/. + +The private variant `\_resetmod` must be used in your +`\<Main-command>` but you need not to declare it as private, +it is done automatically. Declare only `\restmod` by `\_moddef` macro. + +The name of `\<Main-command>` should begin with uppercase letter. + +See font-macro-file `f_libertine-s.opm` which is another example where no +font files but font names are used. + +\secc Additional notes +%--------------------- + +In very rare situations we have more files with almost the same font but +designed for different optimal sizes (so called "optical sizes"). See a +collection of lmroman*.otf files, for example. You can declare such font +files for various optical sizes using `\_optname` macro in the +`\_fontnamegen` macro. See the file `f-lmfonts.opm` for more details. + +If you need to create font-macro-file with non unicode font, you can do it. +The `\_fontnamegen` must expand to the name of TFM file in such case. But we +don't prefer such font-macro-files, because they are usable only with +laguages with alphabet subset to ISO-8859-1 (unicodes are equal to letter +codes of such alphabets), but middle or east Europe use languages where +such condition is not true. |