% KIX, a font for typesetting snail mail zipcodes.
%
% The KIX code is a barcodish format used to encode country codes, zip codes
% and street numbers in a machine-readable format.  If printed below the
% address line on bulk mailings, a discount can be obtained.
%
% This font is according to the Dutch specifications.  The sizes are
% optimal for printing on a printer with a resolution which is a multiple
% of 150dpi.  This optimisation means that the sizes in the TFM file for
% this font match almost exactly on an integer number of pixels.
%
% Install this font in your TeX distribution and update any distro caches.
% Include this file with \font\kix=kix and use it to format properly coded
% KIX-information, for instance {\kix 1234AB56} for zipcode 1234AB and street
% number 56.  For more information on the data to encode in KIX, please refer
% to the following site in Dutch:
%	http://www.tpgpostbusiness.nl/kix/
% KIX is also used in a few other countries, but not worldwide.
%
% Metafont scripting by Rick van Rein, KIX-knowledge from Ivo Terhorst.
%
% Available for any purpose, no warranties.


mode_setup;
font_identifier "kix";


% The bar in the code is barw# wide, spaces are #spcw wide
% The sync portion is synch# high, plus additional stickh# to either side
barw#   := 0.508mm#;
spcw#   := 0.677mm#;
synch#  := 1.27mm#;
stickh# := 2.08mm#;

define_pixels (barw, spcw, synch, stickh);


% Character dimensions:
%  wd, ht, dp

wd# := 4 * (barw# + spcw#);
ht# := synch# + stickh# + 2mm#;
dp# := stickh#;

define_pixels (wd, ht, dp)


% Routine to start a character definition

def defchar (expr ch) =
	beginchar (ch, wd#, ht#, dp#);
	x := 0;
enddef;

% Routine to draw a sync alone

def sync =
	fill (x,0)--(x+barw,0)--(x+barw,synch)--(x,synch)--cycle;
	x := x + barw + spcw
enddef;

% Routine to draw a stick down

def down =
	fill (x,-stickh)--(x+barw,-stickh)--(x+barw,synch)--(x,synch)--cycle;
	x := x + barw + spcw
enddef;

% Routine to draw a stick up

def up =
	fill (x,0)--(x+barw,0)--(x+barw,synch+stickh)--(x,synch+stickh)--cycle;
	x := x + barw + spcw
enddef;

% Routine to draw a long line

def updown =
	fill (x,-stickh)--(x+barw,-stickh)--(x+barw,synch+stickh)--(x,synch+stickh)--cycle;
	x := x + barw + spcw
enddef;

defchar ("1"); sync; down; up; updown; endchar;
defchar ("2"); sync; down; updown; up; endchar;
defchar ("3"); down; sync; up; updown; endchar;
defchar ("4"); down; sync; updown; up; endchar;
defchar ("5"); down; down; up; up; endchar;
defchar ("6"); sync; up; down; updown; endchar;
defchar ("7"); sync; updown; sync; updown; endchar;
defchar ("8"); sync; updown; down; up; endchar;
defchar ("9"); down; up; sync; updown; endchar;
defchar ("0"); sync; sync; updown; updown; endchar;
defchar ("A"); down; up; down; up; endchar;
defchar ("B"); down; updown; sync; up; endchar;
defchar ("C"); sync; up; updown; down; endchar;
defchar ("D"); sync; updown; up; down; endchar;
defchar ("E"); sync; updown; updown; sync; endchar;
defchar ("F"); down; up; up; down; endchar;
defchar ("G"); down; up; updown; sync; endchar;
defchar ("H"); down; updown; up; sync; endchar;
defchar ("I"); up; sync; down; updown; endchar;
defchar ("J"); up; down; sync; updown; endchar;
defchar ("K"); up; down; down; up; endchar;
defchar ("L"); updown; sync; sync; updown; endchar;
defchar ("M"); updown; sync; down; up; endchar;
defchar ("N"); updown; down; sync; up; endchar;
defchar ("O"); up; sync; updown; down; endchar;
defchar ("P"); up; down; up; down; endchar;
defchar ("Q"); up; down; updown; sync; endchar;
defchar ("R"); updown; sync; up; down; endchar;
defchar ("S"); updown; sync; updown; sync; endchar;
defchar ("T"); updown; down; up; sync; endchar;
defchar ("U"); up; up; down; down; endchar;
defchar ("V"); up; updown; sync; down; endchar;
defchar ("W"); up; updown; down; sync; endchar;
defchar ("X"); updown; up; sync; down; endchar;
defchar ("Y"); updown; up; down; sync; endchar;
defchar ("Z"); updown; updown; sync; sync; endchar;

end
