Initial commit.
[p_s.git] / variableKerning.pl
blob1c4c25d33909b3689daf5ca4e455b266199d4dab
1 #!/usr/bin/env perl
2 use strict;
4 # code as grid. only the grid saves!
5 # there may already be a little groff markup in this file
6 my $textForTypesetting = "7tmpslave9printfunction";
8 # this returns the text as an array of arrays, alllinesAllleters ;)
9 my @ohmyAoA = &parseText("$textForTypesetting.txt");
10 # this subroutine's name is no good. it should be more like makegroff
11 &makePS(@ohmyAoA);
13 # takes as an argument the file to be parsed, so &parseText("file.txt")
14 sub parseText {
15 my @alllinesAllletters;
16 my @currentLineLetters;
17 my $TEXTlinesCounter = 0;
18 open TEXT, "< $_[0]";
20 # parse text
21 while (<TEXT>) {
22 chomp;
23 @currentLineLetters = split //, $_;
24 $alllinesAllletters[$TEXTlinesCounter] = [@currentLineLetters];
25 ++$TEXTlinesCounter;
27 @alllinesAllletters;
30 sub makePS {
31 my @linesletters = @_;
32 my $thisLineSize;
33 my $aLetter;
34 my $referLine;
35 my $anAmount;
36 my $goodbye;
38 # this is the file that we will build
39 my $newFile = $textForTypesetting . "Typeset.txt";
40 open TYPESET, "> $newFile";
42 # originally, at this point a header was inserted
44 # for evry letter...
45 foreach $referLine (@linesletters) {
46 $thisLineSize = @$referLine - 1;
47 # this decision structure allows there to already be somemarkup in the file
48 if (@$referLine[0] eq "." || @$referLine[0] eq "\\") {
49 foreach $aLetter (0..$thisLineSize) {
50 print TYPESET @$referLine[$aLetter];
53 else {
54 foreach $aLetter (0..$thisLineSize) {
55 $anAmount = int(rand(20));
56 $goodbye = "\\h'" . $anAmount . "M'@$referLine[$aLetter]\\h'-" . $anAmount . "M'";
57 print TYPESET $goodbye;
60 print TYPESET "\n";