summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/luatex/chickenize/chickenize.lua
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/luatex/chickenize/chickenize.lua')
-rw-r--r--Master/texmf-dist/tex/luatex/chickenize/chickenize.lua109
1 files changed, 101 insertions, 8 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"