% #####################################################################

mode_setup;

% ===============
% set parameters unknown yet

if  unknown height_roof    :  height_roof     = 12 pt#;  fi
if  unknown height_shrinked:  height_shrinked = 5/6 height_roof;  fi
if  unknown height_normal  :  height_normal   = height_shrinked;  fi
if  unknown sign_width     :  sign_width      =  0 pt#;  fi
if  unknown centered       :  centered        =  0    ;  fi

% #####################################################################
% Pen control.
% #####################################################################

stroke_thickness_x# :=  0.4 pt#;  % thickness of   vertical strokes
stroke_thickness_y# :=  0.4 pt#;  % thickness of horizontal strokes

% #####################################################################
% Control height and width of glyphs.
% #####################################################################

% ===============
% prepare some parameter value checking

string  condition[];          % temporary variables only
string  wa; wa = "! Warning: (";
string  wo; wo =              ") necessary.";

% ===============
% Control height of Indus glyphs:

.                               % height of `roofed' glyphs
.                               % = maximal height of glyphs
dy_high#     = height_roof     - stroke_thickness_y#; 
.                               % height of `normal' glyphs (e.g. the `man')
dy_normal#   = height_normal   - stroke_thickness_y#;
.                               % height of the lower main part of roofed glyphs
dy_shrinked# = height_shrinked - stroke_thickness_y#;

condition\1 =   "height_roof >= height_normal";
condition\2 = "height_normal >= height_shrinked";
condition\3 =    "height_roof - height_shrinked >= 1/12 height_normal";
%	The difference needs to be great enough to allow drawing roofs,
%	the oval of 418, etc. in this space.

for i = 1,2,3:
	if not ( scantokens condition[i] ): message wa & condition[i] & wo; fi
endfor

% ===============
% Control maximal width of Indus glyphs:

dx_high# = max( 0, sign_width - stroke_thickness_x# );

% The width of very wide glyphs will be reduced.

% The width reduction will be done by reducing the width only,
% up to a proportion of xscaled_limit,
% beyond that, height as width will be reduced.

xscaled_limit    :=  0.60;

% ===============
% Control dimensions of ASCII glyphs:

asc_dy_normal#  =  8/12 dy_normal#; % height of letters A, b, ...
asc_dx#         =  4/12 dy_normal#; % fixed width
asc_dz#         =  3/12 dy_normal#; % depth of letters g, j, ...

% =======
% height of the baseline of ASCII signs, relative to that of Indus signs:

asc_baseline_y# = 0 pt#;

% =======
% the height of ASCII glyphs splits into a south and a north part:

asc_s_portion  :=  0.5;      % south portion of height

% #####################################################################
% Control global font parameters.
% #####################################################################

font_size                  dy_high#; % sets designsize

font_slant                    0 pt#; % amount of slant per point
font_normal_space    0.8 dy_normal#; % interword spacing
font_normal_stretch  0.2 dy_normal#; % stretchability of interword spacing
font_normal_shrink   0.2 dy_normal#; %  shrinkability of interword spacing
font_x_height        asc_s_portion * asc_dy_normal#; % TeX: `ex'
font_quad                dy_normal#;                 % TeX: `em'
font_extra_space     0.3 dy_normal#; % additional space between sentences

fontdimen 8:     designsize; % to be able, to ask for the design size too

font_identifier     jobname;
font_coding_scheme  "Indus script, signs and code of I.Mahadevan";

% #####################################################################
% Control signs to produce.
% #####################################################################

% The Indus signs to produce are given by the
%    `list_of_indus_signs_wanted',
% formed from single numbers and pairs
% (to interpret as number range wanted).
% The numbers are the sign numbers in the actual sign list (`ASL').
% Example: 111, (222,333), 75
% For the Mahadevan list, (0,419) means: produce all signs.
% (As (-infinity, +infinity) does, for any list.)

def  list_of_indus_signs_wanted =
	,     0         % illegible or lost passage sign (I. Mahadevan)
	, (   1, 419 )  % normal signs
