font-tex.mkxl /size: 3356 b    last modification: 2021-10-28 13:51
1%D \module
2%D   [       file=font-tex,
3%D        version=2021.23.01,
4%D          title=\CONTEXT\ Font Macros,
5%D       subtitle=\TEX\ Glyphs,
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 / TeX Glyphs}
15
16\registerctxluafile{font-tex}{autosuffix}
17
18%D This mechanism turns boxes into glyphs. Of course this assumes that the
19%D backend code supports it. It's an experiment and we can do similar things
20%D with \METAPOST. The interface is not frozen and might change and evolve.
21
22%D \starttyping
23%D \starttext
24%D
25%D \startsetups box:demo:103
26%D     \externalfigure[t:/sources/cow-brown.pdf][height=12pt]
27%D \stopsetups
28%D
29%D \startsetups box:demo:104
30%D     \externalfigure[t:/sources/cow-black.pdf][height=10pt]
31%D \stopsetups
32%D
33%D \startsetups box:demo:105
34%D     \externalfigure[t:/sources/mill.png][height=12pt]
35%D \stopsetups
36%D
37%D \startsetups box:demo:106
38%D     \externalfigure[t:/sources/hacker.jpg][height=12pt]
39%D \stopsetups
40%D
41%D \registerboxglyph category {demo} unicode 103 \relax % rather low level for now
42%D \registerboxglyph category {demo} unicode 104 \relax % rather low level for now
43%D \registerboxglyph category {demo} unicode 105 \relax % rather low level for now
44%D \registerboxglyph category {demo} unicode 106 \relax % rather low level for now
45%D
46%D \definefontfeature[whatever][box=demo]
47%D
48%D \definedfont[Serif*whatever]
49%D
50%D % \enabletrackers[fonts.collecting]
51%D
52%D \startTEXpage%[offset=0pt]
53%D    %\hbox{g}%
54%D     \hbox{\char103}%
55%D     \hbox{\char104}%
56%D \stopTEXpage
57%D
58%D \startsetups box:demo:whatever
59%D     \startMPcode
60%D         picture p ; p := image (draw figure "t:/sources/hacker.jpg" ysized 10pt);
61%D         fill      boundingbox p enlarged .5pt randomized 2pt withcolor "darkgray" ;
62%D         clip p to boundingbox p enlarged -1pt randomized 2pt ;
63%D         draw p ;
64%D     \stopMPcode
65%D \stopsetups
66%D
67%D % in current font!
68%D
69%D \iffontchar\font\privatecharactercode{demo:whatever}\else
70%D     \setboxglyph {
71%D         category {demo}
72%D         name     {demo:whatever}
73%D         setups   {box:demo:whatever}
74%D     }%
75%D \fi
76%D
77%D \startTEXpage[offset=10pt]
78%D     \char\privatecharactercode{demo:whatever}%
79%D \stopTEXpage
80%D
81%D \startTEXpage%[offset=0pt]
82%D     \ruledhbox{\char103}
83%D     \ruledhbox{\char104}
84%D     \ruledhbox{\char105}
85%D     \ruledhbox{\char106}
86%D \stopTEXpage
87%D
88%D \dorecurse{1000}{
89%D     \char 103\relax \space
90%D     \char 104\relax \space
91%D     \char 105\relax \space
92%D     \char 106\relax \space
93%D }
94%D
95%D \page
96%D
97%D \setupalign[verytolerant,flushleft]
98%D
99%D \dorecurse{100}{
100%D     #1:
101%D     \glyph yoffset -2pt `i\relax
102%D     \glyph yoffset -3pt `j\relax\space
103%D }
104%D \stoptext
105%D \stoptyping
106
107\newbox\glyphbox
108
109% somehow makes the first \char disappear
110%
111% \permanent\protected\def\makeglyphbox#1%
112%   {\setbox\glyphbox\hbox{\directsetup{#1}}}
113%
114% so we group:
115
116\permanent\protected\def\makeglyphbox#1%
117  {\begingroup
118   \global\setbox\glyphbox\hbox{\directsetup{#1}}%
119   \finalizeobjectbox\glyphbox
120 % \writestatus{glyphbox}{#1 => (\the\wd\glyphbox,\the\ht\glyphbox,\the\dp\glyphbox)}%
121   \endgroup}
122