summaryrefslogtreecommitdiff
path: root/tex/context/base/font-tra.mkiv
blob: 06b8613785d0b37c2376b44cbf8ab92902f3b459 (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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
%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 ADE \& \CONTEXT\ Development Team}]
%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   {showbodyfont}
%D
%D One can call for a rather simple overview of a bodyfont and the
%D relations between its alternative fonts.
%D
%D \showsetup{showbodyfont}
%D
%D The current bodyfont (here we omitted the argument) looks like:
%D
%D \showbodyfont
%D
%D The implementation is rather straightforward in using
%D \type{\halign}.

\fetchruntimecommand \showbodyfont  {\f!fontprefix\s!run}

%D \macros
%D   {showfontstrip, testminimalbaseline, showminimalbaseline}
%D
%D The next command can come in handy when combining
%D different fonts into a collection (typeface) and
%D determining optimal baseline distances.
%D
%D \showfontstrip \blank \showminimalbaseline

\fetchruntimecommand \showfontstrip       {\f!fontprefix\s!run}
\fetchruntimecommand \testminimalbaseline {\f!fontprefix\s!run}
\fetchruntimecommand \showminimalbaseline {\f!fontprefix\s!run}

%D \macros
%D   {showkerning}
%D
%D A goody is:
%D
%D \showkerning{Can you guess what kerning is?}

\fetchruntimecommand \showkerning {\f!fontprefix\s!run}

%D \macros
%D   {showbodyfontenvironment,showfont,showfontstyle,showligatures}
%D
%D The current bodyfontenvironment is:
%D
%D \showbodyfontenvironment
%D
%D This overview is generated using:
%D
%D \showsetup{showbodyfontenvironment}

\fetchruntimecommand \showbodyfontenvironment {\f!fontprefix\s!run}

%D
%D The following command generates a fontmap:
%D
%D \startbuffer
%D \showfont[SansBold at 12pt]
%D \stopbuffer
%D
%D \typebuffer
%D \getbuffer

\fetchruntimecommand \showfont           {\f!fontprefix\s!run}
\fetchruntimecommand \showfontstyle      {\f!fontprefix\s!run}
\fetchruntimecommand \showligature       {\f!fontprefix\s!run}
\fetchruntimecommand \showligatures      {\f!fontprefix\s!run}
\fetchruntimecommand \showcharratio      {\f!fontprefix\s!run}
\fetchruntimecommand \showfontparameters {\f!fontprefix\s!run}

\unexpanded\def\checkcharactersinfont  {\ctxcommand{checkcharactersinfont()}}
\unexpanded\def\removemissingcharacters{\ctxcommand{removemissingcharacters()}}
\unexpanded\def\showchardata         #1{\ctxcommand{showchardata("#1")}}
\unexpanded\def\showfontdata           {\ctxcommand{showfontparameters()}}

%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{\ctxcommand{doifelse(fonts.names.exists("#1"))}}

% experimental, maybe this becomes a module

\newbox\otfcollector

\unexpanded\def\startotfcollecting{\ctxlua{nodes.tracers.steppers.start()}}
\unexpanded\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#3% font char class
  {\removeunwantedspaces
   \hskip.5em plus .125em\relax
   \doif{#3}{mark}{\underbar}{U+\hexnumber{#2}}:\ruledhbox{\ctxlua{nodes.tracers.fontchar(#1,#2)}}%
   \hskip.5em plus .125em\relax}

\def\otfstepmessagecommand#1#2%
  {\begingroup
   \tttf\language\minusone
   \veryraggedright
   \forgetparindent
   \forgeteverypar
   \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,"otfstepcharcommand")}}

\def\showotfstepmessages#1%
  {\ctxlua{nodes.tracers.steppers.messages(#1,"otfstepmessagecommand",true)}}

\def\showotfstepfeatures
  {\ctxlua{nodes.tracers.steppers.features()}}

\def\showotfsteps
  {\begingroup
   \veryraggedright
   \forgetparindent
   \forgeteverypar
   \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}%
   \endgroup}

\unexpanded\def\startotfsample
  {\enabletrackers[*otf.sample]% beware, kind of global
   \startotfcollecting
   \begingroup
   \veryraggedright
   \forgetparindent
   \forgeteverypar}

\unexpanded\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
   \veryraggedright
   \forgetparindent
   \forgeteverypar
   \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