s-fonts-ligatures.mkiv /size: 6978 b    last modification: 2020-07-01 14:35
1%D \module
2%D   [      file=s-fonts-ligatures,
3%D        version=2014.12.14,
4%D          title=\CONTEXT\ Style File,
5%D       subtitle=Show Fonts Ligatures,
6%D         author=Hans Hagen,
7%D           date=\currentdate,
8%D      copyright={PRAGMA ADE \& \CONTEXT\ Development Team}]
9%C
10%C This module is part of the \CONTEXT\ macro||package and is
11%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
12%C details.
13
14% begin info
15%
16% title   : show some ligature building in fonts
17%
18% comment : we trace some ligatures that have rather different implementations in fontss
19% status  : experimental, used for luatex testing
20%
21% end info
22
23\definefontfeature
24  [otfligaturetest]
25  [analyze=off,
26   ccmp=yes, % brill uses that .. not really ligatures !
27  %clig=yes,
28   script=latn,
29   language=dflt]
30
31\hyphenation{xf-fi-a}
32\hyphenation{xff-i-b}
33\hyphenation{xffi-c}
34\hyphenation{xffid}
35
36\registerhyphenationexception[xf-fi-a]
37\registerhyphenationexception[xff-i-b]
38\registerhyphenationexception[xffi-c]
39\registerhyphenationexception[xffid]
40
41\starttexdefinition showotfligaturescaption #1
42    \bTD [align={flushleft,lohi},nx=3]
43        \nohyphens
44        \ttbf
45        #1
46    \eTD
47\stoptexdefinition
48
49\starttexdefinition showotfligatureslegend #1
50    \bTD [width=6em,align={flushleft,lohi}]
51        \nohyphens \ttxx original
52    \eTD
53    \bTD [width=6em,align={flushleft,lohi}]
54        \nohyphens \ttxx expanded
55    \eTD
56    \bTD [width=6em,align={flushleft,lohi}]
57        \nohyphens \ttxx traditional
58    \eTD
59\stoptexdefinition
60
61\starttexdefinition showotfligaturesline #1#2
62    \bTD[toffset=.5ex,frame=off]
63        \starthyphenation[#1]
64            \LigatureFont
65            \showfontkerns
66            \showdiscretionaries
67            \begstrut#2\endstrut
68            \par
69        \stophyphenation
70    \eTD
71\stoptexdefinition
72
73\def\showotfligaturescells{3}
74%def\showotfligaturesnx   {12}
75%def\showotfligatureswidth{18em}
76\def\showotfligaturesnx   {\the\numexpr  4*\showotfligaturescells}
77\def\showotfligatureswidth{\the\dimexpr6em*\showotfligaturescells}
78
79\starttexdefinition showotfligaturesbanner #1
80    \bTR[frame=off]
81        \bTD [nx=\showotfligaturesnx,xwidth=\showotfligatureswidth,align={middle,lohi},height=4ex]
82            \tttf #1
83        \eTD
84    \eTR
85\stoptexdefinition
86
87\starttexdefinition showotfligaturescaptions #1
88    \bTR[height=3ex,align={middle,lohi},bottomframe=off]
89        \processcommalist[#1]\showotfligaturescaption
90    \eTR
91    \bTR[height=3ex,align={middle,lohi},topframe=off]
92        \processcommalist[#1]\showotfligatureslegend
93    \eTR
94\stoptexdefinition
95
96\starttexdefinition showotfligatureslineset #1
97    \showotfligaturesline{original}   {#1}
98    \showotfligaturesline{expanded}   {#1}
99    \showotfligaturesline{traditional}{#1}
100\stoptexdefinition
101
102
103\starttexdefinition showotfligaturesparagraphset #1
104    \showotfligatureslineset {
105        \hsize         \zeropoint
106        \lefthyphenmin \plustwo
107        \righthyphenmin\plustwo
108        #1
109    }
110\stoptexdefinition
111
112\starttexdefinition showotfligaturesextremeset #1
113    \showotfligatureslineset {
114        \hsize         \zeropoint
115        \lefthyphenmin \plusone
116        \righthyphenmin\plusone
117        #1
118    }
119\stoptexdefinition
120
121\starttexdefinition showotfligatureslines #1
122    \bTR[height=4ex,bottomframe=off]
123        \processcommalist[#1]\showotfligatureslineset
124    \eTR
125\stoptexdefinition
126
127\starttexdefinition showotfligaturesparagraphs #1
128    \bTR[topframe=off]
129        \processcommalist[#1]\showotfligaturesparagraphset
130    \eTR
131\stoptexdefinition
132
133\starttexdefinition showotfligaturesextremes #1
134    \bTR[topframe=off]
135        \processcommalist[#1]\showotfligaturesextremeset
136    \eTR
137\stoptexdefinition
138
139\starttexdefinition showotfligaturesdefaults
140    \bTR
141        \bTD [nx=\showotfligaturesnx,xwidth=\showotfligatureswidth,align=middle,height=4ex,frame=off]
142            \start \LigatureFont fb  \stop \quad
143            \start \LigatureFont ff  \stop \quad
144            \start \LigatureFont fi  \stop \quad
145            \start \LigatureFont fk  \stop \quad
146            \start \LigatureFont fl  \stop \quad
147            \start \LigatureFont ft  \stop \quad
148            \start \LigatureFont ffb \stop \quad
149            \start \LigatureFont fff \stop \quad
150            \start \LigatureFont ffi \stop \quad
151            \start \LigatureFont ffl \stop \quad
152            \start \LigatureFont ffk \stop \quad
153            \start \LigatureFont fft \stop
154        \eTD
155    \eTR
156\stoptexdefinition
157
158\starttexdefinition showotfligaturesexample #1#2
159  % \ctxlua{document.currentdiscexpansion = fonts.getdiscexpansion()}%
160    \showotfligaturescaptions  {#1}
161    \showotfligatureslines     {#2}
162    \showotfligaturesparagraphs{#2}
163    \showotfligaturesextremes  {#2}
164  % \ctxlua{fonts.setdiscexpansion(document.currentdiscexpansion)}%
165\stoptexdefinition
166
167% todo: n -> and split in lua
168
169\starttexdefinition showotfligaturesexamples
170    \showotfligaturesexample
171        {leafing,baffling,efficient,shifffahrt}
172        {leafing,baffling,efficient,shifffahrt}
173    \showotfligaturesexample
174        {offbeat,effect,ef-fective,ef\-fective}
175        {offbeat,effect,ef-fective,ef\-fective}
176    \showotfligaturesexample
177        {xf+fi+a,xff+i+b,xffi+c,xffid}
178        {xffia,  xffib,  xffic, xffid}
179\stoptexdefinition
180
181\starttexdefinition showotfligatures [#1]
182    \begingroup
183        \getdummyparameters[font=Regular,features=default,#1]
184        \definefont[LigatureFont][\dummyparameter{font}*\dummyparameter{features},otfligaturetest ht 2ex]
185        \bTABLE[leftframe=off,rightframe=off]
186            \showotfligaturesbanner{\dummyparameter{font} * \dummyparameter{features}}
187            \showotfligaturesdefaults
188            \showotfligaturesexamples
189        \eTABLE
190    \endgroup
191\stoptexdefinition
192
193\continueifinputfile{s-fonts-ligatures.mkiv}
194
195\starttext
196
197    \definefontfeature[fonttest][default]  [mode=node,language=dflt,script=latn,ccmp=yes,liga=yes,kern=yes,mark=yes,mkmk=yes]
198    \definefontfeature[capstest][smallcaps][mode=node,language=dflt,script=latn,ccmp=yes,liga=yes,kern=yes,mark=yes,mkmk=yes]
199
200    \startTEXpage[offset=10pt] \showotfligatures[font=lmroman10-regular.otf,   features=fonttest] \stopTEXpage
201    \startTEXpage[offset=10pt] \showotfligatures[font=dejavu-serif.ttf,        features=fonttest] \stopTEXpage
202    \startTEXpage[offset=10pt] \showotfligatures[font=minionpro.otf,           features=fonttest] \stopTEXpage
203    \startTEXpage[offset=10pt] \showotfligatures[font=minionpro.otf,           features=capstest] \stopTEXpage
204    \startTEXpage[offset=10pt] \showotfligatures[font=brill.otf,               features=fonttest] \stopTEXpage
205    \startTEXpage[offset=10pt] \showotfligatures[font=gentiumplus-r.ttf,       features=fonttest] \stopTEXpage
206    \startTEXpage[offset=10pt] \showotfligatures[font=cambria,                 features=fonttest] \stopTEXpage
207    \startTEXpage[offset=10pt] \showotfligatures[font=ebgaramond12-regular.otf,features=fonttest] \stopTEXpage
208
209\stoptext
210