%%
%% This is file `cpctitle.mf',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% pacioli.dtx  (with options: `mfd')
%% 
%%  Copyright 1999 Peter R. Wilson
%% 
%%  This program is provided under the terms of the
%%  LaTeX Project Public License distributed from CTAN
%%  archives in directory macros/latex/base/lppl.txt.
%% 
%% Author: Peter Wilson (CUA and NIST)
%%         now at: peter.r.wilson@boeing.com
%% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  MACRO SECTION %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
def makebox(text rule) =
  for y=0,half_height,cap_height,body_height,x_height,-desc_depth,-body_depth:
    rule((l,y)t_,(r,y)t_); endfor  % horizontals
  for x=l,r: rule((x,-body_depth)t_,(x,body_height)t_); endfor % verticals
  for x=u*(1+floor(1/u)) step u until r-1:
    rule((x,-body_depth)t_,(x,body_height)t_); endfor         % more verticals
  if charic<>0:
    rule((r+charic*pt,h.o_),(r+charic*pt,.5h.o_)); fi  % italic correction
enddef;


def proofpcbb(suffix $)(expr xoff, yoff) =
if proofing > 0:
  x$bl = x$ - xoff; y$bl = y$ - yoff;         % Bottom Left Hand Corner
  z$br = (x$bl+cap_height, y$bl);             % BRHC
  z$tr = (x$bl+cap_height, y$bl+cap_height);  % TRHC
  z$tl = (x$bl, y$bl+cap_height);             % TLHC
  z$bc = 1/2[z$bl,z$br]; z$tc = 1/2[z$tl,z$tr];  % horizontal mid points
  pair hc, vc;
  hc = (2u,0); vc = (0,2u);
  pickup pensquare scaled 2;
  for s = z$bl, z$br, z$tr, z$tl, z$bc, z$tc:
    draw s-hc--s+hc;
    draw s-vc--s+vc;
  endfor
fi
enddef;


let cm_arm=arm;

vardef arm(suffix $,$$,@)(expr darkness, armjut) =  % arm from |z$| to |z$$|
numeric vjut_; vjut_= abs(bot y$l-bot y$$);
x@0=good.x(x$$r-armjut); y@0=y$r;
 if serifs: y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0);
   if x$$>=x$: x@2=x@1 - vjut_; else: x@2=x@1+vjut_; fi y@2=y$l;
  filldraw z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l]]{z@2-z$$l}...
  z@2if x$$>=x$: {left} else: {right} fi
   ---z$l--z$r--z@0--z$$r..cycle; % arm and beak
 else: filldraw z$l--z$r--z@0--z$$r--cycle; fi  % sans-serif arm
 penlabels(@0,@1,@2); enddef;


vardef foot(suffix $, $$, @)(expr darkness, armjut) = % curved beak on E and L
numeric vjut_; vjut_= abs(bot y$-bot y$$);
x@0=good.x(x$$r-armjut); y@0=y$r;
 if serifs:
   y@1=y$l; z@1=z$$l+whatever*(z$$r-z@0);
   x@2=x@1-vjut_; y@2=y$l;
   filldraw z$$l{z@1-z$$l}...darkness[z@1,.5[z@2,z$$l] ]...z@2
      ---z$l--z$r--z@0--z$$r--cycle; % arm and beak
 else:
   filldraw z$l--z$r--(x$$r,y$r)--(x$$r,y$l)--cycle;
 fi
 penlabels(@0,@1,@2); enddef;


vardef pulled_super_arc.l(suffix $, $$)(expr darkness)=
 pair corner;
 if y$=y$r: corner=(x$l, y$$l);
 else: corner=(x$$l,y$l); fi
 z$l{corner-z$l}...(darkness)[corner, .5[z$l, z$$l]]{z$$l-z$l}
 ...{z$$l-corner}z$$l enddef;

vardef pulled_super_arc.r(suffix $, $$)(expr darkness)=
 pair corner;
 if y$=y$r: corner=(x$r,y$$r);
 else: corner=(x$$r, y$r); fi
 z$r{corner-z$r}...(darkness)[corner, .5[z$r, z$$r]]{z$$r-z$r}
 ...z$$r{z$$r-corner} enddef;

vardef pulled_arc@#(suffix $, $$)=
 pulled_super_arc@#($,$$)(eta) enddef;


let cm_font_setup=font_setup; % Knuth's original font_setup

def slim_font_setup = % trimmed font_setup for use with Pacioli caps only
 if monospace: let adjust_fit=mono_adjust_fit;
  def mfudged=fudged enddef;
  mono_charic#:=body_height#*slant;
  if mono_charic#<0: mono_charic#:=0; fi
  mono_charwd#:=9u#; define_whole_pixels(mono_charwd);
 else: let adjust_fit=normal_adjust_fit;
  def mfudged= enddef; fi
 define_pixels(u,width_adj,serif_fit,cap_serif_fit,jut,cap_jut,bar_height,
  dish,bracket,beak_jut,apex_o,apex_corr);
 define_whole_pixels(letter_fit,fine,crisp,tiny);
 define_whole_vertical_pixels(body_height,asc_height,
  cap_height,x_height,comma_depth,desc_depth);
 define_whole_blacker_pixels(hair,stem,cap_stem);
 define_whole_vertical_blacker_pixels(vair,dslab,slab);
