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
|
%D \module
%D [ file=font-tra,
%D version=2009.01.02, % or so
%D title=\CONTEXT\ Font Macros,
%D subtitle=Tracing,
%D author=Hans Hagen,
%D date=\currentdate,
%D copyright={PRAGMA / Hans Hagen \& Ton Otten}]
%C
%C This module is part of the \CONTEXT\ macro||package and is
%C therefore copyrighted by \PRAGMA. See mreadme.pdf for
%C details.
\unprotect
%D \macros
%D {doiffontpresentelse}
%D
%D \starttyping
%D \doiffontpresentelse{texnansi-lmr10}{YES}{NO}
%D \doiffontpresentelse{adam-lindsay-modern-serif}{YES}{NO}
%D \stoptyping
\def\doiffontpresentelse#1{\ctxlua{commands.doifelse(fonts.names.exists("#1"))}}
% experimental, maybe this becomes a module
\newbox\otfcollector
\def\startotfcollecting{\ctxlua{nodes.tracers.steppers.start()}}
\def\stopotfcollecting {\ctxlua{nodes.tracers.steppers.stop()}}
\def\resetotfcollecting{\ctxlua{nodes.tracers.steppers.reset()}}
% Rather experimental:
%
% \page \showotfcomposition{arabtype*arab-default at 48pt}{-1}{الضَّرَّ} \page
% \page \showotfcomposition{arabtype*arab-default at 48pt}{-1}{لِلّٰهِ} \page
\def\showotfstepglyphs#1%
{\ctxlua{nodes.tracers.steppers.glyphs(\number\otfcollector,#1)}%
\unhbox\otfcollector}
\def\otfstepcharcommand#1#2% font char
{\removeunwantedspaces
\hskip.5em plus .125em\relax
U+\hexnumber{#2}:\ruledhbox{\ctxlua{nodes.tracers.fontchar(#1,#2)}}%
\hskip.5em plus .125em\relax}
\def\otfstepmessagecommand#1#2%
{\begingroup
\tttf\language\minusone
\veryraggedright
\hangindent1em
\hangafter\plusone
\dontleavehmode\hbox{\detokenize{#1}}\removeunwantedspaces
\doifsomething{#2}{\break\detokenize{#2}}\endgraf
\endgroup
\blank}
\def\showotfstepchars#1%
{\ctxlua{nodes.tracers.steppers.codes(#1,\!!bs\detokenize{\otfstepcharcommand}\!!es)}}
\def\showotfstepmessages#1%
{\ctxlua{nodes.tracers.steppers.messages(#1,\!!bs\detokenize{\otfstepmessagecommand}\!!es,true)}}
\def\showotfstepfeatures
{\ctxlua{nodes.tracers.steppers.features()}}
\def\showotfsteps
{\dontleavehmode\bgroup\tttf \language\minusone features: \showotfstepfeatures\egroup
\blank
\dontleavehmode\bgroup\tttf result:\egroup
\blank
\startlinecorrection
\ruledhbox\bgroup\box\otfcompositionbox\egroup
\stoplinecorrection
\dorecurse{\ctxlua{nodes.tracers.steppers.nofsteps()}}
{\blank
\showotfstepmessages\recurselevel
\blank
\startlinecorrection
\dontleavehmode\bgroup\resetallattributes\pardir TLT\textdir TLT\relax\tttf\recurselevel: \showotfstepchars\recurselevel\egroup
\stoplinecorrection
\blank
\startlinecorrection
\ruledhbox % can be mode
\bgroup\resetallattributes\showotfstepglyphs\recurselevel\egroup % reset is new, we don't want additional processing
\stoplinecorrection
\blank}}
\def\startotfsample
{\enabletrackers[*otf.sample]% beware, kind of global
\startotfcollecting
\begingroup}
\def\stopotfsample
{\endgroup
\stopotfcollecting
\disabletrackers[*otf.sample]% beware, kind of global: otf.sample
\showotfsteps
\resetotfcollecting}
\newbox\otfcompositionbox
\def\showotfcomposition#1#2#3% {font*features at size}, rl=-1, text
{\begingroup
\setupcolors[\c!state=\v!start]% can be option
\startotfsample
\global\setbox\otfcompositionbox\hbox{\definedfont[#1]\ifnum#2<0 \textdir TRT\else\ifnum#2>0 \textdir TLT\fi\fi\relax#3}%
\stopotfsample
\endgroup}
\protect \endinput
|