summaryrefslogtreecommitdiff
path: root/tex/context/base/core-fnt.mkiv
blob: 980f1a85cd842f7d58faeff39ac57c9f1f720df3 (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
%D \module
%D   [       file=core-fnt,
%D        version=1995.10.10,
%D          title=\CONTEXT\ Core Macros,
%D       subtitle=Fonts,
%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 Core Macros / Fonts}

\unprotect

%D \macros
%D   {compound}
%D
%D We will overload the already active \type {|} so we have
%D to save its meaning in order to be able to use this handy
%D macro.
%D
%D \starttyping
%D so test\compound{}test can be used instead of test||test
%D \stoptyping

\bgroup \catcode\barasciicode\activecatcode \gdef\compound#1{|#1|} \egroup

%D Here we hook some code into the clean up mechanism needed
%D for verbatim data.

\appendtoks
    \disablecompoundcharacters
    \disablediscretionaries
\to \everycleanupfeatures

%D The following code will me mkiv'd when needed. It's rather easy to
%D extend the kerner with glue.

%D \macros
%D   {stretched}
%D
%D Stretching characters in a word is a sort of typographical
%D murder. Nevertheless we support this manipulation for use in
%D for instance titles.
%D
%D \starttyping
%D \hbox to 5cm{\stretched{murder}}
%D \stoptyping
%D
%D \typebuffer
%D
%D or
%D
%D \startexample
%D \getbuffer
%D \stopexample
%D
%D \showsetup{stretched}

\unexpanded\def\stretched#1%
  {\ifvmode\hbox to \hsize\else\ifinner\else\hbox\fi\fi
   \bgroup\processtokens\relax\hss\relax{\hss\hss}{#1}\egroup}

%D \startbuffer
%D \stretched{Unknown Box}
%D \hbox to .5\hsize{\stretched{A Horizontal Box}}
%D \vbox to 2cm{\stretched{A Vertical Box}}
%D \hbox to 3cm{\stretched{sp{\'e}c{\`\i}{\"a}l}}
%D \stopbuffer
%D
%D \getbuffer
%D
%D The first line of this macros takes care of boxing. Normally
%D one will use an \type{\hbox} specification. The last line
%D shows how special characters should be passed.
%D
%D \typebuffer

%D \macros
%D   {stretchednormalcase, stretcheduppercase, stretchedlowercase}
%D
%D A convenient alternative is:
%D
%D \starttyping
%D \stretcheduppercase{Is this what you like?}
%D \stoptyping
%D
%D \typebuffer
%D
%D this one uses fixed skips and kerns.
%D
%D \startexample
%D \getbuffer
%D \stopexample
%D
%D The default skip can be set with:

%D Given the following settings, the space is 1em by default:

%D OBSOLETE:

\def\stretchedspacefactor{4}
\def\stretchedspaceamount{.25em}
\def\stretchedbreaktokens{.@/}

\unexpanded\def\stretchednormalcase
  {\stretchedsomecase\firstofoneargument}

\unexpanded\def\stretcheduppercase
  {\stretchedsomecase{\the\everyuppercase\uppercase}}

\unexpanded\def\stretchedlowercase
  {\stretchedsomecase{\the\everylowercase\lowercase}}

\def\stretchedsomecase#1#2%
  {\bgroup
   #1{\def\textstring{#2}}%
   \ifdim\stretchedspaceamount=\zeropoint
     \textstring
   \else
     \def\textkern##1%
       {% beware: ##1 may not be \box\somebox -)
        \determinemidwordbreak{##1}{\stretchedbreaktokens}%
        \kern\stretchedspaceamount##1\domidwordbreak}%
     \def\textskip
       {\scratchdimen\stretchedspaceamount
        \hskip\stretchedspacefactor\scratchdimen}%
     \@EA\processtokens\@EA\relax\@EA\textkern\@EA\relax\@EA\textskip\@EA{\textstring}%
   \fi
   \egroup}

%D An auxiliary macro, see for usage \type {\stretcheduppercase}.

\let\domidwordbreak\relax

\def\setmidwordbreaktoken#1%
  {\sfcode`#1=5000\relax}

\def\determinemidwordbreak#1#2%
  {\edef\midwordbreaktokens{#2}%
   \ifx\midwordbreaktokens\empty
     \global\let\domidwordbreak\relax
   \else
     \setbox\scratchbox\hbox
       {\expandafter\handletokens\midwordbreaktokens\with\setmidwordbreaktoken
        a\space \!!dimena\lastskip
        #1\space\!!dimenb\lastskip \relax % needed
        \ifdim\!!dimena=\!!dimenb
          \globallet\domidwordbreak\relax
        \else
          \globallet\domidwordbreak\allowbreak
        \fi}%
   \fi}

\protect \endinput