% Copyright 2003-2005 Han The Thanh <hanthethanh@gmx.net>.
% This file is part of vntex.  License: LPPL, version 1.3 or newer,
% according to http://www.latex-project.org/lppl.txt

% driver for cap and smallcap fonts (based on eccsc.mf)

version_check(1,0);  % |version_check| was introduced in dc1.3

input exaccess; % accessories for polish special letters
input expseudo; % pseudoparameters 

mode_setup;
font_setup;
pseudo_setup;

if known testing:
    set_uppercase;
    input vnaccent;
    input_ur_fam;
elseif known gen_t5_supp:
    input exbraces; % ^ ~ cwm  ( ) < | > [ ] \ { } _ - (177) space (040)
    input expunct;  %  < << > >>  ! ` ' *  + , . / = ; : (spanish !)
    input exsign;   %  zero for mille, " # $ % @ pound sign
    set_uppercase;
    input vnaccent;
    input vnuacc;
    input vnuor;    % Ohorn
    input vnuur;    % Uhorn
    input vnudr;    % D-bar
else:
    input exrulett; % upper case (majuscules)
    input exbraces; % ^ ~ cwm  ( ) < | > [ ] \ { } _ - (177) space (040)
    input expunct;  %  < << > >>  ! ` ' *  + , . / = ; : (spanish !)
    input exsign;   %  zero for mille, " # $ % @ pound sign
    input exromp;   % (roman punctuation)  & ? (spanish ?)
    input exrdigit; % roman digits

    set_uppercase;
    input vnaccent;
    input vnuar;    % modified/accented "A"
    input vnuer;    % modified/accented "E"
    input vnuir;    % accented "I"
    input vnuor;    % modified/accented "O"
    input vnuur;    % modified/accented "U"
    input vnuyr;    % accented "Y"
    input vnudr;    % D-bar
fi % known testing/gen_t5_supp

boolean is_small_cap; is_small_cap:=true;
%%% fine higher
% the `higher' values are used while putting accents and attaching ogoneks
forsuffixes $=u,o,letter_fit,x_height,bar_height,body_height,stem:
 higher.$.#:=$.#; higher.$:=$;
endfor

%%% fine lower
begingroup
forsuffixes $= u, width_adj, cap_serif_fit, letter_fit,
 body_height, cap_height, x_height, bar_height, comma_depth,
 flare, dot_size, cap_hair, stem, cap_stem, cap_curve, cap_ess,
 cap_jut, beak_jut, beak, slab, cap_bar, cap_band, cap_notch_cut,
 o, apex_o: save $; $.#:=lower.$.#; endfor
fudge:=lower.fudge;

% optional part:
forsuffixes $ = depth_corr, left_corr, top_breadth_corr, tip_breadth_corr,
  tip_xcorr, tip_ycorr, pre_angle, post_angle, pre_limit, post_limit,
  pre_lightness, post_lightness, pre_deflexion, post_deflexion, cap_flat,
  ogonek_pen#: if known lower.$: $:=lower.$; fi
endfor

input expseudo;  % Recalculate pseudoparameters

font_setup;
pseudo_setup;  % now try again with |lower| settings

if unknown testing and unknown gen_t5_supp:
    input_lig excspl;    % dotless i,j; letter ligatures  FF FI FL FFI FFL D-
fi

if known testing:
    set_smallcap;
    input vnaccent;
    input_sc_fam;
    def next= endgroup endinput enddef;
elseif known gen_t5_supp:
    set_smallcap;
    input vnaccent;
    input vnlacc;
    input vnuor;    % Ohorn
    input vnuur;    % Uhorn
    input vnudr;    % D-bar
    input txpseudo; % Recalculate pseudoparameters for capital accents
    font_setup;
    pseudo_setup;
    input txaccent; % Accents for capital letters with small cap parameters
    input vndothook;% dotbelow and hookabove
    input vnminus;  % minus iff monospace:
    def next= endgroup endinput enddef;
else:
    let next=relax;
fi % known testing/gen_t5_supp
next;

extra_endchar:=extra_endchar&"charcode:=charcode+code_offset";
code_offset:=ASCII"a" - ASCII"A";

input exrulett;  % upper case (majuscules)

suppress_i_dot := true;

code_offset:=0;

set_smallcap;
input vnaccent;
input vnuar;          % modified/accented "A"
input vnuer;          % modified/accented "E"
input vnuir;          % accented "I"
input vnuor;          % modified/accented "O"
input vnuur;          % modified/accented "U"
input vnuyr;          % accented "Y"
input vnudr;          % D-bar

input txpseudo; % Recalculate pseudoparameters for capital accents
font_setup;
pseudo_setup;
input txaccent; % Accents for capital letters with small cap parameters
input vndothook;% dotbelow and hookabove
input vnminus;  % minus iff monospace:

endgroup;


% Fontparameter
%
font_coding_scheme := "Vietnamese TeX Font Encoding";
boundarychar := oct"027";
font_slant slant; 
font_x_height x_height#;
font_cap_height cap_height#;
font_asc_height asc_height#;
font_acc_cap_height (cap_height#+acc_height#);
font_desc_depth desc_depth#;
font_max_height (max(asc_height#,body_height#, cap_height#+acc_height#));
font_max_depth (max(desc_depth#,paren_depth#,the_ogonek_depth#));
% font_digit_width % set inside the digits file
% font_cap_stem    % set after the programme of the capital I
font_baselineskip max(1.2*designsize,body_height#+paren_depth#);

if monospace:
    font_normal_space 9u#; % no stretching or shrinking
    font_quad 18u#;
    font_extra_space 9u#;
    input vnmligtb;   % do the monospace ligature programs
else:
    font_normal_space 6u# + 2letter_fit#;
    font_normal_stretch 3u#;
    font_normal_shrink 2u#;
    font_quad 18u# + 4letter_fit#;
    font_extra_space 2u#;
    input vncligtb;    % do the ligature programs, not for monospaced fonts
fi

endinput;
