summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/context/base/mkxl/font-tex.mkxl
blob: ae936be3190bbd9e8df99c971dc73fb610ce1bf0 (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
%D \module
%D   [       file=font-tex,
%D        version=2021.23.01,
%D          title=\CONTEXT\ Font Macros,
%D       subtitle=\TEX\ Glyphs,
%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.

\writestatus{loading}{ConTeXt Font Macros / TeX Glyphs}

\registerctxluafile{font-tex}{autosuffix}

%D This mechanism turns boxes into glyphs. Of course this assumes that the
%D backend code supports it. It's an experiment and we can do similar things
%D with \METAPOST. The interface is not frozen and might change and evolve.

%D \starttyping
%D \starttext
%D
%D \startsetups box:demo:103
%D     \externalfigure[t:/sources/cow-brown.pdf][height=12pt]
%D \stopsetups
%D
%D \startsetups box:demo:104
%D     \externalfigure[t:/sources/cow-black.pdf][height=10pt]
%D \stopsetups
%D
%D \startsetups box:demo:105
%D     \externalfigure[t:/sources/mill.png][height=12pt]
%D \stopsetups
%D
%D \startsetups box:demo:106
%D     \externalfigure[t:/sources/hacker.jpg][height=12pt]
%D \stopsetups
%D
%D \registerboxglyph category {demo} unicode 103 \relax % rather low level for now
%D \registerboxglyph category {demo} unicode 104 \relax % rather low level for now
%D \registerboxglyph category {demo} unicode 105 \relax % rather low level for now
%D \registerboxglyph category {demo} unicode 106 \relax % rather low level for now
%D
%D \definefontfeature[whatever][box=demo]
%D
%D \definedfont[Serif*whatever]
%D
%D % \enabletrackers[fonts.collecting]
%D
%D \startTEXpage%[offset=0pt]
%D    %\hbox{g}%
%D     \hbox{\char103}%
%D     \hbox{\char104}%
%D \stopTEXpage
%D
%D \startsetups box:demo:whatever
%D     \startMPcode
%D         picture p ; p := image (draw figure "t:/sources/hacker.jpg" ysized 10pt);
%D         fill      boundingbox p enlarged .5pt randomized 2pt withcolor "darkgray" ;
%D         clip p to boundingbox p enlarged -1pt randomized 2pt ;
%D         draw p ;
%D     \stopMPcode
%D \stopsetups
%D
%D % in current font!
%D
%D \iffontchar\font\privatecharactercode{demo:whatever}\else
%D     \setboxglyph {
%D         category {demo}
%D         name     {demo:whatever}
%D         setups   {box:demo:whatever}
%D     }%
%D \fi
%D
%D \startTEXpage[offset=10pt]
%D     \char\privatecharactercode{demo:whatever}%
%D \stopTEXpage
%D
%D \startTEXpage%[offset=0pt]
%D     \ruledhbox{\char103}
%D     \ruledhbox{\char104}
%D     \ruledhbox{\char105}
%D     \ruledhbox{\char106}
%D \stopTEXpage
%D
%D \dorecurse{1000}{
%D     \char 103\relax \space
%D     \char 104\relax \space
%D     \char 105\relax \space
%D     \char 106\relax \space
%D }
%D
%D \page
%D
%D \setupalign[verytolerant,flushleft]
%D
%D \dorecurse{100}{
%D     #1:
%D     \glyph yoffset -2pt `i\relax
%D     \glyph yoffset -3pt `j\relax\space
%D }
%D \stoptext
%D \stoptyping

\newbox\glyphbox

% somehow makes the first \char disappear
%
% \permanent\protected\def\makeglyphbox#1%
%   {\setbox\glyphbox\hbox{\directsetup{#1}}}
%
% so we group:

\permanent\protected\def\makeglyphbox#1%
  {\begingroup
   \global\setbox\glyphbox\hbox{\directsetup{#1}}%
   \finalizeobjectbox\glyphbox
 % \writestatus{glyphbox}{#1 => (\the\wd\glyphbox,\the\ht\glyphbox,\the\dp\glyphbox)}%
   \endgroup}