enddef;

% ===============
% The ASCII signs to produce are given by (1~yes, 0~no):

	ascii_letters_lowercase_wanted := 0;
	ascii_letters_uppercase_wanted := 0;
	ascii_digits_wanted            := 1;
	ascii_special_signs_wanted     := 1;

% ===============
% The `preliminary' signs to produce
% (up to 128 are possible now - but that could be changed easily)
% are given by a (may be empty) list of `arbitrary' strings
% (but they should be short and normally unique too,
% and may only contain the 95 visible ASCII characters and the blank).
%
% The signs get codes consecutively (for no strong reason).
%
% Here we define as examples two possibilities, which enable
% to work with Seppo Koskenniemi/Asko Parpola/Simo Parpola texts
% or with Kimmo Koskenniemi/Asko Parpola texts
% (see references in file indusfont.mf)
% as long as the SKo resp. KKo font is not ready:

if false:
def  list_of_preliminary_glyph_strings  =  
			% may be useful as a delimiter ?:
	. ""
			% SKo signs, with no IMa sign, obviously equivalent
			% (but take this as a first raw sketch only):
	, "s006"  , "s010"  , "s012.2", "s014"  , "s018"  , "s026"
	, "s030"  , "s033"  , "s045"  , "s046"  , "s047"  , "s050"
	, "s054"  , "s075"  , "s078"  , "s079"  , "s083"  , "s084"
	, "s091"  , "s096"  , "s097.2", "s098"  , "s110"  , "s119.1"
	, "s121"  , "s123"  , "s139"  , "s147.2", "s152.2", "s157"
	, "s158"  , "s159"  , "s163"  , "s164"  , "s165"  , "s167"
	, "s172"  , "s173"  , "s176.1", "s177.1", "s179"  , "s183"
	, "s189.1", "s190"  , "s196"  , "s204"  , "s212"  , "s220"
	, "s221"  , "s230"  , "s239"  , "s240"  , "s241"  , "s245"
	, "s256"  , "s262"  , "s263"  , "s264"  , "s273.1", "s273.3"
	, "s274.1", "s274.3", "s274.4", "s274.5", "s275"  , "s278.2"
	, "s278.3", "s281"  , "s283"  , "s289"  , "s295"  , "s300"
	, "s302"  , "s303"  , "s313"  , "s328.1", "s330"  , "s332.1"
	, "s332.2", "s338.2", "s340"  , "s347"  , "s355.2", "s358"
	, "s360"  , "s367"  , "s368"  , "s370"  , "s375"  , "s376"
	, "s380.2", "s386"  , "s387"  , "s391"  , "s392"  , "s396.1"
	, "s396.2", "s396.3", "s396.4"
			% Some other `signs' for a purpose, not known yet:
	, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"
	, "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"
	, "A", "B"
enddef;
fi

if true:
def  list_of_preliminary_glyph_strings  =  
			% may be useful as a delimiter ?:
	. ""
			% KKo signs, with no IMa sign, obviously equivalent
			% (but take this as a first raw sketch only):
	, "k010.505", "k012"    , "k016"    , "k018"    , "k024"
	, "k030"    , "k033"    , "k044.077", "k044.452", "k049"
	, "k069"    , "k071"    , "k072"    , "k075.695", "k081"
	, "k084"    , "k090"    , "k091.045", "k097"    , "k105"
	, "k114.173", "k116"    , "k118"    , "k121.764", "k122.765"
	, "k123.003", "k124.004", "k134"    , "k141.492", "k153.485"
	, "k153.383", "k154.289", "k157"    , "k158"    , "k159"
	, "k161"    , "k166"    , "k167"    , "k168"    , "k169"
	, "k172.226", "k173.365", "k186.708", "k190"    , "k199"
	, "k206.078", "k207"    , "k214"    , "k215.312", "k218"
	, "k219"    , "k225"    , "k234"    , "k235"    , "k236"
	, "k239"    , "k241"    , "k252"    , "k259"    , "k260"
	, "k261"    , "k263"    , "k268.062", "k268.092", "k270.065"
	, "k270.067", "k270.068", "k270.396", "k271"    , "k273"
	, "k275.073", "k275.074", "k279"    , "k284.456", "k284.738"
	, "k287"    , "k291"    , "k293.055", "k297"    , "k298.379"
	, "k298.704", "k309"    , "k319"    , "k327.207", "k330"
	, "k332.211", "k332.210", "k345.262", "k348"    , "k357"
	, "k358"    , "k362"    , "k368"    , "k370"    , "k371"
	, "k373"    , "k377"    , "k381"    , "k385.420", "k390.418"
	, "k391"    , "k392"    , "k397"    , "k398"    , "k399"
	, "k400"    , "k401"    , "k402"    , "k403"
			% Some other `signs' for a purpose, not known yet:
	, "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m"
	, "n", "o", "p", "q", "r"
