summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2013-02-26 00:29:48 +0000
committerKarl Berry <karl@freefriends.org>2013-02-26 00:29:48 +0000
commitd0fb875485e53d004d0a28def85d2df3c0744295 (patch)
treeead09dcd98050ff2ab7997caf1c9091fc28a4621 /Master/texmf-dist/tex/luatex
parent0a17a835648c35c1544427e3729a351d0de3887a (diff)
chickenize (25feb13)
git-svn-id: svn://tug.org/texlive/trunk@29232 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/luatex')
-rw-r--r--Master/texmf-dist/tex/luatex/chickenize/chickenize.lua109
-rw-r--r--Master/texmf-dist/tex/luatex/chickenize/chickenize.sty2
-rw-r--r--Master/texmf-dist/tex/luatex/chickenize/chickenize.tex23
3 files changed, 125 insertions, 9 deletions
diff --git a/Master/texmf-dist/tex/luatex/chickenize/chickenize.lua b/Master/texmf-dist/tex/luatex/chickenize/chickenize.lua
index 18337fcffb8..7a3dda51cb3 100644
--- a/Master/texmf-dist/tex/luatex/chickenize/chickenize.lua
+++ b/Master/texmf-dist/tex/luatex/chickenize/chickenize.lua
@@ -136,7 +136,66 @@ nicetext = function()
texiowrite_nl(separator)
end
end
-
+boustrophedon = function(head)
+ rot = node.new(8,8)
+ rot2 = node.new(8,8)
+ odd = true
+ for line in node.traverse_id(0,head) do
+ if odd == false then
+ w = line.width/65536*0.99625 -- empirical correction factor (?)
+ rot.data = "-1 0 0 1 "..w.." 0 cm"
+ rot2.data = "-1 0 0 1 "..-w.." 0 cm"
+ line.head = node.insert_before(line.head,line.head,node.copy(rot))
+ node.insert_after(line.head,node.tail(line.head),node.copy(rot2))
+ odd = true
+ else
+ odd = false
+ end
+ end
+ return head
+end
+boustrophedon_glyphs = function(head)
+ odd = false
+ rot = nodenew(8,8)
+ rot2 = nodenew(8,8)
+ for line in nodetraverseid(0,head) do
+ if odd==true then
+ line.dir = "TRT"
+ for g in nodetraverseid(37,line.head) do
+ w = -g.width/65536*0.99625
+ rot.data = "-1 0 0 1 " .. w .." 0 cm"
+ rot2.data = "-1 0 0 1 " .. -w .." 0 cm"
+ line.head = node.insert_before(line.head,g,node.copy(rot))
+ node.insert_after(line.head,g,node.copy(rot2))
+ end
+ odd = false
+ else
+ line.dir = "TLT"
+ odd = true
+ end
+ end
+ return head
+end
+boustrophedon_inverse = function(head)
+ rot = node.new(8,8)
+ rot2 = node.new(8,8)
+ odd = true
+ for line in node.traverse_id(0,head) do
+ if odd == false then
+texio.write_nl(line.height)
+ w = line.width/65536*0.99625 -- empirical correction factor (?)
+ h = line.height/65536*0.99625
+ rot.data = "-1 0 0 -1 "..w.." "..h.." cm"
+ rot2.data = "-1 0 0 -1 "..-w.." "..0.5*h.." cm"
+ line.head = node.insert_before(line.head,line.head,node.copy(rot))
+ node.insert_after(line.head,node.tail(line.head),node.copy(rot2))
+ odd = true
+ else
+ odd = false
+ end
+ end
+ return head
+end
countglyphs = function(head)
for line in nodetraverseid(0,head) do
for glyph in nodetraverseid(37,line.head) do
@@ -146,7 +205,7 @@ countglyphs = function(head)
return head
end
printglyphnumber = function()
- texiowrite_nl("Number of glyphs in this document: "..glyphnumber)
+ texiowrite_nl("\n Number of glyphs in this document: "..glyphnumber.."\n")
end
local quotestrings = {
[171] = true, [172] = true,
@@ -498,12 +557,12 @@ colorstretch = function (head)
if colorexpansion then -- if also the font expansion should be shown
local g = line.head
- while not(g.id == 37) do
- g = g.next
- end
- exp_factor = g.width / f[g.char].width
- exp_color = colorstretch_coloroffset + (1-exp_factor)*10 .. " g"
- rule_bad.width = 0.5*line.width -- we need two rules on each line!
+ while not(g.id == 37) and (g.next) do g = g.next end -- find first glyph on line. If line is empty, no glyph:
+ if (g.id == 37) then -- read width only if g is a glyph!
+ exp_factor = g.width / f[g.char].width
+ exp_color = colorstretch_coloroffset + (1-exp_factor)*10 .. " g"
+ rule_bad.width = 0.5*line.width -- we need two rules on each line!
+ end
else
rule_bad.width = line.width -- only the space expansion should be shown, only one rule
end
@@ -578,6 +637,40 @@ function scorpionize_color(head)
nodeinsertafter(head,node.tail(head),nodecopy(color_pop))
return head
end
+substlist = {}
+substlist[1488] = 64289
+substlist[1491] = 64290
+substlist[1492] = 64291
+substlist[1499] = 64292
+substlist[1500] = 64293
+substlist[1501] = 64294
+substlist[1512] = 64295
+substlist[1514] = 64296
+function variantjustification(head)
+ math.randomseed(1)
+ for line in nodetraverseid(nodeid"hhead",head) do
+ if (line.glue_sign == 1 and line.glue_order == 0) then -- exclude the last line!
+ substitutions_wide = {} -- we store all “expandable” letters of each line
+ for n in nodetraverseid(nodeid"glyph",line.head) do
+ if (substlist[n.char]) then
+ substitutions_wide[#substitutions_wide+1] = n
+ end
+ end
+ line.glue_set = 0 -- deactivate normal glue expansion
+ local width = node.dimensions(line.head) -- check the new width of the line
+ local goal = line.width
+ while (width < goal and #substitutions_wide > 0) do
+ x = math.random(#substitutions_wide) -- choose randomly a glyph to be substituted
+ oldchar = substitutions_wide[x].char
+ substitutions_wide[x].char = substlist[substitutions_wide[x].char] -- substitute by wide letter
+ width = node.dimensions(line.head) -- check if the line is too wide
+ if width > goal then substitutions_wide[x].char = oldchar break end -- substitute back if the line would be too wide and break out of the loop
+ table.remove(substitutions_wide,x) -- if further substitutions have to be done, remove the just substituted node from the list
+ end
+ end
+ end
+ return head
+end
zebracolorarray = {}
zebracolorarray_bg = {}
zebracolorarray[1] = "0.1 g"
diff --git a/Master/texmf-dist/tex/luatex/chickenize/chickenize.sty b/Master/texmf-dist/tex/luatex/chickenize/chickenize.sty
index 612b931d0b1..c957e335f34 100644
--- a/Master/texmf-dist/tex/luatex/chickenize/chickenize.sty
+++ b/Master/texmf-dist/tex/luatex/chickenize/chickenize.sty
@@ -13,7 +13,7 @@
%% of this license or (at your option) any later version. This work has the LPPL mainten-
%% ance status ‘maintained’.
\ProvidesPackage{chickenize}%
- [2012/09/16 v0.1a chickenize package]
+ [2013/02/24 v0.2 chickenize package]
\input{chickenize}
\iffalse
\DeclareDocumentCommand\includegraphics{O{}m}{
diff --git a/Master/texmf-dist/tex/luatex/chickenize/chickenize.tex b/Master/texmf-dist/tex/luatex/chickenize/chickenize.tex
index 0e6da86fedb..36aff989800 100644
--- a/Master/texmf-dist/tex/luatex/chickenize/chickenize.tex
+++ b/Master/texmf-dist/tex/luatex/chickenize/chickenize.tex
@@ -38,6 +38,21 @@
}
}
+\def\boustrophedon{
+ \directlua{luatexbase.add_to_callback("post_linebreak_filter",boustrophedon,"boustrophedon")}}
+\def\unboustrophedon{
+ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","boustrophedon")}}
+
+\def\boustrophedonglyphs{
+ \directlua{luatexbase.add_to_callback("post_linebreak_filter",boustrophedon_glyphs,"boustrophedon_glyphs")}}
+\def\unboustrophedonglyphs{
+ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","boustrophedon_glyphs")}}
+
+\def\boustrophedoninverse{
+ \directlua{luatexbase.add_to_callback("post_linebreak_filter",boustrophedon_inverse,"boustrophedon_inverse")}}
+\def\unboustrophedoninverse{
+ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","boustrophedon_inverse")}}
+
\def\chickenize{
\directlua{luatexbase.add_to_callback("pre_linebreak_filter",chickenize,"chickenize")
luatexbase.add_to_callback("start_page_number",
@@ -197,6 +212,9 @@
\def\unrandomuclc{
\directlua{luatexbase.remove_from_callback("pre_linebreak_filter","randomuclc")}}
+\let\rongorongonize\boustrophedoninverse
+\let\unrongorongonize\unboustrophedoninverse
+
\def\scorpionize{
\directlua{luatexbase.add_to_callback("pre_linebreak_filter",scorpionize_color,"scorpionize_color")}}
\def\unscorpionize{
@@ -226,6 +244,11 @@
\def\unuppercasecolor{
\directlua{luatexbase.remove_from_callback("post_linebreak_filter","uppercasecolor")}}
+\def\variantjustification{
+ \directlua{luatexbase.add_to_callback("post_linebreak_filter",variantjustification,"variantjustification")}}
+\def\unvariantjustification{
+ \directlua{luatexbase.remove_from_callback("post_linebreak_filter","variantjustification")}}
+
\def\zebranize{
\directlua{luatexbase.add_to_callback("post_linebreak_filter",zebranize,"zebranize")}}
\def\unzebranize{