ontarget-dk.tex /size: 3148 b    last modification: 2024-01-16 10:21
1% language=us runpath=texruns:manuals/ontarget
2
3\startcomponent ontarget-dk
4
5\environment ontarget-style
6
7\startchapter[title={A new unit: \type {dk}}]
8
9At the \CONTEXT\ 2021 meeting I mixed my \TEX\ talks with showing some of the
10(upcoming) \LUAMETATEX\ source code. One evening we had a extension party where a
11new unit was implemented, the \type {dk}. This event was triggered by a remark
12Hraban [Ramm] made on the participants list in advance of the meeting, where he
13pointed to a Wikipedia article from which we quote:
14
15\startquotation
16In issue 33, Mad published a partial table of the \quotation {Potrzebie System of
17Weights and Measures}, developed by 19|-|year|-|old Donald~E. Knuth, later a famed
18computer scientist. According to Knuth, the basis of this new revolutionary
19system is the potrzebie, which equals the thickness of Mad issue 26, or
202.2633484517438173216473 mm [\dots].
21\stopquotation
22
23So, as the result of that session, the source code now has this comment:
24
25\startquotation
26We support the Knuthian Potrzebie, cf.\ \typ
27{en.wikipedia.org/wiki/Potrzebie}, as the \type {dk} unit. It was added on
282021-09-22 exactly when we crossed the season during an evening session at the
2915\high {th} \CONTEXT\ meeting in Bassenge (Boirs) Belgium. It took a few
30iterations to find the best numerator and denominator, but Taco Hoekwater, Harald
31Koenig and Mikael Sundqvist figured it out in this interactive session. The error
32messages have been adapted accordingly and the scanner in the \LUA\ \type {tex}
33library also handles it. One \type {dk} is 6.43985pt. There is no need to make
34\METAPOST\ aware of this unit because there it is just a numeric multiplier in a
35macro package.
36\stopquotation
37
38When compared to the already present units the \type {dk} nicely fills a gap:
39
40\def\TheUnit#1{
41    \NC \type {#1}
42    \NC \withoutpt\dimexpr1#1\relax
43    \NC \number\dimexpr1#1\relax
44    \NC \vrule width 1#1 height 1.5ex depth .5ex\relax
45    \NC \NR
46}
47
48\starttabulate[|c|cg{.}|r|l|]
49    \BC unit \BC points \BC scaled \BC visual \NC \NR
50    \TheUnit{sp}
51    \TheUnit{pt}
52    \TheUnit{bp}
53    \TheUnit{dd}
54    \TheUnit{mm}
55    \TheUnit{dk}
56    \TheUnit{pc}
57    \TheUnit{cc}
58    \TheUnit{cm}
59    \TheUnit{in}
60
61   %\TheUnit{em}
62   %\TheUnit{ex}
63   %\TheUnit{mu}
64   %\TheUnit{px}
65\stoptabulate
66
67Deep down, the unit scanner uses a numerator and denominator in order
68to map the given value onto the internally used scaled points, so the
69relevant snippet of \CCODE\ is:
70
71\starttyping
72*num   = 49838; // 152940;
73*denom =  7739; //  23749;
74return normal_unit_scanned;
75\stoptyping
76
77The impact on performance of scanning an additional unit can be neglected because
78the scanning code is a bit different from the code in \LUATEX\ and (probably the)
79other engines anyway.
80
81Under consideration are a few extra units in the \type {relative_unit_scanned}
82category that we see in \CSS: \type {vw} (relative to the \type {\hsize}), \type
83{vh} (relative to the \type {\vsize}), maybe a percentage (but of what) and \type
84{ch} (width of the current zero digit character). As usual with \TEX ies,
85once it's there it will be (ab)used.
86
87\stopchapter
88
89\stopcomponent
90
91