if slab<eps: slab:=eps fi;
 define_corrected_pixels(o);
 forsuffixes $=hair,stem,cap_stem:
  fudged$.#:=fudge*$.#; fudged$:=hround(fudged$.#*hppp+blacker);
  forever: exitif fudged$>.9fudge*$; fudged$:=fudged$+1; endfor endfor
 rule_thickness:=ceiling(rule_thickness#*hppp);
 heavy_rule_thickness:=ceiling(3rule_thickness#*hppp);
 oo:=vround(.5o#*hppp*o_correction)+eps;
 apex_oo:=vround(.5apex_o#*hppp*o_correction)+eps;
 lowres_fix(stem) 1.3;
 ess:=(ess#/stem#)*stem; cap_ess:=(cap_ess#/cap_stem#)*cap_stem;
 dw:=(curve#-stem#)*hppp; bold:=curve#*hppp+blacker;
 dh#:=.6designsize;
 more_super:=max(superness,sqrt .77superness);
 hein_super:=max(superness,sqrt .81225258superness); % that's $2^{-.3}$
 clear_pen_memory;
 if fine=0: fine:=1; fi
 forsuffixes $=fine,crisp,tiny:
%%% fine $ %%%% temporary formatting convention for MFT
  if $>fudged.hair: $:=fudged.hair; fi
  $.breadth:=$;
  pickup if $=0: nullpen else: pencircle scaled $; $:=$-eps fi;
  $.nib:=savepen; breadth_[$.nib]:=$;
  forsuffixes $$=lft,rt,top,bot: shiftdef($.$$,$$ 0); endfor endfor
%%% @ $ %%%% restore ordinary formatting for $
 min_Vround:=max(fine.breadth,crisp.breadth,tiny.breadth);
 if min_Vround<vround min_Vround: min_Vround:=vround min_Vround; fi
 pickup pencircle scaled rule_thickness; rule.nib:=savepen;
 currenttransform:=identity slanted slant
  yscaled aspect_ratio scaled granularity;
 if currenttransform=identity: let t_=relax
 else: def t_ = transformed currenttransform enddef fi;
 numeric paren_depth#; .5[body_height#,-paren_depth#]=math_axis#;
 numeric asc_depth#; .5[asc_height#,-asc_depth#]=math_axis#;
 body_depth:=desc_depth+body_height-asc_height;
 shrink_fit:=1+hround(2letter_fit#*hppp)-2letter_fit;
 if not string mode: if mode<=smoke: shrink_fit:=0; fi fi
 enddef;


def pacioli_font_setup= % contains special stuff for Pacioli fonts
  define_pixels(side,thick,thin,medium,half_height);
  define_pixels(Hrad,Lrad,lrad,srad,trad);
  define_pixels(dot_size,math_axis,flare,stem_corr,curve);
  if not known dslab#: dslab=eps; fi
enddef;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  END OF MACROS %%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


font_coding_scheme:="ASCII caps and punctuation";

mode_setup;

pacioli_font_setup;
if whole_font: font_setup; %slab:=eps;
 define_whole_vertical_blacker_pixels(dslab,slab);
 else: slim_font_setup; fi


input cpcromanu;   % Pacioli upper case (majuscules)
input cpcpunct;    % punctuation
input cpclig;      % the several dashes
input cpcromanp    % ampersand and ?mark


font_slant slant; font_x_height x_height#;
if monospace: font_normal_space 9u#; % no stretching or shrinking
 font_quad 18u#;
 font_extra_space 9u#;
else: font_normal_space 6u#+2letter_fit#;
 font_normal_stretch 3u#; font_normal_shrink 2u#;
 font_quad 18u#+4letter_fit#;
 font_extra_space 2u#;
 k#:=-.5u#; kk#:=-1.5u#; kkk#:=-2u#; % three degrees of kerning
 ligtable "P": "T": "Y": "A" kern kk#;
 ligtable "F": "V": "W": "A" kern if serifs: kkk# else: kk#fi,
  "K": "X": "O" kern k#, "C" kern k#, "G" kern k#, "Q" kern k#;
 ligtable "O": "D": "X" kern k#, "W" kern k#, "A" kern k#,
   "V" kern k#, "Y" kern k#;
 ligtable "A": if serifs: "R": fi
  "C" kern k#, "O" kern k#, "G" kern k#, "U" kern k#, "Q" kern k#,
  "L": "T" kern kk#, "Y" kern kkk#, "V" kern kk#, "W" kern kkk#;
ligtable "I": "I" kern -k#; fi % Richard III

bye.

