% This file is part of the TeluguTeX Software Package.
%Copyright (c) 1991 Lakshmankumar Mukkavilli
%
%The TeluguTeX Software Package is distributed in the hope that
%it will be useful,but WITHOUT ANY WARRANTY.  No author or distributor
%accepts responsibility to anyone for the consequences of using it
%or for whether it serves any particular purpose or works at all,
%unless he says so in writing.  Refer to the TeluguTeX Software Package
%General Public License for full details.
%
%Everyone is granted permission to copy, modify and redistribute
%the TeluguTeX Software Package, but only under the conditions described in the
%TeluguTeX Software Package General Public License.   A copy of this license is
%supposed to have been given to you along with TeluguTeX Software Package so you
%can know your rights and responsibilities.  It should be in a
%file named CopyrightLong.  Among other things, the copyright notice
%and this notice must be preserved on all copies.
%%%%%
% This file contains code to generate vowels, vowel modifiers,
%  consonant bases, consonant conjuncts and accents

stest(va);  telchar "vowel a";
begintchar(v_a_code,v_a_width#,x_height#,0,0,0,0);
v_a_form;
sketch z10..z11..z1..z3..z4..z5..z6..z7--z8;
endtchar; etest;

stest(vaa);   telchar "vowel aa";
begintchar(v_aa_code,v_a_width#,x_height#,0,0,0,0);
v_a_form;
sketch z10..z11..z1..z3..z4..z2 &z2{(0,1)}..{up}z12..z6..z5..{left}z7--z8;
endtchar; etest;

stest(ve);  telchar "vowel e";
begintchar(v_e_code,v_e_width#,x_height#,des_depth#,0,0,0);
v_e_form;
d:=abs(bot y10);
endtchar; etest;

stest(vee); telchar "vowel ee";
begintchar(v_ee_code,cb_ra_width#+4u#,asc_height#,0,0,0,0);
cb_ra_form;
z10=top z1;
vm_a_form(1);
currentpicture := currentpicture shifted (u,0);
z6 = (0,1/2x_height);
barandhook_form(6,w,8);
endtchar; etest;

stest(vu); telchar "vowel u";
begintchar(v_u_code,v_u_width#,asc_height#,0,0,0,0);
v_u_form;
barandhook_form(7,v_u_width,1); z20=0.5[z8,z9];
vwedge(20);
h:=top y20a;
endtchar; etest;

stest(vuu); telchar "vowel uu";
begintchar(v_uu_code,v_u_width#+2.5u#,asc_height#,0,0,0,0);
v_u_form;
barandhook_form(7,w-x7,8); vwedge(8); vwedge(9);
h:=top y8a;
endtchar; etest;

stest(vro); telchar "vowel ro";
begintchar(v_ro_code,cb_ba_width#+2vm_u_width#,x_height#,0,0,0,0);
cb_ba_form;
vm_u_form(8);
vm_u_form(8b);
w:=rt x8b.b;
endtchar; etest;

stest(vroo); telchar "vowel roo";
begintchar(v_roo_code,cb_ba_width#+2vm_u_width#+vmwidth#,x_height#,0,0,0,0);
cb_ba_form;
vm_u_form(8);
z10=z8b;
vm_u_form(10);
z11=z10d;
barandhook_forma(11,vmwidth,5);
w:=rt x11b;
endtchar; etest;

stest(vlo); telchar "vowel lo";
begintchar(v_lo_code,v_lo_width#,x_height#,0,0,0,0);
v_lo_form;
endtchar; etest;

stest(vloo); telchar "vowel loo";
begintchar(v_loo_code,v_lo_width#+vmwidth#,x_height#,0,0,0,0);
v_lo_form;
barandhook_forma(9,vmwidth,5);
w:=rt x9b;
endtchar; etest;

stest(vea); telchar "vowel ea";
begintchar(v_ea_code,v_ea_width#,x_height#,0,0,0,0);
v_ea_form;
endtchar; etest;

stest(veae); telchar "vowel eae";
begintchar(v_eae_code,v_ea_width#,asc_height1#,0,0,0,0);
v_ea_form;
lft z10 = (0,5/6x_height);
z11 = (1/2v_ea_width,asc_height1);
sketch z10{up}..{right}z11;
h:=top y11;
endtchar; etest;

stest(vi); telchar "vowel i";
begintchar(v_i_code,v_i_width#,x_height#,0,0,0,0);
lit_cir_form;
bot z2=(x1+2u,0); rt z3=(v_i_width,1/2x_height);
top z4=(x2,x_height); z5=(x1,x_height-y1); top z6=(1/2x1,x_height);
lft z7=(0,y5);
sketch rt z1..z2..z3..z4..z5;
sketch z5..z6..z7;
endtchar; etest;

stest(vao); telchar "vowel ao";
begintchar(v_ao_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
endtchar; etest;


stest(vaoo); telchar "vowel aoo";
begintchar(v_aoo_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
vm_hook_form(2,2);
endtchar; etest;


stest(vau); telchar "vowel au";
begintchar(v_au_code,5/4cb_ja_width#,asc_height#,0,0,0,0);
cb_ja_form;
z12=top z2;
vm_au_form(12,w);
h:=top y12c; w:=rt x1000b;
endtchar; etest;

%--------------------end   of  vowels-------------------
stest(vma);  telchar "vowel modifier of a";
begintchar(vm_a_code,vm_a_width#,asc_height#,0,0,0,0);
top z1=(2/5vm_a_width,x_height); vm_a_form(1);
pivot_message(x1);
endtchar; etest;

stest(vmaa); telchar "vowel modifier of aa";
begintchar(vm_aa_code,11u#,asc_height#,0,0,0,0);
top z1 = (0,x_height);
barandhook_form(1,w,5);
pivot_message((w/3));
h:=top y1;
endtchar; etest;

stest(vmaaa); telchar "vowel modifier of aa";
% used for kha,nga,ja,nya etc.
begintchar(vm_aaa_code,8.3u#,asc_height#,0,0,0,0);
top z1 = (0,x_height);
barandhook_form(1,w,5);
pivot_message((1.6u),rt x1);
h:=top y1;
endtchar; etest;

stest(vme);  telchar "vowel modifier of e";
begintchar(vm_e_code,vm_e_width#,asc_height#,0,0,0,0);
vm_e_form;
pivot_message(x2);
h:=top y7;
endtchar; etest;

stest(vmee); telchar "vowel modifier of ee";
begintchar(vm_ee_code,vm_e_width#,asc_height#,0,0,0,0);
vm_e_form;
vm_hook_form(7,3);
pivot_message(x2);
endtchar; etest;

stest(vmeea); telchar "vowel modifier of ee";
% Used with kha,cha,ccha,ja,ta,na,ba,bha,ma,la,lla,va etc.
begintchar(vm_eea_code,vm_e_width#,asc_height#,0,0,0,0);
% w and h are revised
top z1=(0,vm_e_height1);
vm_hook_form(1,3); w:=rt x1c;
pivot_message(x1);
endtchar; etest;

stest(vmeeb); telchar "vowel modifier of ee";
% Used with ra,ga and da(and its variations)
begintchar(vm_eeb_code,vm_e_width#,asc_height#,0,0,0,0);
% w and h are revised
top z1=(0,vm_e_height3);
vm_hook_form(1,3); w:=rt x1c;
pivot_message(x1);
endtchar; etest;

stest(vmu); telchar "vowel modifier of u";
begintchar(vm_u_code,vm_u_width#,x_height#,0,0,0,0);
rt z1 = (0,w_height);
vm_u_form(1);
w:=rt x1b;
pivot_message(x1d);
endtchar; etest;

stest(vmuu); telchar "vowel modifier of uu";
begintchar(vm_uu_code,vm_u_width#+vmwidth#-2.5u#,x_height#,0,0,0,0);
rt z1 = (0,w_height);
vm_u_form(1);
barandhook_forma(1d,vmwidth,5);
w:=rt x1d.b;
endtchar; etest;

stest(vmro);  telchar "vowel modifier of ro";
begintchar(vm_ro_code,vm_ro_width#,x_height#,des_depth#,0,ul#,0);
vm_ro_form;
endtchar; etest;

stest(vmroo); telchar "vowel modifier of roo";
begintchar(vm_roo_code,vm_ro_width#+vmwidth#,x_height#,des_depth#,0,ul#,0);
vm_ro_form;
barandhook_forma(7,vmwidth,5);
w:=rt x7b;
endtchar; etest;

stest(vmlo); telchar "vowel modifier of lo";
begintchar(vm_lo_code,v_lo_width#,x_height#,0,0,0,0);
%w,h and d are revised later
v_lo_form;
cc_clear;cc_transform(v_lo_p);cc_whd(0,0);
pivot_message((x3*cc_scale));
endtchar; etest;

stest(vmloo); telchar "vowel modifier of loo";
begintchar(vm_loo_code,v_lo_width#+vmwidth#,x_height#,0,0,0,0);
%w,h and d are revised later
v_lo_form;
barandhook_forma(9,vmwidth,5);
w:=rt x9b;
cc_clear;cc_transform(v_lo_p);cc_transform(barandhook_p);cc_whd(0,0);
pivot_message((x3*cc_scale));
endtchar; etest;

stest(vmea);  telchar "vowel modifier of ea";
begintchar(vm_ea_code,vmwidth#,asc_height#,0,0,0,0);
top z1 = (4/7w,x_height);
vm_ea_form(1,w);
pivot_message(x1a);
h:=top y1c;
endtchar; etest;

stest(vmeae); telchar "vowel modifier of eae";
begintchar(vm_eae_code,vmwidth#,asc_height#,0,0,0,0);
top z1 = (4/7w,x_height);
vm_ea_form(1,w);
z2 = z1b;
vm_hook_form(2,3);
pivot_message(x1a);
w:=rt x2c;
endtchar; etest;

stest(vmib); telchar "vowel modifier of i(bottom)";
%top of vm_i is same as vm_ea
begintchar(vm_i2_code,vmwidth#,0,des_depth#,0,0,0);
top z1=(0,0);
barandhook_form(1,w,5); erase sketch barandhook_p;
transform t;
t:= identity rotated 180 shifted (vmwidth,-(bot_accent+(top y1a - bot y1c)));
sketch barandhook_p  transformed t;
pivot_message((w/2));
d:=abs(ypart (top z1 transformed t));
endtchar; etest;

stest(vmao);  telchar "vowel modifier of ao";
begintchar(vm_ao_code,vm_ao_width#,asc_height#,0,0,0,0);
vm_ao_form(1,0);sketch vm_ao_pa;
sketch subpath(0,5) of vm_ao_pb;
pivot_message(x1a);
endtchar; etest;

stest(vmaoo); telchar "vowel modifier of aoo";
begintchar(vm_aoo_code,vm_aoo_width#,asc_height#,0,0,0,0);
vm_ao_form(1,0);sketch vm_ao_pa;      % place the hook
sketch  vm_ao_pb;
pivot_message(x1a);
w:=rt x1l; h:=top y1j;
endtchar; etest;

stest(vmaooa); telchar "vowel modifier of aoo(alternate)";
% This is basically a hook to be attached on top of ao modifier
begintchar(vm_aoo_code_a,0#,asc_height#,0,0,0,0);
vm_ao_form(1,0);      % place the hook
sketch  vm_ao_pb; erase sketch subpath (0,5) of vm_ao_pb;
numeric left_shift;left_shift:=x1i;
currentpicture := currentpicture shifted (-left_shift,0);
h:=top y1j;w:=(rt x1l)-left_shift;
pivot_message(x1i-left_shift);
endtchar; etest;

stest(vmau); telchar "vowel modifier of au";
begintchar(vm_au_code,vmwidth#+4u#,asc_height#,0,0,0,0);
z1 = (0,x_height);
vm_au_form(1,w);
pivot_message(x1,na);
w:=rt x1000b; h:=top y1c;
endtchar; etest;


stest(vmp); telchar "absence of vowel modifier(pollu)";
begintchar(vm_p_code,cb_vg_width#,asc_height#,0,0,0,0);
top z1=(1/3w,x_height);  top z2 = (1/5w,x_height);
z3=(x2,(x_height+asc_height)/2); z4=(w/2,y3);
top z5=(x2,h); top rt z6=(w,h);
sketch z1--z2{left}..{right}z3--z4;
sketch z3{left}..{right}z5--z6;
pivot_message(x1);
endtchar; etest;
%------------End of Vowel Modifiers-------------------

stest(cbka); telchar "base of consonant ka";
begintchar(cb_ka_code,cb_ka_width#,x_height#,0,0,0,0);
cb_ka_form;
sketch cb_ka_p;
pivot_message(x2,x2);
endtchar; etest;

stest(cbkha); telchar "base of consonant kha";
begintchar(cb_kha_code,cb_kha_width#,x_height#,wedge_depth#,0,0,0);
cb_kha_form;
pivot_message(x11,x5);
endtchar; etest;

stest(cbga); telchar "base of consonant ga";
begintchar(cb_ga_code,cb_ga_width#,x_height#,0,0,0,0);
cb_ga_form;
pivot_message(x3,x3);
endtchar; etest;

stest(cbgha); telchar "base of consonant gha";
begintchar(cb_gha_code,cb_va_width#+vm_u_width#,x_height#,wedge_depth#,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
top z10=1/2[rt z1,z1];
wedge(10);
vm_u_form(3);
w:=rt x3b;
pivot_message(x1,x1,x3d);
endtchar; etest;

stest(cbnga); telchar "base of consonant nga";
begintchar(cb_nga_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
half_plus_form(3);
pivot_message(x3c,x7);
endtchar; etest;

stest(cbcha); telchar "base of consonant  cha";
begintchar(cb_cha_code,cb_cha_width#,x_height#,0,0,0,0);
cb_cha_form;
pivot_message(x8,x5);
endtchar; etest;

stest(cbccha); telchar "base of consonant ccha";
begintchar(cb_ccha_code,cb_cha_width#,x_height#,wedge_depth#,0,0,0);
cb_cha_form;
z10 = 1/2[rt z5,z5];
wedge(10);
pivot_message(x8,x5);
endtchar; etest;

stest(cbja); telchar "base of consonant ja";
begintchar(cb_ja_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
sketch cb_ja_pb;
pivot_message(x3z,x7);
endtchar; etest;

stest(cbjha); telchar "base of consonant jha";
begintchar(cb_jha_code,cb_ra_width#+2vm_u_width#,x_height#,wedge_depth#,0,0,0);
cb_ra_form;
% The next statement will identify the point on ra_form
% where the bowl will be attached.
z5 = (cb_ra_p) intersectionpoint ((x1,w_height)--(x1+w,w_height));
vm_u_form(5);
z6 = z5b;
wedge(6);
z7 = z6;
vm_u_form(7);
w:=rt x7b;
pivot_message(x1,x5,lft x7d);
endtchar; etest;

stest(cbnya); telchar "base of consonant nya";
begintchar(cb_nya_code,v_e_width#+half_plus_width#,x_height#,0,0,0,0);
v_e_form;
z14= v_e_p intersectionpoint ((x4,j_height)--(w,j_height));
z15=z14;
half_plus_form(15);
pivot_message(x15c,x7);
w:=rt x15b;d:=abs(bot y10);
endtchar; etest;

stest(cbtta); telchar "base of consonant tta";
begintchar(cb_tta_code,cb_tta_width#,x_height#,0,0,0,0);
cb_tta_form;
vwedge(18);
sketch cb_tta_p;
pivot_message(x7,x4,x19);
h:=top y18a;
endtchar; etest;

stest(cbttha); telchar "base of consonant ttha";
begintchar(cb_ttha_code,cb_ra_width#,x_height#,0,0,0,0);
cb_ra_form;
z10 = (x1,1/2x_height);
fill_dot(10);
pivot_message(x1,x1);
endtchar; etest;

stest(cbdda);  telchar "base of consonant dda";
begintchar(cb_dda_code,v_u_width#,x_height#,0,0,0,0);
v_u_form;
pivot_message((x8+x9)/2,x5);
endtchar; etest;

stest(cbddha); telchar "base of consonant ddha";
begintchar(cb_ddha_code,v_u_width#,x_height#,wedge_depth#,0,0,0);
v_u_form;
z12=3/4[rt z5,z5];
wedge(12);
pivot_message((x8+x9)/2,x5);
endtchar; etest;

stest(cbnna); telchar "base of consonant nna";
begintchar(cb_nna_code,cb_nna_width#,x_height#,0,0,0,0);
cb_nna_form;
pivot_message(x7,x6);
endtchar; etest;

stest(cbta); telchar "base of consonant ta";
begintchar(cb_ta_code,cb_ta_width#,x_height#,0,0,0,0);
cb_ta_form;
sketch cb_ta_p;
pivot_message(x10,x5);
endtchar; etest;

stest(cbtha); telchar "base of consonant tha";
begintchar(cb_tha_code,cb_da_width#,x_height#,wedge_depth#,0,0,0);
cb_da_form;
wedge(4);
z10 = (x1,2/3x_height-uh);
fill_dot(10);
pivot_message(x1,x4);
endtchar; etest;

stest(cbda); telchar "base of consonant da";
begintchar(cb_da_code,cb_da_width#,x_height#,0,0,0,0);
cb_da_form;
pivot_message(x1,x4);
endtchar; etest;

stest(cbdha); telchar "base of consonant dha";
begintchar(cb_dha_code,cb_da_width#,x_height#,wedge_depth#,0,0,0);
cb_da_form;
wedge(4);
pivot_message(x1,x4);
endtchar; etest;

stest(cbna);telchar "base of consonant  na";
begintchar(cb_na_code,cb_na_width#,x_height#,0,0,0,0);
cb_na_form;
sketch  cb_na_p;
pivot_message(x6,x6);
endtchar; etest;

stest(cbpa);  telchar "base of consonant pa";
begintchar(cb_pa_code,cb_va_width#,x_height#,0,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
pivot_message(x1,x1);
endtchar; etest;

stest(cbpha); telchar "base of consonant pha";
begintchar(cb_pha_code,cb_va_width#,x_height#,wedge_depth#,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
top z10 = 1/2[rt z1,z1];
wedge(10);
pivot_message(x1,x1);
endtchar; etest;

stest(cbba);  telchar "base of consonant  ba";
begintchar(cb_ba_code,cb_ba_width#,x_height#,0,0,0,0);
cb_ba_form;
pivot_message(x9,x6);
endtchar; etest;

stest(cbbha); telchar "base of consonant bha";
begintchar(cb_bha_code,cb_ba_width#,x_height#,wedge_depth#,0,0,0);
cb_ba_form;
wedge(6);
pivot_message(x9,x6);
endtchar; etest;

stest(cbma); telchar "base of consonant ma";
begintchar(cb_ma_code,cb_va_width#+vm_u_width#,x_height#,0,0,0,0);
cb_va_form;
sketch  cb_va_p;
vm_u_form(3);
w:=rt x3b;
pivot_message(x5,x1,x3d);
endtchar; etest;

stest(cbya); telchar "base of consonant ya";
begintchar(cb_ya_code,cb_ya_width#+vm_u_width#,x_height#,0,0,0,0);
cb_ya_form;
 sketch z1..z2..z3..z4..cycle;
 sketch z3{down}..{right}z5..z6..z7..z8;
vm_u_form(6);
w:=rt x6b;
pivot_message(x8,x3,x6d);
endtchar; etest;

stest(cbra); telchar "base of consonant ra";
begintchar(cb_ra_code,cb_ra_width#,x_height#,0,0,0,0);
cb_ra_form;
pivot_message(x1,x3);
endtchar; etest;

stest(cbrra); telchar "base of consonant rra";
begintchar(cb_rra_code,cb_tta_width#,x_height#,0,0,0,0);
cb_rra_form;
pivot_message(x7,x4,x19);
endtchar; etest;

stest(cbla); telchar "base of consonant la";
begintchar(cb_la_code,cb_la_width#,x_height#,0,0,0,0);
cb_la_form;
sketch cb_la_p;
pivot_message(x5,x3,x8);
endtchar; etest;

stest(cblla); telchar "base of consonant lla";
begintchar(cb_lla_code,cb_lla_width#,x_height#,0,0,0,0);
cb_lla_form;
pivot_message(x10,x1);
endtchar; etest;

stest(cbva); telchar "base of consonant va";
begintchar(cb_va_code,cb_va_width#,x_height#,0,0,0,0);
cb_va_form;
sketch  cb_va_p;
pivot_message(x5,x1);
endtchar; etest;

stest(cbca); telchar "base of consonant ca";
begintchar(cb_ca_code,cb_ca_width#,x_height#,0,0,0,0);
cb_ca_form;
pivot_message(x6,x3,x10);
endtchar; etest;

stest(cbsha); telchar "base of consonant sha";
begintchar(cb_sha_code,cb_sha_width#,x_height#,wedge_depth#,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
bot rt z25 = (cb_sha_width,-d);
sketch bot z3{down}..{right}z25;
pivot_message(x1,x1);
endtchar; etest;

stest(cbsa); telchar "base of consonant sa";
begintchar(cb_sa_code,cb_na_width#,x_height#,0,0,0,0);
cb_na_form;
sketch subpath (0,4.7) of cb_na_p;
pivot_message(x3,x6);
endtchar; etest;

stest(cbha); telchar "base of consonant ha";
begintchar(cb_ha_code,cb_va_width#+vmwidth#,x_height#,0,0,0,0);
cb_va_form;
z10 = point 3.6 of cb_va_p;
top z11 = (x10,x_height);
sketch subpath(0,3) of cb_va_p..z11;
barandhook_forma(11,vmwidth,5);
pivot_message(x5,x2,x11a);
w:=rt x11b;
endtchar; etest;

stest(cbksha); telchar "base of consonant ksha";
begintchar(cb_ksha_code,cb_ka_width#,x_height#,cb_ksha_depth#,0,0,0);
cb_ksha_form;
sketch cb_ka_p;
pivot_message(x2,x6);
endtchar; etest;

stest(cbdt); telchar "dantyam accent(sits at top)";
begintchar(cb_dt_code,vmwidth#,0,0,0,0,0);
% h is set later
top z1=(0,top_accent);
barandhook_form(1,w,5);erase sketch barandhook_p;
transform t;
t:=identity reflectedabout (top z1, top z1 + (w,0));
sketch barandhook_p  transformed t;
h:=ypart((bot z1c) transformed t);
pivot_message((w/2));
endtchar; etest;

stest(cbnp); telchar "consonant nakaarapollu(np)";
begintchar(cb_np_code,cb_np_width#,x_height#,0,0,0,ur#);
bot z1 = (1/2w,0);
bot z2 = (1/5w,0);
z3 = (x2,1/3x_height);
z4 = (x1,y3);
z5 = (x3,2/3x_height);
z6 = (x1,y5);
top z7 = (x2,x_height);
top rt z8 = (w,x_height);
sketch z1--z2{left}..{right}z3--z4;
sketch z3{left}..{right}z5--z6;
sketch z5{left}..{right}z7--z8;
endtchar; etest;

stest(cbvg); telchar "consonant valapalagilaka(vg)";
begintchar(cb_vg_code,cb_vg_width#,x_height#,0,0,0,ur#);
bot z1 = (1/2w,0);
bot z2 = (1/5w,0);
z3 = (x2,1/3x_height);
z4 = (x1,y3);
top z5 = (x2,2/3x_height);
top rt z6 = (w,2/3x_height);
sketch z1--z2{left}..{right}z3--z4;
sketch z3{left}..{right}z5--z6;
h:=top y5;
endtchar; etest;

stest(cbbb); telchar "consonant blackbox(bb)";
%This is not really a letter in Telugu. However this character
% is useful for demonstrating vowel modifiers, cons. conjuncts, accents etc.
begintchar(cb_bb_code,0.2em_width#,0.8x_height#,0.25x_height#,0,0,0);
fill (0,-d)--(w,-d)--(w,h)--(0,h)--cycle;
pivot_message((w/2),(w/2));
endtchar; etest;

stest(cbbo); telchar "consonant outlinebox(bo)";
%This is not really a letter in Telugu. However this character
% is useful for demonstrating vowel modifiers, cons. conjuncts, accents etc.
begintchar(cb_bo_code,0.2em_width#,x_height#,0,0,0,0);
bot lft z1=(0,-d);bot rt z2=(w,-d);top rt z3=(w,h); top lft z4=(0,h);
z1a=(0,y1);z2a=(w,y2);z3a=(w,y3);z4a=(0,y4);
sketch z1--z4; sketch z2--z3; sketch z1a--z2a; sketch z4a--z3a;
cutoff(z1a,180);cutoff(z2a,0);cutoff(z3a,0);cutoff(z4a,180);
pivot_message((w/2),(w/2));
endtchar; etest;

stest(cbbe); telchar "consonant emptybox(be)";
%This is not really a letter in Telugu. However this character
% is useful for demonstrating vowel modifiers, cons. conjuncts, accents etc.
begintchar(cb_be_code,0.2em_width#,x_height#,0,0,0,0);
pivot_message((w/2),(w/2));
endtchar; etest;
%----------------End of Consonants(Base)----------

stest(ccka);  telchar "consonant conjunct of ka";
begintchar(cc_ka_code,6u#,x_height#,des_depth#,0,ul#,0);
top lft z1 = (0,h);
z2 = (w/4,(-d+h)/2);
lft z3 = (0,-1/3d);
bot z4 = (1/3w,-d);
z5 = (w/2,0);
rt z6 = (w,0);
sketch z1..z2..z3..z4{right}..{up}z5--z6;
endtchar; etest;

stest(cckha); telchar "consonant conjunct of kha";
begintchar(cc_kha_code,cb_kha_width#,x_height#,0,0,0,0);
cb_kha_form;
cc_clear; cc_transform(cb_kha_p);
cc_transform(wedge_p);cc_whd(0,1);
pivot_message(x5*cc_scale);
endtchar; etest;

stest(ccga); telchar "consonant conjunct of ga";
begintchar(cc_ga_code,cb_ga_width#,x_height#,0,0,0,0);
cb_ga_form;
cc_clear; cc_transform(cb_ga_p);cc_whd(0,0);
pivot_message(x3*cc_scale);
endtchar; etest;

stest(ccgha); telchar "consonant conjunct of gha";
begintchar(cc_gha_code,cb_va_width#+vm_u_width#,x_height#,0,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
top z10=1/2[rt z1,z1];
wedge(10);
vm_u_form(3);
cc_clear; cc_transform(subpath(0,3.4) of cb_va_p);
cc_transform(lit_cir_p);
cc_transform(wedge_p);cc_transform(vm_u_p);cc_whd(0,1);
pivot_message(x1*cc_scale);
endtchar; etest;

stest(ccnga); telchar "consonant conjunct of nga";
begintchar(cc_nga_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
half_plus_form(3);
cc_clear; cc_transform(cb_ja_pa);
cc_transform(half_plus_pa);
cc_transform(half_plus_pb);cc_whd(0,0);
pivot_message(x7*cc_scale);
endtchar; etest;

stest(cccha); telchar "consonant conjunct of cha";
begintchar(cc_cha_code,cb_cha_width#,x_height#,0,0,ul#,0);
cb_cha_form;
cc_clear; cc_transform(((subpath (0,6) of cb_cha_p) .. z97));
cc_whd(1,0);
endtchar; etest;

stest(ccccha); telchar "consonant conjunct of ccha";
begintchar(cc_ccha_code,cb_cha_width#,x_height#,0,0,ul#,0);
cb_cha_form;
z10 = 1/2[rt z5,z5];
wedge(10);
cc_clear; cc_transform(((subpath (0,6) of cb_cha_p) .. z97));
cc_transform(wedge_p);cc_whd(1,1);
endtchar; etest;

stest(ccja); telchar "consonant conjunct of ja";
begintchar(cc_ja_code,cb_ja_width#,x_height#,0,0,0,0);
cb_ja_form;
cc_clear; cc_transform(cb_ja_pa);
cc_transform(cb_ja_pb); cc_whd(0,0);
pivot_message(x7*cc_scale);
endtchar; etest;

stest(ccjha); telchar "consonant conjunct of jha";
begintchar(cc_jha_code,cb_ra_width#+2vm_u_width#,x_height#,0,0,0,0);
cb_ra_form;
% The next statement will identify the point on ra_form
% where the bowl will be attached.
z5=z4;
vm_u_form(5);
path p; p:=vm_u_p;
z6 = z5b;
wedge(6);
z7 = z6;
vm_u_form(7);
w:=rt x7b;
cc_clear; cc_transform(cb_ra_p);
cc_transform(p); cc_transform(vm_u_p);
cc_transform(wedge_p);cc_whd(0,1);
penlabels(5,6);
pivot_message(x5*cc_scale);
endtchar; etest;

stest(ccnya); telchar "consonant conjunct of nya";
begintchar(cc_nya_code,v_e_width#+half_plus_width#,x_height#,0,0,0,0);
v_e_form;
z14= v_e_p intersectionpoint ((x4,j_height)--(w,j_height));
z15=rt z14;
half_plus_form(15);
w:=rt x15b;d:=abs(bot y10);
cc_clear; cc_transform(v_e_p);
cc_transform(half_plus_pa);
cc_transform(half_plus_pb);cc_whd(0,0);
d:=d+(abs(bot y10) - pen_width/2)*cc_scale + pen_width/2+bot_spill;
pivot_message(x7*cc_scale);
endtchar; etest;

stest(cctta); telchar "consonant conjunct of tta";
begintchar(cc_tta_code,cb_tta_width#,top_height#,0,0,0,0);
cb_tta_form;
vwedge(18);
cc_clear; cc_transform(cb_tta_p); cc_whd(0,0);
pivot_message(x4*cc_scale);
endtchar; etest;

stest(ccttha); telchar "consonant conjunct of ttha";
begintchar(cc_ttha_code,cb_ra_width#,x_height#,0,0,0,0);
cb_ra_form;
z10 = (x1,1/2x_height);
fill_dot(10);
cc_clear; cc_transform(cb_ra_p);
cc_f_transform(fill_dot_p);cc_whd(0,0);
pivot_message(x1*cc_scale);
endtchar; etest;

stest(ccdda);  telchar "consonant conjunct of dda";
begintchar(cc_dda_code,v_u_width#,top_height#,0,0,0,0);
v_u_form;
cc_clear; cc_transform(v_u_p); cc_whd(0,0);
pivot_message(x5*cc_scale);
endtchar; etest;

stest(ccddha); telchar "consonant conjunct of ddha";
begintchar(cc_ddha_code,v_u_width#,x_height#,0,0,0,0);
v_u_form;
z12=3/4[rt z5,z5];
wedge(12);
cc_clear; cc_transform(v_u_p);
cc_transform(wedge_p);cc_whd(0,1);
pivot_message(x5*cc_scale);
endtchar; etest;

stest(ccnna); telchar "consonant conjunct of nna";
begintchar(cc_nna_code,cb_nna_width#,x_height#,0,0,0,0);
cb_nna_form;
cc_clear; cc_transform(cb_nna_p);cc_whd(0,0);
pivot_message(x6*cc_scale);
endtchar; etest;

stest(ccta);  telchar "consonant conjunct of ta";
begintchar(cc_ta_code,vmwidth#,0,0,0,0,0);
% d is set later
top z1=(0,0); barandhook_form(1,w,5); erase sketch barandhook_p;
sketch barandhook_p  reflectedabout ( top z1, top z1+(w,0))
                               shifted (0, (-bot_accent+ (bot y1c)));
d:=bot_accent- (bot y1c);
pivot_message((w/2));
endtchar; etest;

stest(cctha); telchar "consonant conjunct of tha";
begintchar(cc_tha_code,cb_da_width#,x_height#,0,0,0,0);
cb_da_form;
wedge(4);
z10 = (x1,2/3x_height-uh);
fill_dot(10);
cc_clear; cc_transform(cb_da_p);
cc_transform(wedge_p); cc_f_transform(fill_dot_p);
cc_whd(0,1);
pivot_message(x4*cc_scale);
endtchar; etest;

stest(ccda); telchar "consonant conjunct of da";
begintchar(cc_da_code,cb_da_width#,x_height#,0,0,0,0);
cb_da_form;
cc_clear; cc_transform(cb_da_p);
cc_whd(0,0);
pivot_message(x4*cc_scale);
endtchar; etest;

stest(ccdha); telchar "consonant conjunct of dha";
begintchar(cc_dha_code,cb_da_width#,x_height#,0,0,0,0);
cb_da_form;
wedge(4);
cc_clear; cc_transform(cb_da_p);
cc_transform(wedge_p);
cc_whd(0,1);
pivot_message(x4*cc_scale);
endtchar; etest;

stest(ccna);  telchar "consonant conjunct of na";
begintchar(cc_na_code,7u#,x_height#,des_depth#,0,ul#,0);
top lft z1 = (0,h);
z2 = (1/2w,(h-d)/2);
bot z3 = (1/4w,-d);
lft z4 = (0,-d+1/2sc_height);
z5 = (x3,y3+sc_height);
bot z6 = (3/4w,-d);
rt z7 = (w,y4);
sketch z1..z2..z3..z4..z5..z6..z7;
endtchar; etest;

stest(ccpa);  telchar "consonant conjunct of pa";
begintchar(cc_pa_code,cb_va_width#,top_height#,0,0,ul#,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
cc_clear; cc_transform(((subpath(0,2) of cb_va_p)..z97));
cc_transform(lit_cir_p);
cc_whd(1,0);
endtchar; etest;

stest(ccpha); telchar "consonant conjunct of pha";
begintchar(cc_pha_code,cb_va_width#,x_height#,0,0,ul#,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
top z10 = 1/2[rt z1,z1];
wedge(10);
cc_clear; cc_transform(((subpath(0,2) of cb_va_p)..z97));
cc_transform(lit_cir_p);cc_transform(wedge_p); cc_whd(1,1);
endtchar; etest;

stest(ccba);  telchar "consonant conjunct of  ba";
begintchar(cc_ba_code,cb_ba_width#,top_height#,0,0,ul#,0);
cb_ba_form;
cc_clear; cc_transform(((subpath(0,7) of cb_ba_p)..z97));
cc_whd(1,0);
endtchar; etest;

stest(ccbha); telchar "consonant conjunct of bha";
begintchar(cc_bha_code,cb_ba_width#,x_height#,0,0,ul#,0);
cb_ba_form;
wedge(6);
cc_clear; cc_transform(((subpath(0,7) of cb_ba_p)..z97));
cc_transform(wedge_p); cc_whd(1,1);
endtchar; etest;

stest(ccma);  telchar "consonant conjunct of ma";
begintchar(cc_ma_code,6u#,x_height#,des_depth#,0,ul#,0);
rt z1=(w,-d+uh);bot z2=(w/2,-d);
lft z3=(0,-d/3); z4=(2/3w,x_height/5);
rt z5=(w,0); z6=(x4,-5/10d);
z7=(w/2,y5); z8=(2/3w,x_height/2);
top lft z9=(0,h);
sketch z1..z2..z3..z4..z5..z6..z7..z8..z9;
endtchar; etest;

stest(ccya);  telchar "consonant conjunct of ya";
begintchar(cc_ya_code,6u#,x_height#,des_depth#,0,ul#,0);
lft z1 = (0,-1/3d); z2 = (w/4,0); z3 = (1/4w,-1/2d);
bot z4 = (1/3w,-d); z5 = (2/3w,0); z6 = (1/3w,j_height);
top  z7 = (2/3w,h); rt z8=(w,y6);
sketch z1..z2..z3..z4..z5..z6..z7..z8;
endtchar; etest;

stest(ccra);  telchar "consonant conjunct of ra";
begintchar(cc_ra_code,7u#,0,3.5uh#,0,0,0);
top lft z1=(0,-bot_accent); bot z2=(w/2,-d); top rt z3=(w,-bot_accent);
sketch z1..z2..z3;
pivot_message(x2);
endtchar; etest;

stest(ccrra); telchar "consonant conjunct of rra";
begintchar(cc_rra_code,cb_tta_width#,x_height#,0,0,0,0);
cb_rra_form;
cc_clear; cc_transform(cb_rra_p); cc_whd(0,0);
pivot_message(x4*cc_scale);
endtchar; etest;

stest(ccla);  telchar "consonant conjunct of la";
begintchar(cc_la_code,7u#,0,4.5uh#,0,0,0);
path s,t;
bot z1=(w/4,-d); lft z2 =(0,-1/2d); top z3=(x1,-bot_accent);
top z4=(w/2,y2);
s= z1..z2..z3..z4;
t=s reflectedabout ((w/2,h),(w/2,-d));
sketch s;sketch t;
pivot_message(x4);
endtchar; etest;

stest(cclla); telchar "consonant conjunct of lla";
begintchar(cc_lla_code,cb_lla_width#,asc_height#,0,0,ul#,0);
cb_lla_form;
cc_clear; cc_transform(((subpath (0,6) of cb_lla_pa)..z97));
cc_transform(cb_lla_pb); cc_whd(1,0);
endtchar; etest;

stest(ccva);  telchar "consonant conjunct of va";
begintchar(cc_va_code,6u#,x_height#,des_depth#,0,ul#,0);
lit_cir_form; erase sketch lit_cir_p;
transform t;
t= identity shifted (0,-d);
sketch lit_cir_p  transformed t;
z10=z1 transformed t;
z2 = (0,y1); bot z3 = (2/3w,-d); rt z4 = (w,-1/2d);
z5 = (1/3w,w_height); top z6 = (2/3w,h); rt z7 = (w,j_height);
sketch z10..z3..z4..z5..z6..z7;
endtchar; etest;

stest(ccca); telchar "consonant conjunct of ca";
begintchar(cc_ca_code,cb_ca_width#,asc_height#,0,0,ul#,0);
cb_ca_form;
cc_clear; cc_transform(((subpath (0,6) of cb_ca_p){up}..z97)); cc_whd(1,0);
endtchar; etest;

stest(ccsha); telchar "consonant conjunct of sha";
begintchar(cc_sha_code,cb_sha_width#,x_height#,0,0,0,0);
cb_va_form;
sketch subpath(0,3.4) of cb_va_p;
bot rt z10 = (cb_sha_width,0);
sketch z3..z10;
cc_clear; cc_transform(subpath(0,3.4) of cb_va_p);
cc_transform(lit_cir_p);
cc_transform((z3..z10)); cc_whd(0,0);
pivot_message(x2*cc_scale);
endtchar; etest;

stest(ccsa); telchar "consonant conjunct of sa";
begintchar(cc_sa_code,cb_na_width#,x_height#,0,0,ul#,0);
cb_na_form;
sketch subpath (0,4.7) of cb_na_p;
cc_clear; cc_transform(((subpath (0,4) of cb_na_p)..z97)); cc_whd(1,0);
endtchar; etest;

stest(ccha); telchar "consonant conjunct of ha";
begintchar(cc_ha_code,cb_va_width#+vmwidth#-3.5u#,x_height#,0,0,0,0);
cb_va_form;
z10 = point 3.6 of cb_va_p;
top z11 = (x10,x_height);
sketch subpath(0,3) of cb_va_p..z11;
barandhook_forma(11,vmwidth,5);
cc_clear; cc_transform((subpath(0,3) of cb_va_p..z11));
cc_transform(lit_cir_p);
cc_transform(barandhook_p); cc_whd(0,0);
pivot_message(x2*cc_scale);
endtchar; etest;

% ---------- start of ubayaksharas -----------

stest(uas); telchar "accent ardhasunna";
begintchar(u_ardhasunna_code,x_height#/2,x_height#,0,0,0,ur#);
top rt z2=(w,h); bot rt z1=(w,0); lft z3=(0,h/2);
sketch z1..z3..z2;
endtchar; etest;

stest(us); telchar "accent sunna";
begintchar(u_sunna_code,x_height#,x_height#,0,0,0,ur#);
top z2=(w/2,h);  bot z1=(x2,0);
sketch z1..z2..cycle;
endtchar; etest;

stest(uvi); telchar "accent visarga";
begintchar(u_visarga_code,2/5x_height#,x_height#,0,0,0,ur#);
top z2 = (w/2,h); bot z1 =(x2,3h/5);
path puvi;
puvi= z1..z2..cycle;
sketch puvi; sketch puvi shifted (0,-2h/3);
endtchar; etest;

stest(uav); telchar "accent ardhavisarga";
begintchar(u_ardhavisarga_code,2/5x_height#,x_height#,0,0,0,ur#);
path puav;
top z2 = (w/2,h); bot z1 =(x2,3h/5);
puav = subpath (0.25,1.75) of (z1..z2..cycle);
sketch puav;sketch puav  shifted (0,-2h/3);
endtchar; etest;

stest(ua); telchar "accent avagraha";
begintchar(u_avagraha_code,tfig_width#,x_height#,0,0,0,ur#);
top lft z1=(0,h);  lft z2=(0,h/4);   z3=(w/2,(y1+y2)/2);
bot lft z4=(0,0);  bot rt z5=(w,0);
sketch flex (z1,z3,z2,z4)& z4--z5;
endtchar; etest;

% ----------- end of ubhayaksharas ----------

% bars used for transliteration of vedic hymns

stest(buone); telchar "b udatta(one bar)";
begintchar(b_udatta1_code,u#,top_accent#+3uh#,0,0,0,0);
bot z1=(w/2,top_accent);  top z2=(x1,h);
sketch z1--z2;
pivot_message((w/2));
endtchar; etest;

stest(butwo); telchar "b udatta (two bars)";
begintchar(b_udatta2_code,3.5u#,top_accent#+3uh#,0,0,0,0);
bot z1=(w/4,top_accent);  top z2=(x1,h);
bot z3=(w/4+w/2,top_accent);   z4=z2+(w/2,0);
sketch z1--z2;  sketch z3-- z4;
pivot_message((w/2));
endtchar; etest;

stest(ba); telchar "b anudatta";
begintchar(b_anudatta_code,4u#,0,0,0,0,0);
% d is set later
top  lft z1=(0,-bot_accent);top rt z2=(w,-bot_accent);
sketch z1--z2;
d:=- (bot y1);
pivot_message((w/2));
endtchar;  etest;