%
% fikparm.mf
%
%% Cyrillic font container with T2 encoding beta-support
%
% This file is future part of lxfonts package
% Version 3.2 // Patchlevel=0
% (c) O.Lapko
%
% This package belongs to the public domain under conditions similar to
% those of D. E. Knuth specified for the Computer Modern family of fonts.
% In particular, only the authors are entitled to modify this file
% and to save it under the same name.
%
% Content:
%
% File with modified macros for font startup from polish fik_mik.mf
%   (Bogus\l{}aw Jackowski and Marek Ry\'cko)
% and
% Lig & kerns block from lkligtbl.mf (Alexander Berdnikov)
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Contents:
%
% |LHver_check| like exbase's |version_check|
% If unknown fonteq: def fonteq
% If unknown genmode: set genmode
% If unknown param_base: set param_base
% Set flags for input glyph files
% Set flags for letter shapes: not supported by current version
% Input fontbegin file (if necessary)
% Defining boolean altcoding
% Input cmbase and lcyrbeg (file with macros for ec param file)
% input lkligtbl.mf (ligs & kerns block of A.Berdnikov)
% Redefining `generate' macro
% Use_driver macro:
%  input parameter file
%  set font_identifier (and gensize for ec)
%  input coding file
%  input Cyrillic definitions file
%  input driver file
%
% FINAL: START FONT -- use_driver(fonteq)
%

% -- set genmode string
%

% defining LHver_check 3.2
%
lh_maj_ver:=3; lh_min_ver:=2; % version identification
def LHver_check(expr e,f)=
 if     e>lh_maj_ver: message "LH font warning: Obsolete base";
 elseif e<lh_maj_ver: message "LH font warning: File from old release found";
 else: % e=lh_maj_ver: OK
   if     f>lh_min_ver: message "LH font warning: Obsolete base";
   elseif f<lh_min_ver: message "LH font warning: File from old release found";
   else: % f=lh_min_ver: LH version is OK
   fi
 fi
enddef;

% changed fonteq with genmode must precede fikparm:

if unknown fonteq:  def fonteq=2 enddef; fi

if unknown genmode: string genmode; genmode:="cm"; fi
if genmode="dc": genmode:="ec";
   message "We use ec fonts only";  message "";
fi

% user may to specify |param_base| prior to calling fikparm
if unknown param_base:
  string param_base; param_base:=jobname;
fi

% next booleans are used in ??begin files:

% -- set booleans for font stuff
boolean wncoding,vfcoding,roman_ec;
wncoding:=false;
vfcoding:=false;
roman_ec:=false;

% -- set flags for Cyrillic letter assortment
boolean more_letters,old_cyr,other_cyr;
more_letters:=false;
old_cyr:=false;
other_cyr:=false;

% -- set flags for letter shapes
% - put ogoneks instead of descenders?
boolean is_ogonek;     is_ogonek=false;

% -- `true' not supported in current version
boolean concrete,specific,kapitel;
concrete=false;
specific=false;
kapitel:=false;

% -- set flags for ligature and kerning stuff
boolean	TITLEfont,SmallCapsfont,ROMANfont;

% if the first letter of fontname is "i" then font is invisible
if substring(0,1) of param_base="i":
  param_base:=substring(1,length(param_base)) of param_base;
  extra_endchar:=extra_endchar&"clearit;";
fi

string enc_name; % name of encoding for T2/X2

if substring(fonteq-2,fonteq) of param_base = "lh":
       % lh* fonts have not any additional parameters
   elseif substring(fonteq-2,fonteq) of param_base = "ll":
       param_base:="lh" & (substring(fonteq,length(param_base)) of param_base);
       vfcoding:=true;
   elseif substring(fonteq-2,fonteq) of param_base = "wn":
       more_letters:=true; wncoding:=true;
   elseif substring(fonteq-2,fonteq) of param_base = "la":
       roman_ec:=true; genmode:="ex"; enc_name:="T2A";
   elseif substring(fonteq-2,fonteq) of param_base = "lb":
       roman_ec:=true; genmode:="ex"; enc_name:="T2B";
   elseif substring(fonteq-2,fonteq) of param_base = "lc":
       roman_ec:=true; genmode:="ex"; enc_name:="T2C";
   elseif substring(fonteq-2,fonteq) of param_base = "rx":
       more_letters:=true; genmode:="ex"; enc_name:="X2";
   else: % for another non-standard fonts
       scantokens("input "
       & substring(fonteq-2,fonteq) of param_base & "begin.mf");
fi

% -- must go after redefined booleans wncoding and vfcoding in ??begin.mf
boolean altcoding;
  altcoding:= if wncoding or vfcoding: false else: true fi;

% -- start base file
if unknown cmbase: input cmbase; fi

% -- additional macros for ec compatible mode
input lcyrbeg;

% -- if TFMonly: "kill" cmbase's drawing macros
if known TFMonly: input nodraw; fi %  Only build TFM

% -- start macros for ligatures and kerning
input lkligtbl;

string driver_name,ss; numeric ii;

vardef generate @# = driver_name:=str @#; endgroup enddef;

% -- input parameter file
%    set font_identfier
%    then driver file
vardef use_driver @# (expr fonteq)=
%
% Start values
 ii:=0;
 forever: ii:=ii+1;
    ss:=substring(length(param_base)-ii,length(param_base)-ii+1) of param_base;
    exitif (ss<"0") or (ss>"9") or (ii>=length(param_base));
 endfor;
%
% - input parameter file
 ii:=ii-1;
 if (genmode="ex") or (genmode="ec"):
% - set gensize for ec parameter files
    gensize:=scantokens(
      (substring(length(param_base)-ii,length(param_base)) of param_base))/100;
    ss:="input ec" & (substring(fonteq,length(param_base)-ii) of param_base);
 else:
% - set gensize for cm parameter files
    gensize:=scantokens(
      (substring(length(param_base)-ii,length(param_base)) of param_base));
    ss:="input "& genmode & (substring(fonteq,length(param_base)) of param_base);
 fi
 show gensize,ss;
%
% - set font_identifier
 numeric true_pt#; true_pt#=pt#;
 pt#:=true_pt#; scantokens(ss); pt#:=true_pt#;
 font_identifier:=substring(0,length(param_base)-ii) of param_base;
%
% - input encoding file
 scantokens ("input " & (substring(fonteq-2,fonteq) of param_base) & "codes");
% - input Cyrillic definitions file
 scantokens "input lcyrdefs";
%
% - input driver file
 scantokens("input "&
  if genmode="ex":
     if driver_name=		"exroman" :	"leroman"
        elseif driver_name=	"extextit":	"letextit"
        elseif driver_name=	"excsc"   : 	"lecsc"
        else:  driver_name fi
  elseif genmode="ec":
     if driver_name=		"exroman" :	"ldroman"
        elseif driver_name=	"extextit":	"ldtextit"
        elseif driver_name=	"excsc"   : 	"ldcsc"
        else:  driver_name fi
  else:
     if driver_name=		"roman"   :	"ldroman"
        elseif driver_name=	"sroman"  :	"ldsroman"
        elseif driver_name=	"textit"  :	"ldtextit"
        elseif driver_name=	"title"   :	"ldtitle"
        elseif driver_name=	"csc"     :	"ldcsc"
   else:  driver_name fi fi);
enddef;

% START FONT
use_driver(fonteq);

endinput;
% end of file
