% 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

% Computer Modern Roman lower case "y" precomposed glyphs:
% Inclusion:
%               y'      y`      y?      y~      y.

begin_letter(y);
    set_letter_dimens(y)(
        if serifs: 9.5u# else: 9u# fi, x_height#, desc_depth#,
        x_height#*slant + .25u#,
        serif_fit# if monospace: +\\.5u#, .5u#+ else: ,fi\\ serif_fit#
    );
    numeric left_stem, right_stem, bot_stem, bot_vair, outer_jut;
    left_stem = fudged.stem - stem_corr;
    right_stem = fudged.hair if hefty: -2stem_corr fi;
    bot_stem = fudged.hair if hefty: -8stem_corr fi;
    bot_vair = Vround(if serifs: vair else: .5[vair, bot_stem] fi);
    outer_jut = .75jut;
    x1l = w-x4r = l+letter_fit + outer_jut + .25u;
    y1 = y4r = h;
    y2 = y3 = 0;
    x2l = x3l;
    numeric alpha, alpha[];
    x9 = 3u;
    y9 = bot_vair - d-oo;
    alpha1 = diag_ratio(2, bot_stem, y1 - y3, x4r - x1l - apex_corr);
    alpha2 = diag_ratio(1, bot_stem, y1 - y9, x4r - x9);
    if alpha1 < alpha2: x2l - x1l = x4r - x3r + apex_corr;
        alpha = alpha1;
    else: alpha = alpha2;
        z3l = whatever[z9, z4r - (alpha*bot_stem, 0)];
    fi
    penpos3(alpha*bot_stem, 0);
    penpos4(alpha*right_stem, 0);
    alpha3 = (y1 ++ (x2l - x1l))/y1;
    penpos1(alpha3*left_stem, 0);
    penpos2(alpha3*left_stem, 0);
    z0 = whatever[z1r, z2r] = z4l + whatever*(z3r - z4r);
    if y0 > notch_cut: y0 := notch_cut;
        fill z0 + .5right{up} ... {z4r - z3r}diag_end(0, 4l, 1, 1, 4r, 3r)
        -- z3r -- z2l -- diag_end(2l, 1l, 1, 1, 1r, 2r){z2 - z1}
        ... {down}z0 + .5left -- cycle; % left and right diagonals
    else: fill z0 -- diag_end(0, 4l, 1, 1, 4r, 3r) -- z3r -- z2l
        -- diag_end(2l, 1l, 1, 1, 1r, 0) -- cycle;
    fi % left and right diagonals
    penpos5(alpha*bot_stem, 0);
    z5r = whatever[z3r, z4r];
    y5 - .5vair=-.5d;
    if serifs: numeric light_bulb;
        light_bulb = hround 7/8[hair, flare];
        clearpen;
        penpos6(vair, -90);
        penpos7(hair, -180);
        penpos8(light_bulb, -180);
        x6 = 2u;
        y6r=-d - oo;
        y8 - .5light_bulb=-.85d;
        x8r = hround .35u;
        fill stroke z3e --- z5e ... {left}z6e;
        bulb(6, 7, 8);  % arc and bulb
        numeric inner_jut;
        pickup tiny.nib;
        prime_points_inside(1, 2);
        prime_points_inside(4, 3);
        if rt x1'r + jut + .5u + 1<=lft x4'l - jut: inner_jut = jut;
        else: rt x1'r + inner_jut + .5u + 1=lft x4'l - inner_jut;
        fi
        dish_serif(1', 2, a, 1/3, outer_jut, b, 1/2, inner_jut);  % left serif
        dish_serif(4', 3, c, .6, inner_jut, d, 1/2, outer_jut)(dark);  % right serif
    else: penpos6(bot_vair, -90);
        x6 = 2.5u;
        y6r=-d - oo;
        fill stroke z3e --- z5e ... {left}z6e;  % arc
        pickup fine.nib;
        pos6'(bot_vair, -90);
        z6' = z6;
        pos7(2/3[bot_vair, flare], -85);
        lft x7l = hround u;
        bot y7r = vround - .96d - oo;
        y7l := good.y y7l;
        filldraw stroke term.e(6', 7, left, 1, 4);
    fi % arc and terminal
    penlabels(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
    set_letter_join(y, x3, .5w#);
    path dot_join_line;
    dot_join_y := vp(max(vn_depth(y), vn_bot(dot_)) - .5vn_height(dot_));
    dot_join_line := (0, -dot_join_y) -- (w, -dot_join_y);
    z2' = whatever[z1, z2];
    y2' = -dot_join_y;
    set_letter_join(y.dot_, xpart point xpart(dot_join_line intersectiontimes 
                                              (z2 -- z2')) of dot_join_line,
                            .5w#);
    vn_dot_shift_y(y) := max(vn_depth(y), vn_bot(dot_));
    vn_depth(y.dot_) := vn_dot_shift_y(y);
end_letter;

input vnycomp;

endinput;
