From af3bb61d6d9e87dd56438ba72421ed901b8b2030 Mon Sep 17 00:00:00 2001 From: ivan Date: Tue, 17 Aug 2010 16:45:57 +0200 Subject: [PATCH] Two-years-after revision. New `vertical' version. We start to move towards coding standards compliance. We update script to current in-house coding style. Most of this had been written the night before the final examination at the building of the Karel Doormanstraat. Starting from the original `variableKerning' script, it's really simple to make the characters move vertically. We implement this in a new version of the script. Possibilities for the future: + use POD for manual.txt + make h + v pipe-friendly (page 82 of llama, ed. 5) + ... --- h.pl | 57 +++++++++++++++++++++++++ manual.txt | 52 ++++++++++++----------- 7tmpslave9printfunction.txt => sections_7,_9 | 0 v.pl | 57 +++++++++++++++++++++++++ variableKerning.pl | 62 ---------------------------- 5 files changed, 143 insertions(+), 85 deletions(-) create mode 100755 h.pl rewrite manual.txt (71%) rename 7tmpslave9printfunction.txt => sections_7,_9 (100%) create mode 100755 v.pl delete mode 100644 variableKerning.pl diff --git a/h.pl b/h.pl new file mode 100755 index 0000000..f02f759 --- /dev/null +++ b/h.pl @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +# code as grid. only the grid saves! +# there may already be a little groff markup in this file +my $textFile = "sections_7,_9" unless $ARGV[0]; +$textFile = $ARGV[0] unless not $ARGV[0]; + +# this returns the text as an array of arrays, alllinesAllleters ;) +my @textAoA = &parseText($textFile); +&horizontalMotionMarkUp(\@textAoA, 20); + +# takes as an argument the file to be parsed, so &parseText("file") +sub parseText { + my @alllinesAllletters; + my @currentLineLetters; + open(TEXT, "<", $_[0]) || die "can't open $_[0] : $!"; + + while () { + chomp; + @currentLineLetters = split //, $_; + push @alllinesAllletters, [@currentLineLetters]; + } + @alllinesAllletters; +} + +sub horizontalMotionMarkUp { + my @textLetters = @{$_[0]}; + my $localMotionRange = $_[1]; + my $aLetter; + my $aLineRef; + my $anAmount; + my $markedUpLetter; + + # this is the file that we will build + my $newFile = $textFile . "Typeset"; + open(TYPESET, ">", $newFile) || die "can't open $newFile : $!"; + + # for evry letter... + foreach $aLineRef (@textLetters) { + if (@$aLineRef == 0) {} + # the script recognizes lines that begin with a `.' or a `\' + elsif (@$aLineRef[0] eq "." || @$aLineRef[0] eq "\\") { + foreach $aLetter (@{$aLineRef}) { + print TYPESET $aLetter; + } + } else { + foreach $aLetter (@{$aLineRef}) { + $anAmount = int(rand($localMotionRange)); + $markedUpLetter = "\\h'" . $anAmount . "M'$aLetter\\h'-" . $anAmount . "M'"; + print TYPESET $markedUpLetter; + } + } + print TYPESET "\n"; + } +} diff --git a/manual.txt b/manual.txt dissimilarity index 71% index ba7bd8f..2b376d3 100644 --- a/manual.txt +++ b/manual.txt @@ -1,23 +1,29 @@ -variable kerning -======== ======= -this script takes a text file with a little groff mark-up and adds the mark-up -necessary for it to be typeset like the zines. for a precise description of -`little' turn to line 47 of `variableKerning.pl'. the script recognizes lines -that begin with a `.' or a `\' as groff mark-up. - -the name of the file to be processed is determined by the $textForTypesetting -variable. use the name of the file minus the .txt extension. - -directory listing -========= ======= -7tmpslave9printfunction.txt some sample text -manual.txt this file -variableKerning.pl the script - -script -====== -if the name specified by $textForTypesetting is `something', the script -expects that there's a file with the name `something.txt' in the current -directory, and it produces a file called `somethingTypeset.txt'. the sample -file is meant to be typeset with landscape orientation: - groff -Tps -P-pa4 -P-l 7tmpslave9printfunctionTypeset.txt > sample.ps +variable kerning +======== ======= +this script takes a text file with a little groff mark-up and adds the mark-up +necessary for it to be typeset like the zines. for a precise description of +`little' turn to the decision structure inside the main loop of the MarkUp +subroutine. the script recognizes lines that begin with a `.' or a `\' as +groff mark-up. + +the script takes in the name of the file to be processed as its sole argument. + +directory listing +========= ======= +sections_7,_9 some sample text +manual.txt this file +h.pl the script + +script +====== +if the name specified by $textFile is `something', the script will produce a +file called `somethingTypeset'. the sample file is meant to be typeset with +landscape orientation: + groff -Tps -P-pa4 -P-l sections_7,_9Typeset > sections_7,_9.ps + +bonus track +===== ===== +making the characters move up and down is a one-character change. this is the +only major difference between h.pl and v.pl: + "\\h'" . $anAmount . "M'$aLetter\\h'-" . $anAmount . "M'"; + "\\v'" . $anAmount . "M'$aLetter\\v'-" . $anAmount . "M'"; diff --git a/7tmpslave9printfunction.txt b/sections_7,_9 similarity index 100% rename from 7tmpslave9printfunction.txt rename to sections_7,_9 diff --git a/v.pl b/v.pl new file mode 100755 index 0000000..412efeb --- /dev/null +++ b/v.pl @@ -0,0 +1,57 @@ +#!/usr/bin/env perl +use strict; +use warnings; + +# code as grid. only the grid saves! +# there may already be a little groff markup in this file +my $textFile = "sections_7,_9" unless $ARGV[0]; +$textFile = $ARGV[0] unless not $ARGV[0]; + +# this returns the text as an array of arrays, alllinesAllleters ;) +my @textAoA = &parseText($textFile); +&verticalMotionMarkUp(\@textAoA, 10); + +# takes as an argument the file to be parsed, so &parseText("file") +sub parseText { + my @alllinesAllletters; + my @currentLineLetters; + open(TEXT, "<", $_[0]) || die "can't open $_[0] : $!"; + + while () { + chomp; + @currentLineLetters = split //, $_; + push @alllinesAllletters, [@currentLineLetters]; + } + @alllinesAllletters; +} + +sub verticalMotionMarkUp { + my @textLetters = @{$_[0]}; + my $localMotionRange = $_[1]; + my $aLetter; + my $aLineRef; + my $anAmount; + my $markedUpLetter; + + # this is the file that we will build + my $newFile = $textFile . "Typeset"; + open(TYPESET, ">", $newFile) || die "can't open $newFile : $!"; + + # for evry letter... + foreach $aLineRef (@textLetters) { + if (@$aLineRef == 0) {} + # the script recognizes lines that begin with a `.' or a `\' + elsif (@$aLineRef[0] eq "." || @$aLineRef[0] eq "\\") { + foreach $aLetter (@{$aLineRef}) { + print TYPESET $aLetter; + } + } else { + foreach $aLetter (@{$aLineRef}) { + $anAmount = int(rand($localMotionRange)); + $markedUpLetter = "\\v'" . $anAmount . "M'$aLetter\\v'-" . $anAmount . "M'"; + print TYPESET $markedUpLetter; + } + } + print TYPESET "\n"; + } +} diff --git a/variableKerning.pl b/variableKerning.pl deleted file mode 100644 index 1c4c25d..0000000 --- a/variableKerning.pl +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env perl -use strict; - -# code as grid. only the grid saves! -# there may already be a little groff markup in this file -my $textForTypesetting = "7tmpslave9printfunction"; - -# this returns the text as an array of arrays, alllinesAllleters ;) -my @ohmyAoA = &parseText("$textForTypesetting.txt"); -# this subroutine's name is no good. it should be more like makegroff -&makePS(@ohmyAoA); - -# takes as an argument the file to be parsed, so &parseText("file.txt") -sub parseText { - my @alllinesAllletters; - my @currentLineLetters; - my $TEXTlinesCounter = 0; - open TEXT, "< $_[0]"; - - # parse text - while () { - chomp; - @currentLineLetters = split //, $_; - $alllinesAllletters[$TEXTlinesCounter] = [@currentLineLetters]; - ++$TEXTlinesCounter; - } - @alllinesAllletters; -} - -sub makePS { - my @linesletters = @_; - my $thisLineSize; - my $aLetter; - my $referLine; - my $anAmount; - my $goodbye; - - # this is the file that we will build - my $newFile = $textForTypesetting . "Typeset.txt"; - open TYPESET, "> $newFile"; - - # originally, at this point a header was inserted - - # for evry letter... - foreach $referLine (@linesletters) { - $thisLineSize = @$referLine - 1; - # this decision structure allows there to already be somemarkup in the file - if (@$referLine[0] eq "." || @$referLine[0] eq "\\") { - foreach $aLetter (0..$thisLineSize) { - print TYPESET @$referLine[$aLetter]; - } - } - else { - foreach $aLetter (0..$thisLineSize) { - $anAmount = int(rand(20)); - $goodbye = "\\h'" . $anAmount . "M'@$referLine[$aLetter]\\h'-" . $anAmount . "M'"; - print TYPESET $goodbye; - } - } - print TYPESET "\n"; - } -} -- 2.11.4.GIT