enddef;
fi

% #####################################################################
% Control sign code.
% #####################################################################

pair  ind_code_base
.   , asc_code_base
.   , preliminary_code_base;

ind_code_base         = (   0, 0 ); % Indus signs get codes 0 - 255
.                                   % (distributed on two fonts)
asc_code_base         = (   0, 0 ); % ASCII sign x'00' gets code 0
preliminary_code_base = ( 128, 0 ); % 1st preliminary sign gets code 128

% Wanted:
%   ind_code_base     = ( 0, 224 ); % start of Indus sign code area:
%                                   % x'e000' -> ( x'00', x'e0' )
% But I could not find yet a full set of utilities, handling codes >255.

% #####################################################################
% Should glyphs be centered in their signs space?
% #####################################################################

align_centered := centered; % 1 ~ centre (Indus-)glyphs horizontally
align_centered_asc   :=  0; % 1 ~ centre ASCII glyphs horizontally
.                           % 0 ~ do not centre
.                           % intermediate values are possible

% #####################################################################
% Miscellaneous
% #####################################################################

% ===============
% All Indus signs get a left and right white border, controlled by:

glyph_distance#  :=  2.5  pt#;

% ===============
% Someone glyph would look better, if it would overshoot its
% `mathematical' borders by o#
% - but there is made nearly no use of that yet. Sorry.

o#               :=  0.1 pt#;

% #####################################################################
% Indus sign dimension control.
% #####################################################################

% ((A number as `i123' means sign 123 from the I. Mahadevan list (1977).))

% =====================================================================
% ============================================ |  dimensions: height  |
% =====================================================================
% The height of the sign box, as shipped out and submitted
% to text handling software, will take on only values
% from the dy_list, to specify.
%
% There are the same possibilities as for the width,
% described below more detailed.
% Only some will be indicated by example here.
%
% A sign gets the lowest possible of the listed heights.
% Doubling of values in the list is possible.
%
% (There is a limit from Metafont:
%  15 different nonzero heights only are possible for the signs of a font.)
% =======
% Examples:
		% Some fixed heights only are ascribed to the signs:
	def  dy_list  = dy_normal#, dy_high#  enddef; % 2 heights (or one)
%	def  dy_list  =             dy_high#  enddef; % 1 height only

		% Signs with a height greater than normal
		% get their glyph height as height to ship out:
%	def  dy_list  = 8/12 dy_normal#, ( dy_normal#, dy_high# )  enddef;

		% Every sign gets its glyph height as height to ship out:
