% 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 several macros. These are used for setting
% up the environment and character generation. Before you change
% anything in this file you should be very clear about the impact
% of the change.
%
% when testing is false all symbols in the font are
% generated automatically else when testing is true
% only selected symbols will be generated.
if unknown testing:boolean testing; testing:=false; fi
showstopping := 1; % for debugging only
let telchar=\;
let generate=input;
let sketch=draw;
let pos=penpos;
let stop=bye;
string tl_symname,tl_stra,tl_strb,tl_strc,tl_strw,tl_strx,tl_stry;
% contains the name of the symbol being created
tl_symname:=""; % used for creating substitute commands on log file
tl_stra:="OFFSETA{"; tl_strb:="OFFSETB{"; tl_strc:="OFFSETC{";
tl_strw:="CODE{";
tl_strx:="\def\";tl_stry:="}%";
if testing:
%To test different characters use following definitions of
% stest and etest.
def stest (text s) =
quote def s =
enddef;
let etest=enddef;
else:
%To generate all the characters use following definitions of
% stest and etest.
def stest (text s) =
tl_symname := str s;% symbol name - used in various messages
enddef;
let etest=;;
fi;
% We should be very careful about implications of currenttransform
% (particularly 'slanted' transform). When a path is drawn/filled
% currenttransform is applied. When a transform is applied to
% currentpicture, the transform is really applied to slanted (or
% whatever currenttransform is) path.
def font_setup =
let adjust_fit = normal_adjust_fit;
currenttransform := currenttransform slanted slant;
define_pixels(u,v,uh,asc_height,des_depth,x_height);
define_pixels(pen_width,ul,ur,em_width);
define_pixels(bot_depth,top_height);
define_pixels(fig_height,tfig_height,tfig_width);
define_pixels(ascunit,vmwidth);
define_pixels(top_accent,bot_accent);
define_pixels(bot_cc_ceiling,bot_cc_floor,bot_cc_width,ccwidth);
define_pixels(c_height,w_height,j_height);
define_pixels(asc_height1,asc_height2);
define_pixels(dot_radius,wedge_height,wedge_depth);
define_pixels(half_plus_width,sc_height);
%print titles if generating font
if unknown offsets_only:
tracingtitles:=1;
fi;
enddef;
newinternal l,r; %adjustment to spacing
def normal_adjust_fit(expr left_adjustment,right_adjustment) =
l := -hround(left_adjustment*hppp);
interim xoffset := -l;
charwd := charwd + left_adjustment + right_adjustment;
r := l+hround(charwd*hppp) ;
w := r - hround(right_adjustment*hppp) ;
enddef;
def makebox(text rule) =
for y=0,asc_height,-des_depth,x_height,-bot_depth,
top_height,w_height,c_height,
j_height: rule((l,y)t_,(r,y)t_); % horizontal rules
endfor;
rule((0,h),(r+pen_width,h)); rule((0,-d),(r+pen_width,-d));%height,depth markers
for x=l,r:rule((x,-bot_depth)t_,(x,top_height)t_); % vertical
endfor;
for x=u*(1+floor(l/u)) step u until r-1:
rule((x,-bot_depth)t_,(x,top_height)t_);
endfor; % vertical lines at each u
if charic <> 0:
rule((r+charic*pt,h.o_),(r+charic*pt,.5h.o_));
fi % italic correction
enddef;
def maketicks(text rule) =
for y=0,h.o_,-d.o_;
rule((l,y),(l+10,y));rule((r-10,y),(r,y)); % horizontals
endfor
for x=l,r:
rule((x,10-d.o_),(x,-d.o_));
rule((x,h.o_-10),(x,h.o_)); % verticals
endfor
if charic <> 0:
rule((r+charic*pt,h.o_-10),(r+charic*pt,h.o_)); % italic corr
fi
enddef;
def endtchar =
charwd:=w/hppp; charht:= h/vppp; chardp:= d/vppp;
adjust_fit(l_s,r_s);
penlabels(range 1 thru 20);
message "";
% If any special effects are needed then those should be
% defined as special_effects macro.
if known special_effects: special_effects; fi;
endchar;
enddef;
% pivot_message macro is used to print offsets to certain points
% in the symbol being generated. These offsets are used by syllable
% building macros to allign vowel modifiers/consonant conjuncts.
% Unlike in english where all symbols stand alone, in Telugu
% various symbols in the font combine to form text.
% For consonant bases two/three offsets are identified. One is used to place
% vowel modifiers and the other is used to place consonant conjuncts(excluding
% those that appear on side). Third offset is used in attaching vowel modifiers
% in some special cases. Offsets have suffixes A,B and C.
% Vowel modifiers, accents and consonant
% conjuncts that appear above/below base consonant indicate one offset value.
% Same macro works in all cases.
% The messages are in the form of TeX macros.
% The log file contains TeX macros mixed with other messages. Use
% some pattern matching program like grep to eliminate all lines containing
% not begining with a \ sign. Name this file tloffsets.
% grep '^\\' xxxxx.log>tloffsets.tex
% The offsets are in em units. So the offsets would be same for any designsize
% and pen width combination.
% Print the offsets only when offsets are being generated.
if unknown offsets_only: % do not print offsets
def pivot_message (text t) =
enddef;
else: %print offsets
def pivot_message (text t) =
numeric count,piv[],index;
% count indicates the number of arguments
count:=0;
for index=t: count:=count+1; piv[count]:=index; endfor;
if count=1:
message tl_strx&tl_symname&tl_stra&decimal((piv[1]+left_space)/em_width)&tl_stry;
elseif count=2:
message tl_strx&tl_symname&tl_stra&decimal((piv[1]+left_space)/em_width)&tl_stry;
message tl_strx&tl_symname&tl_strb&decimal((piv[2]+left_space)/em_width)&tl_stry;
else:
message tl_strx&tl_symname&tl_stra&decimal((piv[1]+left_space)/em_width)&tl_stry;
message tl_strx&tl_symname&tl_strb&decimal((piv[2]+left_space)/em_width)&tl_stry;
message tl_strx&tl_symname&tl_strc&decimal((piv[3]+left_space)/em_width)&tl_stry;
def vm_a_form (suffix $) =
top lft z$a=(x$-2/5vm_a_width,asc_height1);
top rt z$b=(x$+3/5vm_a_width,asc_height);
z$c = z$;
sketch z$a..tension 6..z$c..tension 16..z$b;
penlabels($a,$b,$c);
enddef;
def vm_e_form =
lft z1 = (0,x_height+1.2ascunit);
top z2 = (1/2vm_e_width,x_height);
rt z3 = (vm_e_width,x_height+2ascunit);
lft z5 = (0,x_height+3ascunit);
z6 = (1/2vm_e_width,y5);
top z7=(1/2vm_e_width,vm_e_height1+ascunit);
sketch subpath (0.4,1) of z1{down}..{right}z2..z3..z7..z5..z6;
% hook can be attached at z7
enddef;
def vm_e_form_a (expr xcoord) =
% used for vowel modifier e for some consonants (eg. khe, che, ne etc)
% 999 was chosen arbitrarily. we needed something not used elsewhere!
% same suffix should be used by vm_ee_form_a.
top z999=(xcoord,vm_e_height1); rt z999i=((lft x999)-1.8u,(y999+y999j)/2);
top z999j=(x999,asc_height1);
path vm_e_pa;
vm_e_pa=z999..z999i..z999j..cycle; h:= (top y999)+pen_width;
penlabels(z999,z999i,z999j);
enddef;
def vm_ee_form_a (expr xcoord) =
% used for vowel modifier ee for some consonants (eg. khee, chee, nee etc)
% 999 was chosen arbitrarily. we needed something not used elsewhere!
% same suffix should be used by vm_e_form_a.
vm_e_form_a(xcoord); vm_hook_form(999,3);
enddef;
% b---------c--------------d
% | |_|
% $------a
def vm_au_form (suffix $)(expr bar_width) = % see the above diagram
numeric na;
top z$e=z$;
z$a = (x$e+2/10(bar_width-u),y$e);
z1000 = (x$-u,asc_height2);
% 1000 was chosen arbitrarily
% we needed some suffix not used by any user of
% this macro
barandhook_form(1000,bar_width,5);
z$d=z1000a;
%next two statements solve for c
x$c = x$a;
z$c = whatever[z1000,z$d];
na:=x$c+(x1000a-x$c)/3; % used for alligning pa,pha,sha..
sketch z$e--z$a{right}..{left}z$c;
penlabels($a,$b,$c,$d,$e,1000);
enddef;
def cc_transform(text t) =
% used to obtain consonant conjuncts for some consonants and vowels lo&loo
path cc_transformed_path;
cc_transformed_path = t scaled cc_scale
shifted (0,-bot_accent-(x_height*cc_scale));
sketch cc_transformed_path;
enddef;
def cc_f_transform(text t) =
% used to obtain consonant conjuncts for some consonants and vowels lo&loo
fill t scaled cc_scale
shifted (0,-bot_accent-(x_height*cc_scale));
enddef;
def cc_whd (expr hh,dd) =
%this macro sets w, h and d for accents that appear below baseline.
% for some consonant conjuncts that result from transforming
% consonant bases the height is not zero (eg. cha, ba ,pa etc)
% for such symbols hh should be 1 and for others hh should be 0.
% Some consonant bases have wedges that hang below base line (eg. bha, pha
% ddha etc. ). For these dd should be 1 and for others dd should be 0.
%
%When a picture is scaled, what really happens is the componant paths
% are scaled and the picture is redrawn. Hence we need to adjust w,h and d.
% Still consonant conjunct for nya needs special care( for d).
w:=w*cc_scale-pen_width*cc_scale+pen_width;;
h:=hh*x_height;
d:=bot_accent+((x_height+(dd*wedge_depth))*cc_scale)+dd*bot_spill;
% (x,y) slanted s shifted (a,b) is (x+sy+a,y+b) whereas
% (x,y) shifted (a,b) slanted s is (x+sy+a+ bs,y+b). Hence we
% need to add the correction 'bs'. 'bs' is -bot_spill*slant
currentpicture:=currentpicture shifted
(-left_spill+((-bot_spill)*slant),-bot_spill);
enddef;