1
2
3
4
5
6
7
8
9
10
11
12
13
14\writestatus{loading}{ConTeXt Spacing Macros Profiling}
15
16
17
18
19
20
21
22\unprotect
23
24\registerctxluafile{spacprf}{}
25
26\definesystemattribute[profilemethod][public]
27
28\installcorenamespace {profile}
29\installcorenamespace {profiles}
30
31\installcommandhandler \??profile {profile} \??profile
32
33\setupprofile
34 [\c!height=\strutht,
35 \c!depth=\strutdp,
36 \c!distance=\normallineskip,
37 \c!lines=\zerocount,
38 \c!factor=\plusone]
39
40\defineprofile
41 [\v!strict]
42 [\c!method=\v!strict]
43
44\defineprofile
45 [\v!fixed]
46 [\c!method=\v!fixed]
47
48\defineprofile
49 [\v!none]
50 [\c!method=\v!none,
51 \c!height=\zeropoint,
52 \c!depth=\zeropoint,
53 \c!distance=\zeropoint,
54 \c!factor=\plusone]
55
56\defineprofile[halffixed] [\v!fixed][\c!factor=\plustwo]
57\defineprofile[quarterfixed][\v!fixed][\c!factor=\plusfour]
58\defineprofile[eightsfixed] [\v!fixed][\c!factor=\pluseight]
59
60\unexpanded\def\setprofile[#profile]
61 {\edef\currentprofile{#profile}
62 \clf_setprofile
63 name {\currentprofile}
64 height \dimexpr\profileparameter\c!height\relax
65 depth \dimexpr\profileparameter\c!depth\relax
66 distance \dimexpr\profileparameter\c!distance\relax
67 factor \numexpr\profileparameter\c!factor\relax
68 lines \numexpr\profileparameter\c!lines\relax
69 method {\profileparameter\c!method}
70 \relax}
71
72\unexpanded\def\resetprofile
73 {\c_attr_profilemethod\attributeunsetvalue}
74
75\unexpanded\def\useprofileparameter#getparameter
76 {\edef\m_spac_profile_asked{#getparameter\c!profile}
77 \ifx\m_spac_profile_asked\empty
78 \resetprofile
79 \else
80 \setprofile[\m_spac_profile_asked]
81 \fi}
82
83\unexpanded\def\profiledbox
84 {\vbox\bgroup
85 \dodoubleempty\spac_profiling_box}
86
87\def\spac_profiling_box[#profile][#settings]
88 {\ifsecondargument
89 \edef\currentprofile{#profile}
90 \setupcurrentprofile[#settings]
91 \else
92 \doifassignmentelse{#profile}
93 {\let\currentprofile\v!none
94 \setupcurrentprofile[#profile]}
95 {\edef\currentprofile{#profile}}
96 \fi
97 \dowithnextbox
98 {\profilegivenbox\currentprofile\nextbox
99 \unvbox\nextbox
100 \egroup}
101 \vbox}
102
103\unexpanded\def\profilegivenbox#profile#box
104 {\begingroup
105 \edef\currentprofile{#profile}
106 \clf_profilebox
107 box \numexpr#box\relax
108 height \dimexpr\profileparameter\c!height\relax
109 depth \dimexpr\profileparameter\c!depth\relax
110 distance \dimexpr\profileparameter\c!distance\relax
111 factor \numexpr\profileparameter\c!factor\relax
112 lines \numexpr\profileparameter\c!lines\relax
113 method {\profileparameter\c!method}
114 \relax
115 \endgroup}
116
117\protect \endinput
118 |