% This file is part of vntex. License: GPL.
%
% Computer Modern Roman upper case "U" precomposed glyphs:
% Inclusion:
%               U'      U`      U?      U~      U.
%       U+      U+'     U+`     U+?     U+~     U+.

begin_letter(u);
    set_letter_dimens(u)(
        13u# + .5width_adj#, cap_height#, 0,
        cap_height#*slant - cap_serif_fit# + cap_jut# - 2.5u# + min(.5cap_stem#, u#),
        if monospace: 
            cap_serif_fit# - .5u#, cap_serif_fit# - .5u#
        else:
            cap_serif_fit#, cap_serif_fit#
        fi
    );
    pickup tiny.nib;
    pos1(cap_stem, 0);
    pos2(cap_stem, 0);
    pos2'(cap_stem, 180);
    z2' = z2;
    pos3(cap_band, -90);
    pos4(cap_hair, 0);
    pos5(cap_hair, 0);
    x1 = x2;
    x3 = .5[x1, x5];
    x4 = x5;
    x1l = w-x5r;
    top y1 = top y5 = h;
    y2 = y4 = 1/3h;
    bot y3r=-o;
    lft x1l = hround max(2u, 3u - .5cap_stem);
    filldraw stroke z1e -- z2e; % left stem
    filldraw stroke pulled_arc.e(2', 3)
    & pulled_arc.e(3, 4)&z4e -- z5e; % arc and right stem
    if serifs: dish_serif(1, 2, a, 1/3, cap_jut, b, 1/3, cap_jut); % left serif
        dish_serif(5, 4, c, 1/2, cap_jut, d, 1/2, cap_jut)(dark);
    fi  % right serif
    math_fit( - cap_serif_fit# - .3cap_height#*slant - min(cap_height#*slant, u#),
        max(.5ic# - .5u#, 0));
    set_letter_join(u, x3, .5w#);
    set_letter_join(u.dot_, x3 + .5u, .5w# + .5u#);
    set_horn_join(u, z4 -- z5, z4 -- z5);
    penlabels(1, 2, 3, 4, 5);
end_letter;

% for accented capital u with horn we need another letter "U" without right
% part of the right serif, however all calculations are done via dimensions of
% the above letter to make the macros simply

begin_letter(Uhorn); 
    set_letter_dimens(Uhorn)(
        13u# + .5width_adj#, cap_height#, 0,
        cap_height#*slant - cap_serif_fit# + cap_jut# - 2.5u# + min(.5cap_stem#, u#),
        if monospace: 
            cap_serif_fit# - .5u#, cap_serif_fit# - .5u#
        else: 
            cap_serif_fit#, cap_serif_fit# 
        fi
    );
    pickup tiny.nib;
    pos1(cap_stem, 0);
    pos2(cap_stem, 0);
    pos2'(cap_stem, 180);
    z2' = z2;
    pos3(cap_band, -90);
    pos4(cap_hair, 0);
    pos5(cap_hair, 0);
    x1 = x2;
    x3 = .5[x1, x5];
    x4 = x5;
    x1l = w - x5r;
    top y1 = top y5 = h;
    y2 = y4 = 1/3h;
    bot y3r = -o;
    lft x1l = hround max(2u, 3u - .5cap_stem);
    filldraw stroke z1e -- z2e; % left stem
    filldraw stroke pulled_arc.e(2', 3)
    & pulled_arc.e(3, 4)&z4e -- z5e; % arc and right stem
    if serifs: dish_serif(1, 2, a, 1/3, cap_jut, b, 1/3, cap_jut); % left serif
        dish_serif(5, 4, c, 1/2, cap_jut, d, 1/2, 0)(dark);
    fi  % right serif
    math_fit( - cap_serif_fit# - .3cap_height#*slant - min(cap_height#*slant, u#),
        max(.5ic# - .5u#, 0));
    penlabels(1, 2, 3, 4, 5);
end_letter;

input vnucomp;

endinput;
