font-lib.mkvi /size: 6879 b    last modification: 2021-10-28 13:50
1%D \module
2%D   [       file=font-lib,
3%D        version=2011.01.13, % (copied fron font-ini)
4%D          title=\CONTEXT\ Font Macros,
5%D       subtitle=Libraries,
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\writestatus{loading}{ConTeXt Font Macros / Libraries}
15
16\unprotect
17
18\registerctxluafile{font-ini}{}
19\registerctxluafile{font-log}{}
20\registerctxluafile{font-con}{}
21\registerctxluafile{font-cft}{}
22\registerctxluafile{font-enc}{}
23\registerctxluafile{font-agl}{}         % if needed we can comment this and delay loading
24\registerctxluafile{font-cid}{}         % cid maps
25\registerctxluafile{font-map}{optimize}
26
27% helpers
28
29\registerctxluafile{font-otr}{optimize} % opentype fontloader
30\registerctxluafile{font-web}{}         % opentype fontloader
31\registerctxluafile{font-cff}{optimize} % quadratic outlines
32\registerctxluafile{font-ttf}{optimize} % cubic outlines
33\registerctxluafile{font-dsp}{optimize} % ... for this one
34\registerctxluafile{font-hsh}{}         % hashes used by context
35\registerctxluafile{font-vfc}{}
36\registerctxluafile{font-prv}{}         % needs hashes
37\registerctxluafile{font-nod}{optimize}
38\registerctxluafile{font-oti}{}         % otf initialization
39\registerctxluafile{font-ott}{}         % otf tables (first)
40\registerctxluafile{font-otl}{}
41\registerctxluafile{font-oto}{}
42\registerctxluafile{font-otj}{optimize}
43\registerctxluafile{font-oup}{}
44\registerctxluafile{font-ota}{}
45\registerctxluafile{font-ots}{optimize}
46\registerctxluafile{font-otd}{optimize}
47\registerctxluafile{font-otc}{}
48\registerctxluafile{font-oth}{}
49\registerctxluafile{font-osd}{}
50%registerctxluafile{font-osm}{}
51
52% \ifcase\directlua{tex.print(callback.list()["provide_charproc_data"] == false and 1 or 0)}\relax
53%     % this is the generic variant that will become luatex-fonts-ocl once we have
54%     % more recent versions of luatex 1.13/1.14 on the garden
55%     \registerctxluafile{font-ocl}{}
56% \else
57    \registerctxluafile{font-ocm}{}
58% \fi
59
60% we use otf code for type one
61
62\registerctxluafile{font-onr}{optimize}
63\registerctxluafile{font-one}{optimize}
64\registerctxluafile{font-afk}{}
65
66\registerctxluafile{font-txt}{}
67
68% tfm
69
70\registerctxluafile{font-tpk}{optimize}
71\registerctxluafile{font-tfm}{}
72
73% name database
74
75\registerctxluafile{font-syn}{}
76\registerctxluafile{font-trt}{}
77
78% shapes
79
80\registerctxluafile{font-shp}{}
81
82% so far
83
84\registerctxluafile{font-pat}{} % patchers
85
86\registerctxluafile{node-fnt}{} % here
87
88\registerctxluafile{font-mps}{} % outline fun
89
90\registerctxluafile{font-lua}{}
91
92\registerctxluafile{font-vir}{}
93\registerctxluafile{font-enh}{}
94
95\registerctxluafile{good-ini}{}
96\registerctxluafile{good-gen}{}
97\registerctxluafile{good-ctx}{}
98\registerctxluafile{good-mth}{}
99
100\registerctxluafile{font-def}{}
101\registerctxluafile{font-ctx}{} % after def as it overloads
102
103% extensions, order matters
104
105\registerctxluafile{font-imp-ligatures}{}
106\registerctxluafile{font-imp-tex}{}
107\registerctxluafile{font-imp-reorder}{}
108\registerctxluafile{font-imp-properties}{}
109\registerctxluafile{font-imp-unicode}{}
110\registerctxluafile{font-imp-math}{}
111\registerctxluafile{font-imp-notused}{}
112\registerctxluafile{font-imp-effects}{}
113\registerctxluafile{font-imp-quality}{}
114\registerctxluafile{font-imp-italics}{}
115\registerctxluafile{font-imp-dimensions}{}
116\registerctxluafile{font-imp-spacekerns}{}
117\registerctxluafile{font-imp-tweaks}{}
118\registerctxluafile{font-imp-combining}{}
119
120\doifelsefileexists{font-imp-scripts.lua} {
121    \registerctxluafile{font-imp-scripts}{}
122} {
123    % not yet, lmtx feature
124}
125
126\registerctxluafile{font-imp-tracing}{} % comes last!
127
128\registerctxluafile{font-fbk}{}
129
130\registerctxluafile{font-aux}{}
131
132\registerctxluafile{font-lig}{} % only for experiments so try to avoid it
133
134%D Some low level helpers
135%D
136%D \starttyping
137%D \def\TestLookup#specification%
138%D   {\dolookupfontbyspec{#specification}
139%D     pattern: #specification, found: \dolookupnoffound
140%D    \blank
141%D    \dorecurse {\dolookupnoffound} {%
142%D      \recurselevel:~\dolookupgetkeyofindex{fontname}{\recurselevel}\quad
143%D    }%
144%D    \blank}
145%D
146%D \TestLookup{familyname=helveticaneue}
147%D \TestLookup{familyname=helveticaneue,weight=bold}
148%D \TestLookup{familyname=helveticaneue,weight=bold,style=italic}
149%D \stoptyping
150
151% we can also move the lookups to the fonts.namespace (of commands)
152% one can also directly use the clf calls when speed is needed
153
154           \def\dolookupfontbyspec     #1{\clf_fontlookupinitialize{#1}}
155           \def\dolookupnoffound         {\clf_fontlookupnoffound}
156           \def\dolookupgetkeyofindex#1#2{\clf_fontlookupgetkeyofindex{#1}\numexpr#2\relax}
157           \def\dolookupgetkey         #1{\clf_fontlookupgetkey{#1}}
158           \def\cleanfontname          #1{\clf_cleanfontname{#1}}
159\unexpanded\def\setfontofid            #1{\clf_setfontofid\numexpr#1\relax}
160
161% this is an ugly hack needed for postponed inclusion stuff ... don't try
162% to understand this ... these are kind of old mkiv solutions
163
164\unexpanded\def\typethreefont#1{\setfontid#1\relax}
165\unexpanded\def\typethreechar#1{\char#1\hskip-\fontcharwd\font#1\relax}
166\unexpanded\def\typethreelast#1{\char#1\relax}
167\unexpanded\def\typethreecode#1{\pdfliteral direct {#1}}
168
169\newtoks\typethreetoks
170\let    \typethreemacro\empty
171
172\typethreetoks {%
173    \setbox\zerocount\hpack{\typethreemacro}%
174    \setbox\zerocount\hpack{\raise\dp\zerocount\box\zerocount}%
175}
176\protect \endinput
177
178% Some simple test with an upgraded data handling. Because in the
179% end most users will use lmtx we can sacrifice some performance
180% in mkiv unless I decide to ship different ots files. The gain
181% in lmtx is hard to determine but the fact that it runs about
182% as fast as luametatex looks quite ok, given the fact that the
183% backend has a significant performance hit. (We're talking of
184% two changes actually, also the state handling got changed which
185% has a bit more impact on lmtx.)
186%
187% \starttext \start
188%
189% Performance can be better in luatex when I decide to backport
190% but it is somewhat context (font) specific which contradicts
191% the fact that we don't want to add package specific features
192% to the engines (which in the end could hurt the other packages)
193% so that might never happen.
194%
195% latin modern (fastest time):
196%
197% old: luatex 2.979 | luametatex 3.198
198% new: luatex 3.399 | luametatex 3.198
199%
200% % \setupbodyfont[pagella] \smallcaps
201%
202% pagella (fastest time):
203%
204% old: luatex 5.098 | luametatex 5.104
205% new: luatex 6.178 | luametatex 4.975
206%
207% \testfeatureonce{1000}{\samplefile{tufte}\par}
208%
209% \page \elapsedtime \stop \stoptext
210%
211% In then end this upgrade was rejected and the experimental code
212% was thrashed (pending possible future lmtx specific variants of
213% font-*.lua).
214