summaryrefslogtreecommitdiff
path: root/macros/luatex/optex/base/f-lmfonts.opm
blob: 4c9ce04760a30c8db2338388efe6d7d5a7f00c35 (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
%% This is part of OpTeX project, see http://petr.olsak.net/optex

\_famdecl [Latin Modern] \LMfonts {TeX Gyre fonts based on Coputer Modern}
        {\roman \sans \quotset \ttset \ttprop \ttlight \ttcond \upital 
         \dunhill submods:\caps \slant \nbold \bolder} {\rm \bf \it \bi \tt} {LM}
        {[lmroman10-regular]}
        {\_def\_fontnamegen {[\_optname{lm\_subfamV.\_currV}]:\_fontfeatures}}

\_wlog{\_detokenize{%
Modifiers (selects subfamily):^^J
 \modreset .. implicit values (serif, bold extended, nocaps)^^J
 \sans ...... sans serif subfamily^^J
 \quotset ... quotation subfamily^^J
 \ttset ..... typewriter subfamily^^J
 \ttprop .... proportional typewriter-like subfamily^^J
 \ttlight ... light typewriter subfamily^^J
 \ttcond .... condensed typewriter subfamily^^J
 \upital .... upright italic (only \rm)^^J
 \dunhill ... dunhill roman subfamily (only \rm, \it)^^J%
Sub-modifiers (selects special variants of given subfamily):^^J
 \caps ...... caps & small caps (available only at limited shapes)^^J
 \slant ..... slanted (default in some subfamilies)^^J
 \nbold ..... normal bold (extended bold is default)^^J
 \bolder .... extended bold^^J
}}

\_def\_LMregfont #1 #2 #3{%
   \_edef\_tmp {\_noexpand\_regoptsizes #1 #2 \_ea\_detokenize\_ea{#3}}%
   \_lowercase\_ea{\_tmp}% OTF file names are lowercase
}
\_def \_regoptFS {5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <*}
\_def \_regoptFT {5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <*}
\_def \_regoptST {7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <*}
\_def \_regoptES {8 <8.5 9 <9.5 10 <11.1 12 <15 17 <*}
\_def \_regoptET {8 <8.5 9 <9.5 10 <11.1 12 <*}
\_def \_regoptT  {10 <*}
\_def \_regoptE  {8 <*}

\_LMregfont lmrm.r     LMRoman?-Regular        \_regoptFS  % 5-17
\_LMregfont lmrm.bx    LMRoman?-Bold           \_regoptFT  % 5-12
\_LMregfont lmrm.i     LMRoman?-Italic         \_regoptST  % 7-12
\_LMregfont lmrm.bxi   LMRoman?-BoldItalic     \_regoptT   % 10
\_LMregfont lmrm.isl   LMRomanSlant?-Regular   \_regoptES  % 8-17
\_LMregfont lmrm.bxisl LMRomanSlant?-Bold      \_regoptT   % 10
\_LMregfont lmrm.b     LMRomanDemi?-Regular    \_regoptT   % 10
\_LMregfont lmrm.bi    LMRomanDemi?-Oblique    \_regoptT   % 10

\_LMregfont lmss.r     LMSans?-Regular          \_regoptES  % 8-17
\_LMregfont lmss.bx    LMSans?-Bold             \_regoptT   % 10
\_LMregfont lmss.i     LMSans?-Oblique          \_regoptES  % 8-17
\_LMregfont lmss.bxi   LMSans?-BoldOblique      \_regoptT   % 10
\_LMregfont lmss.b     LMSansDemiCond?-Regular  \_regoptT   % 10
\_LMregfont lmss.bi    LMSansDemiCond?-Oblique  \_regoptT   % 10

\_LMregfont lmsq.r     LMSansQuot?-Regular      \_regoptE  % 8
\_LMregfont lmsq.b     LMSansQuot?-Bold         \_regoptE  % 8
\_LMregfont lmsq.i     LMSansQuot?-Oblique      \_regoptE  % 8
\_LMregfont lmsq.bi    LMSansQuot?-BoldOblique  \_regoptE  % 8

\_LMregfont lmtt.r     LMMono?-Regular        \_regoptET  % 8-12
\_LMregfont lmtt.b     LMMonoLt?-Bold         \_regoptT   % 10
\_LMregfont lmtt.i     LMMono?-Italic         \_regoptT   % 10
\_LMregfont lmtt.bi    LMMonoLt?-BoldOblique  \_regoptT   % 10
\_LMregfont lmtt.isl   LMMonoSlant?-Regular   \_regoptT   % 10
\_optfontalias {lmtt.bisl} {lmtt.bi} 

\_LMregfont lmtp.r     LMMonoPropLt?-Regular      \_regoptT  % 10
\_LMregfont lmtp.bx    LMMonoPropLt?-Bold         \_regoptT  % 10
\_LMregfont lmtp.i     LMMonoPropLt?-Oblique      \_regoptT  % 10
\_LMregfont lmtp.bxi   LMMonoPropLt?-BoldOblique  \_regoptT  % 10
\_LMregfont lmtp.b     LMMonoProp?-Regular        \_regoptT  % 10
\_LMregfont lmtp.bi    LMMonoProp?-Oblique        \_regoptT  % 10

\_LMregfont lmtl.r     LMMonoLt?-Regular  \_regoptT  % 10
\_LMregfont lmtl.i     LMMonoLt?-Oblique  \_regoptT  % 10

\_LMregfont lmtc.r     LMMonoLtCond?-Regular  \_regoptT  % 10
\_LMregfont lmtc.i     LMMonoLtCond?-Oblique  \_regoptT  % 10

\_LMregfont lmrm.rc    LMRomanCaps?-Regular \_regoptT  % 10
\_LMregfont lmrm.ic    LMRomanCaps?-Oblique \_regoptT  % 10
\_LMregfont lmtt.rc    LMMonoCaps?-Regular  \_regoptT  % 10
\_LMregfont lmtt.ic    LMMonoCaps?-Oblique  \_regoptT  % 10

\_LMregfont lmmu.r     LMRomanUnsl?-Regular    \_regoptT  % 10
\_LMregfont lmdu.r     LMRomanDunh?-Regular    \_regoptT  % 10
\_LMregfont lmdu.sl    LMRomanDunh?-Oblique    \_regoptT  % 10

% main modifiers (they select a subfamily)
\_moddef \resetmod {\_fsetV subfam=rm \_fvars r bx i bxi }
\_moddef \sans     {\_fsetV subfam=ss \_fvars r bx i bxi }
\_moddef \quotset  {\_fsetV subfam=sq \_fvars r b i bi }
\_moddef \ttset    {\_fsetV subfam=tt \_fvars r b i bi }
\_moddef \ttprop   {\_fsetV subfam=tp \_fvars r b i bi }
\_moddef \ttlight  {\_fsetV subfam=tl \_fvars r . i . }
\_moddef \ttcond   {\_fsetV subfam=tc \_fvars r . i . }
\_moddef \upital   {\_fsetV subfam=mu \_fvars r . . . }
\_moddef \dunhill  {\_fsetV subfam=du \_fvars r . sl . }

% submodifiers (they select special vaiants in a subfamily)
\_moddef \nbold    {\_onlyif subfam=rm,ss,tp: {\_fvars r b i bi }}
\_moddef \bolder   {\_onlyif subfam=rm,ss,tp: {\_fvars r bx i bxi }} 
\_moddef \slant    {\_onlyif subfam=rm:       {\_fvars r bx isl bxisl }%
                    \_onlyif subfam=tt:       {\_fvars r b isl bisl }}
\_moddef \caps     {\_onlyif subfam=rm,tt:    {\_fvars rc . ic . }}

\_def \_tryloadtt {\_fontdef\_tentt{\_LMfonts \_addto\_fontfeatures{-tlig;}\_ttset \_rm}} 
\_private \LMfonts \ttset ; % used in \_tryloadtt

\_initfontfamily % new font family must be initialized

\_loadmath {[latinmodern-math]}

\_endcode

\secc How to write the font family file with optical sizes

You can use \^`\_optname` macro when `\_fontnamegen` in expanded. This macro is fully
expandable and its input is `<internal-template>` and its output is a
part of the font file name `<size-dependent-template>` with respect to given 
optical size.

You can declare a collection of `<size-dependent-template>`s for one
given `<internal-template>` by the \^`\_regoptsizes` macro. 
The syntax is shown for one real case:

\begtt 
\_regoptsizes lmr.r lmroman?-regular
    5 <5.5 6 <6.5 7 <7.5 8 <8.5 9 <9.5 10 <11.1 12 <15 17 <* 
\endtt

In general: 

\begtt \catcode`\<=13
\_regoptsizes <internal-template> <general-ouput-template> <resizing-data>
\endtt

Suppose our example above. Then `\_optname{lmr.r}` expands to
lmroman?-regular where the question mark is substituted by a number
depending on current `\_optsize`. If the `\_optsize` lies between two boundary
values (they are prefixed by \code{<} character) then the number written between
them is used. For example if $11.1 \lt `\_optsize` \le 15$ then 12 is
substituted instead question mark. The <resizing-data> virtually begins
with zero \code{<0}, but it is not explicitly written. The right part of
<resizing-data> must be terminated by \code{<*} which means "less than infinity".

If `\_optname` gets an argument which is not registered <internal-template>
then it expands to `\_failedoptname` which typically ends to error message
about missing font. You can redefine `\_failedoptname` macro to some
existing font if you find it useful.

We are using a special macro `\_LMregfont` in `f-lmfonts.opm`. 
It sets the file names to
lowercase and enables to use a shortcasts isntead real <resizing-data>.
There are shortcats `\_regoptFS`, `\_regoptT`, etc. here. The collection of
`<internal-templates>` are declared, each of them covers a collection of real
file names.

The \^`\_optfontalias` `{<new-template>} {<internal-template>}` declares
`<new-template>` with the same meaning as previously declared
`<internal-template>`.

The `\_optname` macro can be used even if no otical sizes are provided by
a font family. Suppose that font file names are much more chaotic (because
artists are very creative people), so you need to declare more systematic
`<internal-templates>` and do an alias from each `<internal-template>` to
`<real-font-name>`. For example, you can do it as follows:

\begtt
\def\fontalias #1 #2 {\_regoptsizes #1 ?#2 {} <*}
%          alias name           real font name
\fontalias crea-a-regular       {Creative Font}
\fontalias crea-a-bold          {Creative FontBold}
\fontalias crea-a-italic        {Creative olique}
\fontalias crea-a-bolditalic    {Creative Bold plus italic}
\fontalias crea-b-regular       {Creative Regular subfam}
\fontalias crea-b-bold          {Creative subfam bold}
\fontalias crea-b-italic        {Creative-subfam Oblique}
\fontalias crea-b-bolditalic    {Creative Bold subfam Oblique}
\endtt

Another example of font family with optical sizes is Antykwa Półtawskiego.
The optical sizes feature is deactivated by default and it is switched on by
`\osize` font modifier:

\printdoc f-poltawski.opm