| 1 |
%% This file is public domain. |
| 2 |
%% Originally written 1990, Alan Hoenig. |
| 3 |
%% Notice added by Clea F. Rees 2010/12/13 following correspondence between Alan Hoenig and Karl Berry. |
| 4 |
|
| 5 |
% This is DTITLE.MF, adapted from Knuths title.mf (Jan 8, 1990). |
| 6 |
% This makes a short font (caps only) |
| 7 |
|
| 8 |
% This file also contains special macros universally needed in the durer font |
| 9 |
% but not in CM.BAS. |
| 10 |
|
| 11 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 12 |
%% MACRO SECTION %%%%%%%%%%%%%%%%%%%%%%%%%% |
| 13 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 14 |
def formal=not informal enddef; |
| 15 |
|
| 16 |
vardef antiserif(suffix $,$$,@)(expr darkness, jut) suffix modifier= |
| 17 |
% erases a serif-like region at |z_$| from |z_{$$}| |
| 18 |
pickup crisp.nib; pair downward; downward=z$-z$$; |
| 19 |
y@2=jut; x@1=lft x$l+jut; top y@1=bot y$; |
| 20 |
z@2-penoffset downward of currentpen= |
| 21 |
z$l+penoffset downward of pen_[tiny.nib]+whatever*downward; |
| 22 |
erase filldraw z@2{downward}...darkness[(x@2,y@1), .5[z@2,z@1]]{z@1-z@2} |
| 23 |
...{right}z@1--(x@1,y@1-eps)--origin--(x@2-eps,y@2)--z@2&cycle; |
| 24 |
labels(@1, @2); enddef; |
| 25 |
|
| 26 |
|
| 27 |
let cm_arm=arm; |
| 28 |
|
| 29 |
vardef arm(suffix $,$$,@)(expr darkness, armjut) = % arm from |z$| to |z$$| |
| 30 |
numeric vjut_; vjut_= abs(bot y$l-bot y$$); |
| 31 |
x@0=good.x(x$$r-armjut); y@0=y$r; |
| 32 |
if serifs: y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0); |
| 33 |
if x$$>=x$: x@2=x@1 - vjut_; else: x@2=x@1+vjut_; fi y@2=y$l; |
| 34 |
filldraw z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l]]{z@2-z$$l}... |
| 35 |
z@2if x$$>=x$: {left} else: {right} fi |
| 36 |
---z$l--z$r--z@0--z$$r..cycle; % arm and beak |
| 37 |
else: filldraw z$l--z$r--z@0--z$$r--cycle; fi % sans-serif arm |
| 38 |
penlabels(@0,@1,@2); enddef; |
| 39 |
|
| 40 |
vardef foot(suffix $, $$, @)(expr darkness, armjut) = % curved beak on E and L |
| 41 |
numeric vjut_; vjut_= abs(bot y$-bot y$$); |
| 42 |
x@0=good.x(x$$r-armjut); y@0=y$r; |
| 43 |
if x@0>w-.5u: x@0:=w-.5u; fi |
| 44 |
if serifs: y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0); |
| 45 |
x@2=x@1-vjut_; y@2=y$l; |
| 46 |
filldraw z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l] ]...z@2 |
| 47 |
[email protected]..{up}z$$r..cycle; % arm and beak |
| 48 |
else: filldraw z$l--z$r--(x$$r,y$r)--(x$$r,y$l)--cycle; fi |
| 49 |
penlabels(@0,@1,@2); enddef; |
| 50 |
|
| 51 |
vardef flourish(suffix from, at, to, @) % flourish for top of `A' |
| 52 |
(expr darkness)= |
| 53 |
pickup pencircle scaled 0pt; % use this after all serifs have been drawn |
| 54 |
pair downward; pair upward; |
| 55 |
upward=z.at.l-z.from.l; downward=z.to.r-z.at.r; |
| 56 |
top y@1=top y.at; x@1=.5[x.from,x.at]; |
| 57 |
% leftmost point of flourish |
| 58 |
numeric alpha[]; alpha1=angle(upward); |
| 59 |
y@2=vround(top y.at-bracket/sind alpha1 ); lft z@2=whatever[z.at.l,z.from.l]; |
| 60 |
% |z@2| lies on the `from' limb and marks the beginning of the flourish |
| 61 |
x@1'=x@1; y@1'[email protected](tiny,thin); % point to give end of flourish some thickness |
| 62 |
top y@3=y.at; z@3=whatever[z@2,z.at.l]; % |z@3| is like Knuth's `corner' point |
| 63 |
filldraw z@2{upward}...darkness[.5[z@1',z@2],z@3]{z@1'-z@2} |
| 64 |
...z@1'{left}..{right}z@1--lft [email protected]; |
| 65 |
labels(@1,@2,@3); enddef; |
| 66 |
|
| 67 |
vardef pulled_super_arc.l(suffix $, $$)(expr darkness)= |
| 68 |
pair corner; |
| 69 |
if y$=y$r: corner=(x$l, y$$l); |
| 70 |
else: corner=(x$$l,y$l); fi |
| 71 |
z$l{corner-z$l}...(darkness)[corner, .5[z$l, z$$l]]{z$$l-z$l} |
| 72 |
...{z$$l-corner}z$$l enddef; |
| 73 |
|
| 74 |
vardef pulled_super_arc.r(suffix $, $$)(expr darkness)= |
| 75 |
pair corner; |
| 76 |
if y$=y$r: corner=(x$r,y$$r); |
| 77 |
else: corner=(x$$r, y$r); fi |
| 78 |
z$r{corner-z$r}...(darkness)[corner, .5[z$r, z$$r]]{z$$r-z$r} |
| 79 |
...z$$r{z$$r-corner} enddef; |
| 80 |
|
| 81 |
vardef pulled_arc@#(suffix $, $$)= |
| 82 |
pulled_super_arc@#($,$$)(eta) enddef; |
| 83 |
|
| 84 |
let cm_font_setup=font_setup; % Knuth's original font_setup |
| 85 |
|
| 86 |
def slim_font_setup = % trimmed font_setup for use with Durer caps only |
| 87 |
if monospace: let adjust_fit=mono_adjust_fit; |
| 88 |
def mfudged=fudged enddef; |
| 89 |
mono_charic#:=body_height#*slant; |
| 90 |
if mono_charic#<0: mono_charic#:=0; fi |
| 91 |
mono_charwd#:=9u#; define_whole_pixels(mono_charwd); |
| 92 |
else: let adjust_fit=normal_adjust_fit; |
| 93 |
def mfudged= enddef; fi |
| 94 |
define_pixels(u,width_adj,serif_fit,cap_serif_fit,jut,cap_jut,bar_height, |
| 95 |
dish,bracket,beak_jut,apex_o,apex_corr); |
| 96 |
define_whole_pixels(letter_fit,fine,crisp,tiny); |
| 97 |
define_whole_vertical_pixels(body_height,asc_height, |
| 98 |
cap_height,x_height,comma_depth,desc_depth); |
| 99 |
define_whole_blacker_pixels(hair,stem,cap_stem); |
| 100 |
define_whole_vertical_blacker_pixels(vair,dslab,slab); |
| 101 |
if slab<eps: slab:=eps fi; |
| 102 |
define_corrected_pixels(o); |
| 103 |
forsuffixes $=hair,stem,cap_stem: |
| 104 |
fudged$.#:=fudge*$.#; fudged$:=hround(fudged$.#*hppp+blacker); |
| 105 |
forever: exitif fudged$>.9fudge*$; fudged$:=fudged$+1; endfor endfor |
| 106 |
rule_thickness:=ceiling(rule_thickness#*hppp); |
| 107 |
heavy_rule_thickness:=ceiling(3rule_thickness#*hppp); |
| 108 |
oo:=vround(.5o#*hppp*o_correction)+eps; |
| 109 |
apex_oo:=vround(.5apex_o#*hppp*o_correction)+eps; |
| 110 |
lowres_fix(stem) 1.3; |
| 111 |
ess:=(ess#/stem#)*stem; cap_ess:=(cap_ess#/cap_stem#)*cap_stem; |
| 112 |
dw:=(curve#-stem#)*hppp; bold:=curve#*hppp+blacker; |
| 113 |
dh#:=.6designsize; |
| 114 |
more_super:=max(superness,sqrt .77superness); |
| 115 |
hein_super:=max(superness,sqrt .81225258superness); % that's $2^{-.3}$ |
| 116 |
clear_pen_memory; |
| 117 |
if fine=0: fine:=1; fi |
| 118 |
forsuffixes $=fine,crisp,tiny: |
| 119 |
%%% fine $ %%%% temporary formatting convention for MFT |
| 120 |
if $>fudged.hair: $:=fudged.hair; fi |
| 121 |
$.breadth:=$; |
| 122 |
pickup if $=0: nullpen else: pencircle scaled $; $:=$-eps fi; |
| 123 |
$.nib:=savepen; breadth_[$.nib]:=$; |
| 124 |
forsuffixes $$=lft,rt,top,bot: shiftdef($.$$,$$ 0); endfor endfor |
| 125 |
%%% @ $ %%%% restore ordinary formatting for $ |
| 126 |
min_Vround:=max(fine.breadth,crisp.breadth,tiny.breadth); |
| 127 |
if min_Vround<vround min_Vround: min_Vround:=vround min_Vround; fi |
| 128 |
pickup pencircle scaled rule_thickness; rule.nib:=savepen; |
| 129 |
currenttransform:=identity slanted slant |
| 130 |
yscaled aspect_ratio scaled granularity; |
| 131 |
if currenttransform=identity: let t_=relax |
| 132 |
else: def t_ = transformed currenttransform enddef fi; |
| 133 |
numeric paren_depth#; .5[body_height#,-paren_depth#]=math_axis#; |
| 134 |
numeric asc_depth#; .5[asc_height#,-asc_depth#]=math_axis#; |
| 135 |
body_depth:=desc_depth+body_height-asc_height; |
| 136 |
shrink_fit:=1+hround(2letter_fit#*hppp)-2letter_fit; |
| 137 |
if not string mode: if mode<=smoke: shrink_fit:=0; fi fi |
| 138 |
enddef; |
| 139 |
|
| 140 |
def durer_font_setup= % contains special stuff for Durer fonts |
| 141 |
define_pixels(side,thick,thin); |
| 142 |
if not known dslab#: dslab=eps; fi |
| 143 |
enddef; |
| 144 |
|
| 145 |
vardef T_flourish(suffix at,from,aux)(expr top_dark, bot_dark)= |
| 146 |
pickup tiny.nib; pair xeps_,yeps_; yeps_=(0,eps); |
| 147 |
numeric stroke_angle_; stroke_angle_=angle(z.at.r-z.at.l); |
| 148 |
numeric slab'; slab'=.6slab; |
| 149 |
pos.at'(alpha*thin+alpha*cap_jut,stroke_angle_); z.at'=z.at; |
| 150 |
if x.at<x.from: xeps_=(eps,0);% left flourish |
| 151 |
rt x.aux2-lft x.at'r=alpha*slab'; |
| 152 |
x.aux1=x.at.r+bracket+slab'; |
| 153 |
else: xeps_=(-eps,0); % right flourish |
| 154 |
rt x.at'r-lft x.aux2=alpha*slab'; |
| 155 |
x.aux1=x.at.r-bracket-slab'; fi |
| 156 |
y.aux1=y.at.r; y.aux4=y.at.l; z.aux1-z.aux4=whatever*(z.at.r-z.at.l); |
| 157 |
y.aux2=y.at'r; y.aux3=y.at'l; z.aux2-z.aux3=whatever*(z.at.r-z.at.l); |
| 158 |
if top_dark>=0: z.aux0 =whatever[z.at.r,z.aux1]=whatever[z.aux2,z.aux3]; |
| 159 |
filldraw z.aux1{z.at.r-z.aux1}.. |
| 160 |
top_dark[z.aux0 ,.5[z.aux1,z.aux2]].. |
| 161 |
if not monospace:{z.at'r-z.at}z.aux2-- |
| 162 |
else: {z.at'r-z.at}(z.at'r+xeps_).. fi |
| 163 |
z.at'r--2/3[z.at.r,z.at.l]--2/3[z.aux1,z.aux4]--cycle; fi |
| 164 |
if bot_dark>=0: z.aux0'=whatever[z.at.l,z.aux4]=whatever[z.aux2,z.aux3]; |
| 165 |
filldraw z.aux4{z.at.l-z.aux4}.. |
| 166 |
bot_dark[z.aux0',.5[z.aux4,z.aux3]].. |
| 167 |
if not monospace:{z.at'l-z.at}z.aux3-- |
| 168 |
else: {z.at'l-z.at}(z.at'l+xeps_).. fi |
| 169 |
z.at'l--2/3[z.at.l,z.at.r]--2/3[z.aux4,z.aux1]--cycle; fi |
| 170 |
penlabels(aux1, aux2,aux3,aux4); |
| 171 |
enddef; |
| 172 |
|
| 173 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 174 |
%% END OF MACROS %%%%%%%%%%%%%%%%%%%%%%%%%% |
| 175 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 176 |
|
| 177 |
font_coding_scheme:="ASCII caps and digits"; |
| 178 |
|
| 179 |
mode_setup; |
| 180 |
|
| 181 |
durer_font_setup; |
| 182 |
if whole_font: font_setup; %slab:=eps; |
| 183 |
define_whole_vertical_blacker_pixels(dslab,slab); |
| 184 |
else: slim_font_setup; fi |
| 185 |
|
| 186 |
if informal: input dromani; % Durer upper case---informal style |
| 187 |
else: input dromanu; fi % Durer upper case (majuscules) |
| 188 |
|
| 189 |
if whole_font: |
| 190 |
input dromanl; |
| 191 |
input dromand; |
| 192 |
fi |
| 193 |
|
| 194 |
font_slant slant; font_x_height x_height#; |
| 195 |
if monospace: font_normal_space 9u#; % no stretching or shrinking |
| 196 |
font_quad 18u#; |
| 197 |
font_extra_space 9u#; |
| 198 |
else: font_normal_space 6u#+2letter_fit#; |
| 199 |
font_normal_stretch 3u#; font_normal_shrink 2u#; |
| 200 |
font_quad 18u#+4letter_fit#; |
| 201 |
font_extra_space 2u#; |
| 202 |
k#:=-.5u#; kk#:=-1.5u#; kkk#:=-2u#; % three degrees of kerning |
| 203 |
ligtable "P": "T": "Y": "A" kern kk#; |
| 204 |
ligtable "F": "V": "W": "A" kern if serifs: kkk# else: kk#fi, |
| 205 |
"K": "X": "O" kern k#, "C" kern k#, "G" kern k#, "Q" kern k#; |
| 206 |
ligtable "O": "D": "X" kern k#, "W" kern k#, "A" kern k#, |
| 207 |
"V" kern k#, "Y" kern k#; |
| 208 |
ligtable "A": if serifs: "R": fi |
| 209 |
"C" kern k#, "O" kern k#, "G" kern k#, "U" kern k#, "Q" kern k#, |
| 210 |
"L": "T" kern kk#, "Y" kern kkk#, "V" kern kk#, "W" kern kkk#; |
| 211 |
ligtable "I": "I" kern -k#; fi % Richard III |
| 212 |
|
| 213 |
bye. |
| 214 |
|
| 215 |
ligtable "k": if serifs: "v": "a" kern -u#, fi "w": "e" kern k#, |
| 216 |
"a" kern k#, "o" kern k#, "c" kern k#; |
| 217 |
ligtable "P": |
| 218 |
"y": "o" kern k#, "e" kern k#, "a" kern k#, "." kern kk#, "," kern kk#; |
| 219 |
ligtable "F": "V": "W": if serifs: "o" kern kk#, "e" kern kk#, "u" kern kk#, |
| 220 |
"r" kern kk#, "a" kern kk#, "A" kern kkk#, |
| 221 |
else: "o" kern k#, "e" kern k#, "u" kern k#, |
| 222 |
"r" kern k#, "a" kern k#, "A" kern kk#; fi |
| 223 |
ligtable "T": "y" kern if serifs: k# else: kk# fi, |
| 224 |
"Y": "e" kern kk#, "o" kern kk#, |
| 225 |
"r" kern kk#, "a" kern kk#, "A" kern kk#, "u" kern kk#; |
| 226 |
if serifs: ligtable "h": "m": "n": |
| 227 |
"t" kern k#, "u" kern k#, "b" kern k#, "y" kern k#, "v" kern k#, "w" kern k#; |
| 228 |
ligtable "c": "h" kern k#, "k" kern k#; fi |
| 229 |
ligtable "o": "b": "p": "e" kern -k#, "o" kern -k#, "x" kern k#, |
| 230 |
"d" kern -k#, "c" kern -k#, "q" kern -k#, |
| 231 |
"a": if serifs: "v" kern k#, "j" kern u#, else: "r" kern k#, fi |
| 232 |
"t": "y" kern k#, |
| 233 |
"u": "w" kern k#; |
| 234 |
ligtable "g": "j" kern -k#; % logjam |
| 235 |
|
| 236 |
bye. |
| 237 |
|
| 238 |
|