summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/fonts/source/public/knitting/knit_grid_cables.mf
blob: e127626bd5ed6c86a11ab2a4f80dd262a0249413 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
% Date: 2010/08/10

picture symbolpic[];

beginchar(5,wd#,ht#,dp#); "Top and bottom outlines";
	pickup pensquare scaled gridwidth;
    if (fonttype = gridtype) or (fonttype = bothtype):
	draw (0,-d)--(w,-d); draw (0,h)--(w,h);
	fi 
endchar;

beginchar(6,0,ht#,dp#); "Vertical grid line";
	pickup pensquare scaled gridwidth;
	if (fonttype = gridtype) or (fonttype = bothtype):
	draw (0,-d)--(0,h);
	fi
endchar;

code := 127;

beginchar(".",incrwidth(0,0),ht#,dp#); "No stitch";
  fill (0.5(w-standardheight),-d+bottomgap) --
       (0.5(w-standardheight),h-topgap) --
       (0.5(w+standardheight),h-topgap) --
       (0.5(w+standardheight),-d+bottomgap) -- cycle;
  symbolpic0 := currentpicture;
  charbox; endchar;
beginchar(",",incrwidth(0,0),ht#,dp#); "Purl no stitch";
  currentpicture := symbolpic0;
  purlbox; endchar;
  
beginchar("-",wd#,ht#,dp#); "A knit stitch";
  charbox; endchar;
beginchar("=",wd#,ht#,dp#); "A purl stitch";
  purlbox; endchar;
    
% Cables

cablelinewidth#:=0.4pt#;
define_blacker_pixels(cablelinewidth);
pickup pencircle scaled cablelinewidth; cable_pen := savepen; 

% The one-letter cells
  
beginchar("p",wd#,ht#,dp#); "Purl cable background";
  purlbox; endchar;
beginchar("P",wd#,ht#,dp#); "Purl cable foreground";
  purlbox; endchar;
beginchar("k",wd#,ht#,dp#); "Knit cable background";
  charbox; endchar;
beginchar("K",wd#,ht#,dp#); "Knit cable foreground";
  charbox; endchar;
beginchar("g",wd#,ht#,dp#); "Purl cable background";
  purlbox; endchar;
beginchar("G",wd#,ht#,dp#); "Purl cable foreground";
  purlbox; endchar;
beginchar("c",wd#,ht#,dp#); "Knit cable background";
  charbox; endchar;
beginchar("C",wd#,ht#,dp#); "Knit cable foreground";
  charbox; endchar;
beginchar("d",wd#,ht#,dp#); "White knit cable background";
  charbox; endchar;
beginchar("D",wd#,ht#,dp#); "White knit cable foreground";
  charbox; endchar;
beginchar("n",wd#,ht#,dp#); "Odd knit cable background";
  charbox; endchar;
beginchar("N",wd#,ht#,dp#); "Odd knit cable foreground";
  charbox; endchar;
beginchar("e",wd#,ht#,dp#); "Odd twist";
  charbox; endchar;
beginchar("o",wd#,ht#,dp#); "Odd twist";
  charbox; endchar;
  
% Horizontal cables
  
horizcablegap# := 0.3 wd#;
define_pixels(horizcablegap);

beginchar("+",wd#,ht#,dp#); "Left end of a horizontal cable";
  charbox; 
  pickup pensquare scaled cablelinewidth;
  x1=x4=horizcablegap; x2=x3=w; bot y1=bot y2= -d+bottomgap; top y3=top y4=h-topgap;
  if (fonttype = gridtype) or (fonttype = bothtype):
  draw lft z3--rt z4; draw rt z1--lft z2; draw rt z4--rt z1;
  fi
  if fonttype = purltype:
 	fill (0,-d)--(w,-d)--z2--z1--z4--z3--(w,h)--(0,h)--cycle;
  fi 
  symbolpic0 := currentpicture;
endchar;

midhoriz := 20;
righthoriz := 21;
specialhoriz := ASCII"/";

beginchar(midhoriz,wd#,ht#,dp#); "Middle of a horizontal cable";  
 charbox; 
  pickup pensquare scaled cablelinewidth;
  x1=x4=0; x2=x3=w; bot y1=bot y2= -d+bottomgap; top y3=top y4=h-topgap;
  if (fonttype = gridtype) or (fonttype = bothtype):
  draw rt z1--lft z2; draw lft z3--rt z4;
  fi
 if fonttype = purltype:
 	fill z1--z2--(w,-d)--(0,-d)--cycle;
 	fill z4--z3--(w,h)--(0,h)--cycle;
 fi 
 endchar;
 
beginchar(specialhoriz,wd#,ht#,dp#); "Special horizontal cable";  
  charbox; 
  pickup pensquare scaled cablelinewidth;
  x1=x4=0; x2=x3=w; bot y1=bot y2= -d+bottomgap; top y3=top y4=h-topgap;
  
  x5=x6; x7=x8; x7-x5 = y3-y2; 0.5[x7,x5]=0.5w;
  y5=y7=-d; y6=y8=h;
  
  if (fonttype = gridtype) or (fonttype = bothtype):
  draw top z5--bot z6; draw top z7--bot z8;  
  draw rt z1--lft (x5,y2); 
  draw rt (x7,y2)--lft z2; 
  draw lft z3--rt(x7,y3); 
  draw lft(x5,y4)--rt z4;
  fi
  
 if fonttype = purltype:
  	fill (x1,y5)--z1--(x5,y1)--z5--cycle;
  	fill (x2,y7)--z2--(x7,y2)--z7--cycle;
   	fill (x3,y8)--z3--(x8,y3)--z8--cycle;
 	fill (x4,y6)--z4--(x6,y4)--z6--cycle;
 fi
 endchar;
 
 
beginchar(righthoriz,wd#,ht#,dp#); "Right end of a horizontal cable";  
  fliphoriz(symbolpic0)(currentpicture);  
  endchar;

ligtable "+": specialhoriz:
 	"+" |=: righthoriz;
ligtable righthoriz:
	"+" |=: righthoriz,
	specialhoriz =:| midhoriz,
	righthoriz =:| midhoriz;
	
% Setup for the standard cables
 
numeric cableleft[][][]; numeric cableright[][][];
numeric whitecableleft[][][]; numeric whitecableright[][][];
numeric twistleft[][]; numeric twistright[][];
numeric revcableleft[][]; numeric revcableright[][];
numeric topcableleft[][]; numeric topcableright[][];
numeric botcableleft[][]; numeric botcableright[][];

for sts = 2 upto 3:
    cableright[0][sts][0] := incr code;
    beginchar(code, (sts)*wd#,ht#,dp#); decimal sts&" cable background stitches";
      charbox; endchar;  
      
    cableleft[sts][0][0] := incr code;
    beginchar(code, (sts)*wd#,ht#,dp#); decimal sts&" cable foreground stitches";
      charbox; endchar;      
      
    revcableright[0][sts] := incr code;
    beginchar(code, (sts)*wd#,ht#,dp#); decimal sts&" twist background stitches";
      purlbox; endchar;       
      
    revcableleft[sts][0] := incr code;
    beginchar(code, (sts)*wd#,ht#,dp#); decimal sts&" twist foreground stitches";
      purlbox; endchar;  
endfor

% Draw the cables

if known slantlines: else: boolean slantlines; slantlines = false; fi

for backsts = 1 upto 3:
for frontsts = 1 upto 3: 
for midsts = 0 upto if frontsts = backsts: if frontsts < 3: frontsts else: 0 fi else: 0 fi:


cableleft[frontsts][backsts][midsts] = incr code;
cableright[frontsts][backsts][midsts] = incr code;
whitecableleft[frontsts][backsts][midsts] = incr code;
whitecableright[frontsts][backsts][midsts] = incr code;

if midsts = 0:
topcableleft[frontsts][backsts] = incr code;
topcableright[frontsts][backsts] = incr code;
botcableleft[frontsts][backsts] = incr code;
botcableright[frontsts][backsts] = incr code;
twistleft[frontsts][backsts] = incr code;
twistright[frontsts][backsts] = incr code;
revcableleft[frontsts][backsts] = incr code;
revcableright[frontsts][backsts] = incr code;
fi

symbolpic0 := nullpicture;
symbolpic1 := nullpicture;
symbolpic2 := nullpicture;

totsts := frontsts + backsts + midsts;

if (frontsts+backsts+midsts)*wd# < symbolmaxwd#:

beginchar(cableleft[frontsts][backsts][midsts],totsts * wd#,ht#,dp#); 
	% Cable/cable front
	"Cable " & decimal(frontsts) & " over " &decimal(backsts) & " over " &decimal(midsts);
	
	frontstroke := cablelinewidth * ((backsts+midsts)++1);
	backstroke := cablelinewidth * ((frontsts+midsts)++1)/2;

	charbox; % Have to do it here so the grid type fonts have stuff
	if (fonttype = gridtype) or (fonttype = bothtype):
	
	% Define top and bottom points
	if slantlines:
	for k=0 upto totsts:
	z.bot[k] = (k*wd,-d);
	z.top[k] = (k*wd,h);
	penpos.bot[k] (frontstroke, 0);
	penpos.top[k] (frontstroke, 0);
	endfor	
	else:
	z.top[0] = (0,h);
	z.top[frontsts] = (frontsts*wd,h);
	z.top[totsts] = (totsts*wd,h);
	z.bot[0] = (0,-d);
	z.bot[backsts] = (backsts*wd,-d);
	z.bot[totsts] = (totsts*wd,-d);
	if midsts > 0:
	z.bot[backsts+midsts] = ((backsts+midsts)*wd,-d);
	z.top[frontsts+midsts] = ((frontsts+midsts)*wd,h);
	fi
	penpos.bot[backsts+midsts] (frontstroke, 0);
	penpos.top[0] (frontstroke, 0);
	penpos.bot[totsts] (frontstroke, 0);
	penpos.top[frontsts] (frontstroke, 0);
	fi
	
	% Draw the lines on the front cable
	if slantlines:
	for k=1 upto frontsts-1:
	penstroke z.top[k]e -- z.bot[k+backsts+midsts]e;
	endfor
	fi
	
	% Draw the left and right lines of the front cable
	pair temp;
	temp = (0,whatever);
	temp = whatever[z.top0l,z.bot[backsts+midsts]l];

	fill z.top0r--z.bot[backsts+midsts]r -- z.bot[backsts+midsts]l--temp--z.top0--cycle;

	pair temp;
	temp = (w,whatever);
	temp = whatever[z.bot[totsts]r,z.top[frontsts]r];

	fill z.top[frontsts]r--z.top[frontsts]l--z.bot[totsts]l --z.bot[totsts]--temp--cycle;
	
	symbolpic1 := currentpicture;
	% Save this pic for twist front

	% Draw the back lines
	pair slip;
	slip = whatever[(-backstroke,0),(frontsts+midsts,1)+(-backstroke,0)];
	slip = whatever * (-backsts,1);	

	% Define some more points
	if slantlines:
	for k=0 upto backsts:
	z.ur[k] = whatever [z.top0,z.bot[backsts+midsts]];
	z.ur[k] = whatever [z.bot[k],z.top[frontsts+midsts+k]];
	z.ll[k] = whatever [z.bot[totsts],z.top[frontsts]];
	z.ll[k] = whatever [z.bot[k],z.top[frontsts+midsts+k]];
	endfor
	else:
	z.ur[0] = whatever [z.top0,z.bot[backsts+midsts]];
	z.ur[0] = whatever [z.bot0,z.top[frontsts+midsts]];
	z.ll[backsts] = whatever [z.bot[totsts],z.top[frontsts]];
	z.ll[backsts] = whatever [z.bot[backsts],z.top[totsts]];
	z.ur[backsts] = whatever [z.top0,z.bot[backsts+midsts]];
	z.ur[backsts] = whatever [z.bot[backsts],z.top[totsts]];
	z.ll[0] = whatever [z.bot[totsts],z.top[frontsts]];
	z.ll[0] = whatever [z.bot[0],z.top[frontsts+midsts]];
	fi
	
	% Top back lines
	fill z.top[totsts]+(-backstroke,0) -- z.top[totsts] -- z.top[totsts]+(0,-ypart(slip)) -- z.ll[backsts]-slip -- z.ll[backsts]+slip --cycle;

	if midsts > 0:
	fill z.top[frontsts+midsts]+(-backstroke,0) -- z.top[frontsts+midsts]+(backstroke,0) -- z.ll[0]-slip -- z.ll[0]+slip --cycle;
	fi

	if slantlines:
	for k=1 upto backsts-1:		
	fill z.top[frontsts+midsts+k]+(-backstroke,0) -- z.top[frontsts+midsts+k]+(backstroke,0) -- z.ll[k]-slip -- z.ll[k]+slip --cycle;
	endfor 
	fi
	
	symbolpic2 := currentpicture;
	
	% Bottom back lines
	fill z.bot[0]+(backstroke,0) -- z.bot[0] -- z.bot[0]+(0,ypart(slip)) -- z.ur[0]+slip -- z.ur[0]-slip --cycle;	

	if midsts > 0:
	fill z.bot[backsts]+(backstroke,0) -- z.bot[backsts]-(backstroke,0) -- z.ur[backsts]+slip -- z.ur[backsts]-slip --cycle;	
	fi

	if slantlines:
	for k=1 upto backsts-1:		
	fill z.bot[k]+(backstroke,0) -- z.bot[k]-(backstroke,0) -- z.ur[k]+slip -- z.ur[k]-slip --cycle;	
	endfor 
	fi

	fi

	if fonttype = purltype:
	z.L = whatever[(0,-d),((frontsts+midsts)*wd,h)];
	z.L = whatever[(0,h),((backsts+midsts)*wd,-d)];
	z.R = whatever[(w,-d),(w-(backsts+midsts)*wd,h)];
	z.R = whatever[(w,h),(w-(frontsts+midsts)*wd,-d)];
	
	if midsts = 0: else:
	z.top1 = (frontsts*wd,h);  z.top2 = ((frontsts+midsts)*wd,h);
	z.bot1 = (frontsts*wd,-d); z.bot2 = ((frontsts+midsts)*wd,-d);
	z.top3 = whatever[z.top1,(w,-d)];
	z.top3 = whatever[z.top2,(0,-d)];
	z.bot3 = whatever[z.bot1,(w,h)];
	z.bot3 = whatever[z.bot2,(0,h)];
	fill z.top1 -- z.top2 -- z.top3 -- cycle;
	fill z.bot1 -- z.bot2 -- z.bot3 -- cycle;
	fi
	
	fill (0,-d) -- z.L -- (0,h) --cycle;
	fill (w,-d) -- z.R -- (w,h) --cycle;
	fi
	symbolpic0 := currentpicture;
	endchar;
beginchar(cableright[frontsts][backsts][midsts],totsts * wd#,ht#,dp#); 
	"Cable right " & decimal(frontsts) & " over " &decimal(backsts);
	currentpicture := symbolpic0 reflectedabout ((w/2,0),(w/2,h));
	endchar;
beginchar(whitecableleft[frontsts][backsts][midsts],totsts * wd#,ht#,dp#); 
	"White cable " & decimal(frontsts) & " over " &decimal(backsts);	
	if fonttype <> purltype: 	currentpicture := symbolpic0; fi
	endchar;	
beginchar(whitecableright[frontsts][backsts][midsts],totsts * wd#,ht#,dp#); 
	"White cable " & decimal(frontsts) & " over " &decimal(backsts);	
	if fonttype <> purltype: 	currentpicture := symbolpic0 reflectedabout ((w/2,0),(w/2,h)); fi
	endchar;
	
if midsts = 0:

beginchar(twistleft[frontsts][backsts],totsts * wd#,ht#,dp#); 
	% Twist/twist front
	"Twist " & decimal(frontsts) & " over " &decimal(backsts);
	charbox;
	if fonttype <> purltype: currentpicture := symbolpic1;
	else:
	fill (0,h)--(wd*backsts,-d)--(0,-d)--cycle; % Bottom triangle
	fill (w,-d)--(wd*frontsts,h)--(w,h)--cycle;	% Top triangle
	fi
	symbolpic1 := currentpicture;
	endchar;
beginchar(twistright[frontsts][backsts],totsts * wd#,ht#,dp#); 
	"Twist " & decimal(frontsts) & " over " &decimal(backsts);
	currentpicture := symbolpic1 reflectedabout ((w/2,0),(w/2,h)); 
	endchar;
	
beginchar(topcableleft[frontsts][backsts],totsts * wd#,ht#,dp#); 
	% Twist/twist front
	"Cable " & decimal(frontsts) & " over " &decimal(backsts);
	z.R = whatever[(w,-d),(w-(backsts+midsts)*wd,h)];
	z.R = whatever[(w,h),(w-(frontsts+midsts)*wd,-d)];
	charbox;
	if fonttype <> purltype: currentpicture := symbolpic2;
	else:
	fill (0,h)--(wd*backsts,-d)--(0,-d)--cycle; % Bottom left triangle
	fill (w,-d) -- z.R -- (w,h) --cycle; % Right triangle
	fi
	symbolpic2 := currentpicture;
	endchar;
beginchar(topcableright[frontsts][backsts],totsts * wd#,ht#,dp#); 
	"Cable " & decimal(frontsts) & " over " &decimal(backsts);
	currentpicture := symbolpic2 reflectedabout ((w/2,0),(w/2,h)); 
	endchar;
beginchar(botcableleft[frontsts][backsts],totsts * wd#,ht#,dp#); 
	"Cable " & decimal(frontsts) & " over " &decimal(backsts);
	currentpicture := symbolpic2 rotatedaround ((w/2,(h-d)/2),180); 
	endchar;
beginchar(botcableright[frontsts][backsts],totsts * wd#,ht#,dp#); 
	"Cable " & decimal(frontsts) & " over " &decimal(backsts);
	currentpicture := symbolpic2 reflectedabout ((0,(h-d)/2),(w,(h-d)/2)); 
	endchar;
		
beginchar(revcableleft[frontsts][backsts],totsts * wd#,ht#,dp#); 
	% Reverse cable/twist back
	"Reverse cable left " & decimal(frontsts) & " over " &decimal(backsts);
	if fonttype <> purltype: 
	currentpicture := symbolpic0;
	else: purlbox; fi
	endchar;
beginchar(revcableright[frontsts][backsts],totsts * wd#,ht#,dp#); 
	"Reverse cable " & decimal(frontsts) & " over " &decimal(backsts);
	if fonttype <> purltype: 
	currentpicture := symbolpic0 reflectedabout ((w/2,0),(w/2,h));
	else: purlbox; fi
	endchar;
fi

else:

beginchar(cableleft[frontsts][backsts][midsts],0pt#,ht#,dp#); endchar;
beginchar(cableright[frontsts][backsts][midsts],0pt#,ht#,dp#); endchar;
beginchar(whitecableleft[frontsts][backsts][midsts],0pt#,ht#,dp#); endchar;
beginchar(whitecableright[frontsts][backsts][midsts],0pt#,ht#,dp#); endchar;

if midsts = 0:
beginchar(twistleft[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(twistright[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(topcableleft[frontsts][backsts],0pt#,ht#,dp#);	endchar;
beginchar(topcableright[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(botcableleft[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(botcableright[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(revcableleft[frontsts][backsts],0pt#,ht#,dp#); 	endchar;
beginchar(revcableright[frontsts][backsts],0pt#,ht#,dp#);	endchar;

fi

fi
	
endfor endfor endfor

% Ligatures to let kkKK turn into a cable

if fonttype <> counttype:

cableright[0][1][0] := ASCII"k";
cableleft[1][0][0] := ASCII"K";
revcableright[0][1] 	:= ASCII"p";
revcableleft[1][0] := ASCII"P";

ligtable "c": 
	"k" =: cableright[0][1+1][0],
	"c" =: cableright[0][1+1][0], 
	"p" =: cableright[1][1][1],
	"K" =: cableright[1][1][0],
 	"D" =: whitecableright[1][1][0],
 	"N" =: topcableright[1][1];
ligtable "C": 
	"K" =: cableleft[1+1][0][0],
	"C" =: cableleft[1+1][0][0], 
	"p" =: twistleft[1][1],
	"k" =: cableleft[1][1][0],
	"d" =: whitecableleft[1][1][0],
	"n" =: topcableleft[1][1],
	"e" =: botcableleft[1][1],
	"o" =: botcableleft[1][1];
 ligtable "g": 
	"p" =: revcableright[0][1+1], 
	"g" =: revcableright[0][1+1], 
	"K" =: twistright[1][1],
	"P" =: revcableright[1][1],
	"N" =: botcableright[1][1];
 ligtable "G": 
	"P" =: revcableleft[1+1][0],
	"G" =: revcableleft[1+1][0],
	"p" =: revcableleft[1][1];

for sts = 1 upto 3:
 ligtable cableright[0][sts][0]: 
	if sts < 3: 
	"k" =: cableright[0][sts+1][0],
	"c" =: cableright[0][sts+1][0], 
	"p" =: cableright[sts][sts][1],
	fi
	"K" =: cableright[1][sts][0],
	"D" =: whitecableright[1][sts][0],
	"N" =: topcableright[1][sts];
 ligtable cableleft[sts][0][0]: 
	if sts < 3: 
	"K" =: cableleft[sts+1][0][0],
	"C" =: cableleft[sts+1][0][0], 
	fi
	"p" =: twistleft[sts][1],
	"k" =: cableleft[sts][1][0],
	"d" =: whitecableleft[sts][1][0],
	"n" =: topcableleft[sts][1],
	"e" =: botcableleft[sts][1],
	"o" =: botcableleft[sts][1];
 ligtable revcableright[0][sts]: 
	if sts < 3: 
	"p" =: revcableright[0][sts+1], 
	"g" =: revcableright[0][sts+1], 
	fi
	"K" =: twistright[1][sts],
	"P" =: revcableright[1][sts],
	"N" =: botcableright[1][sts];
 ligtable revcableleft[sts][0]: 
	if sts < 3: 
	"P" =: revcableleft[sts+1][0],
	"G" =: revcableleft[sts+1][0],
	fi
	"p" =: revcableleft[sts][1];
	
endfor

for sts = 1 upto 2:
 ligtable cableleft[sts][sts][1]: 
	if sts > 1: "p" =: cableleft[sts][sts][2], fi
	"k" =: cableleft[sts][sts][1],
	"d" =: whitecableleft[sts][sts][1];
 ligtable cableright[sts][sts][1]: 
	if sts > 1: "p" =: cableright[sts][sts][2], fi
	"K" =: cableright[sts][sts][1],
	"D" =: whitecableright[sts][sts][1];
 ligtable whitecableleft[sts][sts][1]: 
	"d" =: whitecableleft[sts][sts][1];
 ligtable whitecableright[sts][sts][1]: 
	"D" =: whitecableright[sts][sts][1];
endfor

if 6wd# < symbolmaxwd#:
 ligtable cableleft[2][2][2]: 
	"k" =: cableleft[2][2][2],
	"d" =: whitecableleft[2][2][2];
 ligtable cableright[2][2][2]: 
	"K" =: cableright[2][2][2],
	"D" =: whitecableright[2][2][2]; 
 ligtable whitecableleft[2][2][2]: 
	"d" =: whitecableleft[2][2][2];
 ligtable whitecableright[2][2][2]: 
	"D" =: whitecableright[2][2][2];
fi
	
for backsts = 1 upto 3:
for frontsts = 1 upto 3:

 if frontsts < 3:
 ligtable cableright[frontsts][backsts][0]: 
	"K" =: cableright[frontsts+1][backsts][0],
	"N" =: topcableright[frontsts+1][backsts],
	"D" =: whitecableright[frontsts+1][backsts][0];
 ligtable whitecableright[frontsts][backsts][0]: 
	"D" =: whitecableright[frontsts+1][backsts][0];
 ligtable topcableright[frontsts][backsts]: 
	"N" =: topcableright[frontsts+1][backsts];
 ligtable botcableright[frontsts][backsts]: 
	"N" =: botcableright[frontsts+1][backsts];
 ligtable twistright[frontsts][backsts]: 
	"K" =: twistright[frontsts+1][backsts],
	"N" =: botcableright[frontsts+1][backsts];
 ligtable revcableright[frontsts][backsts]: 
	"P" =: revcableright[frontsts+1][backsts];
  fi

 if backsts < 3:
 ligtable cableleft[frontsts][backsts][0]: 
	"k" =: cableleft[frontsts][backsts+1][0],
	"n" =: topcableleft[frontsts][backsts+1],
	"d" =: whitecableleft[frontsts][backsts+1][0];
 ligtable whitecableleft[frontsts][backsts][0]: 
	"d" =: whitecableleft[frontsts][backsts+1][0];
 ligtable topcableleft[frontsts][backsts]: 
	"n" =: topcableleft[frontsts][backsts+1];
 ligtable botcableleft[frontsts][backsts]: 
	"e" =: botcableleft[frontsts][backsts+1],
	"o" =: botcableleft[frontsts][backsts+1];
 ligtable twistleft[frontsts][backsts]: 
    if frontsts < 3: if backsts <= frontsts:
	"k" =: cableleft[frontsts][frontsts][backsts],
	"d" =: whitecableleft[frontsts][frontsts][backsts],
    fi fi
	"e" =: botcableleft[frontsts][backsts+1],
	"o" =: botcableleft[frontsts][backsts+1],
	"p" =: twistleft[frontsts][backsts+1];
 ligtable revcableleft[frontsts][backsts]: 
	"p" =: revcableleft[frontsts][backsts+1];
  fi  

endfor
endfor

fi