%	def  dy_list  = ( 0#, dy_high# )  enddef;
%	def  dy_list  =                   enddef; % works the same way
% =====================================================================
% ============================================= |  dimensions: width  |
% =====================================================================
% Main possibilities, we want to have for the Indus signs of the font:
% 1) All signs are of the same width.
% 2) The width is coming from a little set only.
%    (Example: a nearly-fixed-width font with some signs get double width.)
% 3) The signs have `free' width, i.e.:
%    sign width = glyph width  +  fixed minimal glyph distance
% 4) The signs have limited `free' width:
%    as `free' width, but with a given maximal width.
% =======
% To choose from these possibilities we specify a list
%   of sharp widths           - meaning: this is an accepted width -
%   and pairs of sharp widths - meaning: any value in this range
%                                        is an accepted width -
% The values in the list (incl. xpart and ypart of pairs)
% must be ordered in ascending row.
%
% Attention: The glyph distance is not included now in the given values.
% ((That may be changed, if it proves to be inconvenient.))
%
% (Note: the maximal width (sign i218) actually is 2.264 dy_normal#.)
% =======
% Examples:

if  sign_width = 0:
	def  dx_list =  ( 0 pt#, 8   dy_normal# )  enddef;   % variant 3)
else:
	def  dx_list =  sign_width  enddef;                  % variant 1)
fi

%	def  dx_list =    1 dy_normal#                       % variant 2)
%	.               , 2 dy_normal# + glyph_distance#
%	enddef;

%	def  dx_list =  ( 0 pt#, 1.5 dy_normal# )  enddef;   % variant 4)
% =====================================================================
% ============================================= |  dimensions: depth  |
% =====================================================================
% Formally the same possibilities as for the width exist for the depth -
% but there seems to be no strong reason to give Indus signs a depth > 0.
%
% From the glyphs, actually constructed here,
% only that of i152 extends a little bit below the baseline.
% (Other candidates for a depth > 0 would be i223, i224.)
%
% Because the glyph of i152 extends only to a very low depth
% (and this sign occurs only once in the texts of I.Mahadevan),
% it seems reasonable, to give a depth of 0 to this sign too.
% =======
% e.g.
	def  dz_list = 0 pt#  enddef;  % all signs get 0 as depth
%	def  dz_list =        enddef;  % give any sign the depth of its glyph
% =====================================================================

% #####################################################################
% ASCII parameters
% #####################################################################

def  asc_dx_list =      asc_dx#  enddef;
def  asc_dy_list = asc_s_portion * asc_dy_normal#, asc_dy_normal#  enddef;
def  asc_dz_list =   0, asc_dz#  enddef;

asc_super     :=  0.70;      % superness of ASCII digit zero
asc_super_O   :=  0.85;      % superness of ASCII letters O, G

% #####################################################################
% Preliminary sign parameters
% #####################################################################

def  pre_dx_list = dx_list     enddef;
def  pre_dy_list = dy_normal#  enddef;
def  pre_dz_list =          0  enddef;

preliminary_glyph_dist# = 3 stroke_thickness_x#;
preliminary_bound_dist# = 2 stroke_thickness_x#;

% #####################################################################
% Control error handling, reports and checking.
% #####################################################################
% The numeric values mean:
%    0 - no
%   >0 - yes,
%        a higher value means `in a higher degree'
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
	scrollmode;           % don't stop on error - but write diagnostics
	error_handling  := 1; % (very limited) error handling

% control size of output into the log file (and, maybe, to the terminal)
	tracingonline   := 1; % send all diagnostics to the terminal too
	progress_report := 0; % 1 - report main steps only
	.                     % 2 - report single Indus glyph generation too
	resource_report := 0; % 1 - log resource usage at end of job
	.                     % 2 - log it on some intermediate stages too
	.                     % 3 - log usage of some internal resources too

	tracingstats := resource_report; % >0: log resource usage at end of job

% to enable intervention at defined work stages:
	stop_when_glyphs_ready := 0;
	stop_after_work        := 0;

% to get a look on the online display (if it's working ...)
	stop_at_shipout        := 0;

% to check error possibilities:
%   to check correct bound settings:

	check_bounds_at_west   := 0; % (To check more than one side at once
	check_bounds_at_east   := 0; % . can trigger `memory overflow'
	check_bounds_at_south  := 0; % . if Metafont works with the
	check_bounds_at_north  := 0; % . standard memory of 263001 words.)

%   to check implementation conditions:
	check_names            := 0; % if memory overflows, set this to 0

% #####################################################################
