summaryrefslogtreecommitdiff
path: root/macros/luatex/generic/barracuda/test/test-ga-pdfliteral
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2022-06-24 03:01:47 +0000
committerNorbert Preining <norbert@preining.info>2022-06-24 03:01:47 +0000
commit1ef4c041ba74d4619dd62209ae48a2b24563954c (patch)
treeb45a2e8da583a0f219e75f9536d9696f9af2aca7 /macros/luatex/generic/barracuda/test/test-ga-pdfliteral
parent00e67dfd87c53faeafcf0c9e66c8c2c7a410fcb8 (diff)
CTAN sync 202206240301
Diffstat (limited to 'macros/luatex/generic/barracuda/test/test-ga-pdfliteral')
-rw-r--r--macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdfbin30290 -> 30029 bytes
-rw-r--r--macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex222
-rw-r--r--macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.pdfbin0 -> 15101 bytes
-rw-r--r--macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.tex69
-rw-r--r--macros/luatex/generic/barracuda/test/test-ga-pdfliteral/polygon.svg132
5 files changed, 290 insertions, 133 deletions
diff --git a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf
index b3f3336f43..d741453c5b 100644
--- a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf
+++ b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf
Binary files differ
diff --git a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex
index c51fa3dfb0..a40ba4ec8b 100644
--- a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex
+++ b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex
@@ -1,7 +1,7 @@
% !TeX program = LuaTeX
% test for ga-canvas pdfliteral driver
%
-% Copyright (C) 2020 Roberto Giacomelli
+% Copyright (C) 2019-2022 Roberto Giacomelli
% see LICENSE.txt file
---ga--- is a binary format as an istruction set similar to
@@ -28,35 +28,36 @@ the PDF output file.
\newbox\mybox
\directlua{
- driver = require [[lib-driver.brcd-driver]] % global Lua variables
+ brcd = require "barracuda"
+ driver = brcd:get_driver() % global Lua variables
pt = tex.sp [[1pt]] % 1pt = 65536sp
}
Let's start drawing an horizontal line 100pt long:
\directlua{
- local ga = {_data = {33, 0*pt, 100*pt, 0*pt}}
+ local ga = {33, 0*pt, 100*pt, 0*pt}
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
or two different parallel lines 24pt long:
\directlua{
- local ga = {_data = {33, 0*pt, 24*pt, 0*pt, 33, 0*pt, 24*pt, 5*pt}}
+ local ga = {33, 0*pt, 24*pt, 0*pt, 33, 0*pt, 24*pt, 5*pt}
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
and again two horizontal lines 10pt thick, touching a corner:
\directlua{
- local ga = {_data = {
+ local ga = {
1, 10*pt,
33, -24*pt, 0*pt, -5*pt,
33, 0*pt, 24*pt, 5*pt,
- }}
+ }
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
Several vertical lines with its horizontal limits:
\directlua{
- local ga = { _data = {
+ local ga = {
34, -20*pt, 20*pt, 0*pt,
34, -15*pt, 15*pt, 5*pt,
34, -10*pt, 10*pt, 10*pt,
@@ -69,16 +70,16 @@ Several vertical lines with its horizontal limits:
1, .05*pt,
33, 0*pt, 40*pt, -20*pt,
33, 0*pt, 40*pt, 20*pt,
- }}
+ }
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
Finally a little rectangle:
\directlua{
- local ga = {_data = {
+ local ga = {
1, 5*pt,
48, 0*pt, 0*pt, 15*pt, 10*pt,
- }}
+ }
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
@@ -86,7 +87,7 @@ Finally a little rectangle:
Test number 1: a vbar 2pt width, 20pt height:
\directlua{
% vbar: <36> y1 y2 <nbars> x1 w1 x2 w2 ... xn wn
- local ga = {_data = {36, 0, 20*pt, 1, 0.0, 2*pt}}
+ local ga = {36, 0, 20*pt, 1, 0.0, 2*pt}
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
@@ -98,7 +99,7 @@ Test number 2: ten vbars in a row equally spaced by 10pt:
ga[i*2 + 5] = 5*pt + i*20*pt
ga[i*2 + 6] = 10*pt
end
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -117,7 +118,7 @@ Test number 3: two series of vbars 10pt and 5pt large:
ga[i*2 + 29] = 15*pt + i*20*pt
ga[i*2 + 30] = 5*pt
end
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -132,7 +133,7 @@ Test number 4: a bunch of thin vertical bars (25):
ga[i*2 + 5] = 1*pt + i*4*pt
ga[i*2 + 6] = 2*pt
end
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule A\box\mybox A\vrule
\bigskip
@@ -155,7 +156,7 @@ Test number 5: two rows of a bunch of thin bars:
ga[i*2 + 59] = 3*pt + i*4*pt
ga[i*2 + 60] = 2*pt
end
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -181,7 +182,7 @@ Test number 6: staircase of Vbars (manually data definition):
25*pt, % x
10*pt, % w
}
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -219,7 +220,7 @@ Test number 7: vbars with spaced text, in three different rows:
ga[52] = 71 % G
ga[53] = 72 % H
ga[54] = 0
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -271,7 +272,7 @@ Test number 8: spaced text (checking the correct vertical alignment):
ga[66] = 55 % 7
ga[67] = 56 % 8
ga[68] = 0
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -323,7 +324,7 @@ Test number 9: spaced text, check correct vertical alignment:
ga[66] = 55 % 7
ga[67] = 56 % 8
ga[68] = 0
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
@@ -356,11 +357,11 @@ Test number 10: two centered texts aligned to the baseline:
ga[23] = 56 % 8
ga[24] = 57 % 9
ga[25] = 0
- driver:ga_to_hbox({_data = ga}, [[mybox]])
+ driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
-So far, we have manually build data for ga stream. Next we are going to
+So far, we have manually build data for ga stream. For now on, we are going to
use the ga-canvas library.
\bigskip
@@ -368,26 +369,22 @@ In fact, all the previous tests are rebuild with the ga-canvas library.
Test 1: a vbar 2pt width, 20pt height:
\directlua{
- gacanvas = require "lib-geo.brcd-gacanvas"
- local ga = gacanvas:new()
- local vbar = {_yline = {0.0, 2*pt}}
- local err = ga:encode_Vbar(vbar, 0.0, 0.0, 20*pt) % x, w
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ local vbar = {0.0, 2*pt}
+ assert(ga:encode_vbar(vbar, 0.0, 0.0, 20*pt)) % x, w
driver:ga_to_hbox(ga, [[mybox]])
}\box\mybox
\bigskip
Test 2: ten vbars equally spaced by 10pt:
\directlua{
- local ga = gacanvas:new()
- local data = {}
+ local ga = brcd:new_canvas()
+ local bars = {}
for i = 0, 9 do
- data[i*2 + 1] = 5*pt + i*20*pt % x
- data[i*2 + 2] = 10*pt % w
+ bars[i*2 + 1] = 5*pt + i*20*pt % x
+ bars[i*2 + 2] = 10*pt % w
end
- local bars = {_yline = data}
- local err = ga:encode_Vbar(bars, 0.0, 0.0, 10*pt)
- assert(not err, err)
+ assert(ga:encode_vbar(bars, 0.0, 0.0, 10*pt))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -404,11 +401,9 @@ Test 3: two series of vbars 10pt and 5pt large:
b2[i*2 + 1] = i*20*pt
b2[i*2 + 2] = 5*pt
end
- local ga = gacanvas:new()
- local err = ga:encode_Vbar({_yline=b1}, 0.0, 0.0, 10*pt)
- assert(not err, err)
- err = ga:encode_Vbar({_yline=b2}, 10.0*pt, 2.5*pt, 7.5*pt)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b1, 0.0, 0.0, 10*pt))
+ assert(ga:encode_vbar(b2, 10.0*pt, 2.5*pt, 7.5*pt))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -420,9 +415,8 @@ Test 4: a bunch of thin bars:
b[i*2 + 1] = 1*pt + i*4*pt
b[i*2 + 2] = 2*pt
end
- local ga = gacanvas:new()
- local err = ga:encode_Vbar({_yline=b}, 0.0, 5*pt, 25*pt)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b, 0.0, 5*pt, 25*pt))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule{ }\box\mybox{ }\vrule
@@ -434,42 +428,34 @@ Test 5: two levels of a bunch of thin bars:
b[i*2 + 1] = i*4*pt
b[i*2 + 2] = 2*pt
end
- local b = {_yline=b}
- local ga = gacanvas:new()
- local err = ga:encode_Vbar(b, 0.0, 5*pt, 25*pt)
- assert(not err, err)
- err = ga:encode_Vbar(b, 2*pt, 25*pt, 45*pt, b)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b, 0.0, 5*pt, 25*pt))
+ assert(ga:encode_vbar(b, 2*pt, 25*pt, 45*pt, b))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
Test number 6: staircase of bars (manual insertion of data):
\directlua{
- local b = {_yline={0.0, 10*pt}}
- local ga = gacanvas:new()
- local err = ga:encode_Vbar(b, 0.0, 0.0, 20*pt)
- assert(not err, err)
- err = ga:encode_Vbar(b, 10*pt, 20*pt, 40*pt)
- assert(not err, err)
- err = ga:encode_Vbar(b, 20*pt, 40*pt, 60*pt)
- assert(not err, err)
+ local b = {0.0, 10*pt}
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b, 0.0, 0.0, 20*pt))
+ assert(ga:encode_vbar(b, 10*pt, 20*pt, 40*pt))
+ assert(ga:encode_vbar(b, 20*pt, 40*pt, 60*pt))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
\bigskip
Test number 7: vbars with spaced text, all in three rows:
\directlua{
- local b = {}
+ local vb = {}
for i = 0,7 do
- b[i*2+1] = i*10*pt
- b[i*2+2] = 5*pt
+ vb[i*2+1] = i*10*pt
+ vb[i*2+2] = 5*pt
end
- local vb = {_yline=b}
- local ga = gacanvas:new()
- local err = ga:encode_Vbar(vb, 0.0, 0.0, 20*pt)
- assert(not err, err)
- local err = ga:encode_Vbar(vb, 0.0, 30*pt, 50*pt)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(vb, 0.0, 0.0, 20*pt))
+ assert(ga:encode_vbar(vb, 0.0, 30*pt, 50*pt))
local txt = {codepoint = {
65, % A
66, % B
@@ -480,8 +466,7 @@ Test number 7: vbars with spaced text, all in three rows:
71, % G
72, % H
}}
- err = ga:encode_Text_xspaced(txt, 0.0, 10*pt, 25*pt, 0.5)
- assert(not err, err)
+ assert(ga:encode_Text_xspaced(txt, 0.0, 10*pt, 25*pt, 0.5))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -493,12 +478,9 @@ Test 8: spaced text, check correct vertical alignment:
b[i*2+1] = i*10*pt
b[i*2+2] = 2*pt
end
- b = {_yline=b}
- local ga = gacanvas:new()
- local err = ga:encode_Vbar(b, 0.0, 0.0, 20*pt)
- assert(not err, err)
- local err = ga:encode_Vbar(b, 0.0, 40*pt, 60*pt)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b, 0.0, 0.0, 20*pt))
+ assert(ga:encode_vbar(b, 0.0, 40*pt, 60*pt))
local c = { codepoint = {
65, % A
66, % B
@@ -509,8 +491,7 @@ Test 8: spaced text, check correct vertical alignment:
71, % G
72, % H
}}
- err = ga:encode_Text_xspaced(c, 0.0, 10*pt, 30*pt, 0.0)
- assert(not err, err)
+ assert(ga:encode_Text_xspaced(c, 0.0, 10*pt, 30*pt, 0.0))
local n = { codepoint = {
49, % 1
50, % 2
@@ -521,8 +502,7 @@ Test 8: spaced text, check correct vertical alignment:
55, % 7
56, % 8
}}
- err = ga:encode_Text_xspaced(n, 0.0, 10*pt, 30*pt, 1.0)
- assert(not err, err)
+ assert(ga:encode_Text_xspaced(n, 0.0, 10*pt, 30*pt, 1.0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -534,12 +514,9 @@ Test number 9: spaced text, check correct vertical alignment:
b[i*2+1] = i*10*pt
b[i*2+2] = 8*pt
end
- b = {_yline = b}
- local ga = gacanvas:new()
- local err = ga:encode_Vbar(b, 0.0, 0.0, 20*pt)
- assert(not err, err)
- local err = ga:encode_Vbar(b, 0.0, 40*pt, 60*pt)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_vbar(b, 0.0, 0.0, 20*pt))
+ assert(ga:encode_vbar(b, 0.0, 40*pt, 60*pt))
local c = { codepoint = {
65, % A
66, % B
@@ -550,8 +527,7 @@ Test number 9: spaced text, check correct vertical alignment:
71, % G
72, % H
}}
- err = ga:encode_Text_xspaced(c, 0.0, 10*pt, 20*pt, 0.0)
- assert(not err, err)
+ assert(ga:encode_Text_xspaced(c, 0.0, 10*pt, 20*pt, 0.0))
local n = { codepoint = {
49, % 1
50, % 2
@@ -562,8 +538,7 @@ Test number 9: spaced text, check correct vertical alignment:
55, % 7
56, % 8
}}
- err = ga:encode_Text_xspaced(n, 0.0, 10*pt, 40*pt, 1.0)
- assert(not err, err)
+ assert(ga:encode_Text_xspaced(n, 0.0, 10*pt, 40*pt, 1.0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule{ }\box\mybox{ }\vrule
@@ -582,16 +557,14 @@ Test number 10: two centered texts and baseline aligned:
56, % 8
57, % 9
}}
- local ga = gacanvas:new()
- local err = ga:encode_Text(n, 0, 0, 0.5, 0)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_Text(n, 0, 0, 0.5, 0))
local a = { codepoint = {
65, % A
string.byte("Q"), % Q
67, % C
}}
- err = ga:encode_Text(a, 0, 0, 0.5, 1)
- assert(not err, err)
+ assert(ga:encode_Text(a, 0, 0, 0.5, 1))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -610,16 +583,14 @@ Test number 11: two centered texts aligned:
56, % 8
57, % 9
}}
- local ga = gacanvas:new()
- local err = ga:encode_Text(n, 0, 0, 0.5, 1)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_Text(n, 0, 0, 0.5, 1))
local a = { codepoint = {
65, % A
string.byte("Q"), % Q
67, % C
}}
- err = ga:encode_Text(a, 0, 0, 0.5, 0)
- assert(not err, err)
+ assert(ga:encode_Text(a, 0, 0, 0.5, 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -639,9 +610,8 @@ Test number 12: text\_xwidth opcode:
56, % 8
57, % 9
}}
- local ga = gacanvas:new()
- local err = ga:encode_Text_xwidth(n, 0, tex.sp "5cm", 0, 0)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ assert(ga:encode_Text_xwidth(n, 0, tex.sp "5cm", 0, 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -664,20 +634,14 @@ Test number 13: text\_xwidth with different size:
56, % 8
57, % 9
}}
- local ga = gacanvas:new()
- % (txt, x1, x2, ypos, ay) --> err
- local err = ga:encode_Text_xwidth(n, tex.sp "0mm", tex.sp "50mm", 0, 0)
- assert(not err, err)
- local err = ga:encode_Text_xwidth(n, tex.sp "5mm", tex.sp "45mm", tex.sp "3mm", 0)
- assert(not err, err)
- local err = ga:encode_Text_xwidth(n, tex.sp "10mm", tex.sp "40mm", tex.sp "6mm", 0)
- assert(not err, err)
- local err = ga:encode_Text_xwidth(n, tex.sp "15mm", tex.sp "35mm", tex.sp "9mm", 0)
- assert(not err, err)
- local err = ga:encode_Text_xwidth(n, tex.sp "20mm", tex.sp "30mm", tex.sp "12mm", 0)
- assert(not err, err)
- local err = ga:encode_Text_xwidth(n, tex.sp "24mm", tex.sp "26mm", tex.sp "15mm", 0)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ % (txt, x1, x2, ypos, ay) --> ok, err
+ assert(ga:encode_Text_xwidth(n, tex.sp "0mm", tex.sp "50mm", 0, 0))
+ assert(ga:encode_Text_xwidth(n, tex.sp "5mm", tex.sp "45mm", tex.sp "3mm", 0))
+ assert(ga:encode_Text_xwidth(n, tex.sp "10mm", tex.sp "40mm", tex.sp "6mm", 0))
+ assert(ga:encode_Text_xwidth(n, tex.sp "15mm", tex.sp "35mm", tex.sp "9mm", 0))
+ assert(ga:encode_Text_xwidth(n, tex.sp "20mm", tex.sp "30mm", tex.sp "12mm", 0))
+ assert(ga:encode_Text_xwidth(n, tex.sp "24mm", tex.sp "26mm", tex.sp "15mm", 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -691,16 +655,12 @@ Test number 14: place bars and text as text\_xwidth:
b[i*2 + 1] = i*12*pt
b[i*2 + 2] = 0.4*pt
end
- b = {_yline = b}
local n = {codepoint = { 48, 49, 50, 51, 52, 53, 54, 55, 56, 57,}}
- local ga = gacanvas:new()
- % (vbar, x0, y1, y2) --> err
- local err = ga:encode_Vbar(b, 0.0, 0*pt, 25*pt)
- local err = ga:encode_Vbar(b, 0.0, 32*pt, 42*pt)
- assert(not err, err)
- % (txt, x1, x2, ypos, ay) --> err
- local err = ga:encode_Text_xwidth(n, 0*pt, 108*pt, 25*pt, 0)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ % (vbar, x0, y1, y2) --> ok, err
+ assert(ga:encode_vbar(b, 0.0, 0*pt, 25*pt))
+ % (txt, x1, x2, ypos, ay) --> ok, err
+ assert(ga:encode_Text_xwidth(n, 0*pt, 108*pt, 25*pt, 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -711,17 +671,14 @@ Test number 14: place bars and text as text\_xwidth:
b[i*2 + 1] = i*12*pt
b[i*2 + 2] = 0.2*pt
end
- b = {_yline = b}
local n = { 48, 49, 50, 51, string.byte([[x]]), 53, 54, 55, 56,}
n = {codepoint = n}
- local ga = gacanvas:new()
+ local ga = brcd:new_canvas()
% x0, y1, y2, bars
- local err = ga:encode_Vbar(b, 0.0, 0*pt, 25*pt)
- local err = ga:encode_Vbar(b, 0.0, 32*pt, 42*pt)
- assert(not err, err)
- % (txt, x1, x2, ypos, ay) --> err
- local err = ga:encode_Text_xwidth(n, 0*pt, 96*pt, 25*pt, 0)
- assert(not err, err)
+ assert(ga:encode_vbar(b, 0.0, 0*pt, 25*pt))
+ assert(ga:encode_vbar(b, 0.0, 32*pt, 42*pt))
+ % (txt, x1, x2, ypos, ay) --> ok, err
+ assert(ga:encode_Text_xwidth(n, 0*pt, 96*pt, 25*pt, 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
@@ -730,10 +687,9 @@ Test number 15: place text\_xwidth when text is only two chars long:
\directlua{
local n = {codepoint = { 48, 56,}} % 0 and 8
- local ga = gacanvas:new()
- % (txt, x1, x2, ypos, ay) --> err
- local err = ga:encode_Text_xwidth(n, 0*pt, 32*pt, 25*pt, 0)
- assert(not err, err)
+ local ga = brcd:new_canvas()
+ % (txt, x1, x2, ypos, ay) --> ok, err
+ assert(ga:encode_Text_xwidth(n, 0*pt, 32*pt, 25*pt, 0))
driver:ga_to_hbox(ga, [[mybox]])
}\vrule\box\mybox\vrule
diff --git a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.pdf b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.pdf
new file mode 100644
index 0000000000..72d4eddc05
--- /dev/null
+++ b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.pdf
Binary files differ
diff --git a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.tex b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.tex
new file mode 100644
index 0000000000..14a713dee9
--- /dev/null
+++ b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/002-polyline.tex
@@ -0,0 +1,69 @@
+% !TeX program = LuaTeX
+
+\directlua{
+ brcd = require "barracuda"
+}
+\newbox\mybox
+
+Test 1: a simple polyline:
+\directlua{
+ local Polyline = brcd._libgeo.Polyline
+ local p = Polyline:new()
+ p:add_point(0, 0)
+ p:add_point(tex.sp "32pt", 0)
+ p:add_relpoint(tex.sp "16pt", tex.sp "16pt")
+
+ local gaCanvas = brcd._gacanvas
+ local ga = gaCanvas:new()
+ assert(ga:encode_polyline(p))
+
+ local driver = brcd:get_driver()
+ driver:ga_to_hbox(ga, [[mybox]])
+}\vrule\box\mybox\vrule
+
+
+Test 2: a staircase:
+\directlua{
+ local h = tex.sp "18pt"
+ local b = tex.sp "36pt"
+ local Polyline = brcd._libgeo.Polyline
+ local p = Polyline:new()
+ p:add_point(0, 0)
+ for _ = 1, 5 do
+ p:add_relpoint(0, h)
+ p:add_relpoint(b, 0)
+ end
+
+ local gaCanvas = brcd._gacanvas
+ local ga = gaCanvas:new()
+ assert(ga:encode_polyline(p))
+
+ local driver = brcd:get_driver()
+ driver:ga_to_hbox(ga, [[mybox]])
+}\vrule\box\mybox\vrule
+
+Test 3: several regular polygons:
+\directlua{
+ local Polyline = brcd._libgeo.Polyline
+ local l = tex.sp "36pt" % side length
+ local gaCanvas = brcd._gacanvas
+ local ga = gaCanvas:new()
+ ga:encode_linewidth(tex.sp "0.4pt")
+ for n = 3, 13 do
+ local p = Polyline:new()
+ p:add_point(0, 0)
+ local alpha = 2*math.pi/n % angle
+ local a = alpha/2 % regular angles sum
+ for _ = 1, n do
+ local x, y = l * math.cos(a), l * math.sin(a)
+ a = a + alpha
+ p:add_relpoint(x, y)
+ end
+ assert(ga:encode_polyline(p))
+ end
+ local driver = brcd:get_driver()
+ driver:ga_to_hbox(ga, [[mybox]])
+ driver:save("svg", ga, "polygon")
+}\vrule\box\mybox\vrule
+
+\bye
diff --git a/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/polygon.svg b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/polygon.svg
new file mode 100644
index 0000000000..fd00ed2912
--- /dev/null
+++ b/macros/luatex/generic/barracuda/test/test-ga-pdfliteral/polygon.svg
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Barracuda package (https://github.com/robitex/barracuda) -->
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<svg xmlns="http://www.w3.org/2000/svg"
+ version="1.1"
+ width="52.484243mm" height="52.101574mm"
+ viewBox="-26.242122 -52.101574 52.484243 52.101574"
+>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 6.326276,-10.957432
+ -6.326276,-10.957432
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 8.946706,-8.946706
+ 0.000000,-17.893412
+ -8.946706,-8.946706
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 10.236130,-7.436984
+ 6.326276,-19.470277
+ -6.326276,-19.470277
+ -10.236130,-7.436984
+ -0.000000,-0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 10.957432,-6.326276
+ 10.957432,-18.978829
+ 0.000000,-25.305106
+ -10.957432,-18.978829
+ -10.957432,-6.326276
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 11.399556,-5.489737
+ 14.215014,-17.825064
+ 6.326276,-27.717228
+ -6.326276,-27.717228
+ -14.215014,-17.825064
+ -11.399556,-5.489737
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 11.689435,-4.841922
+ 16.531357,-16.531357
+ 11.689435,-28.220792
+ 0.000000,-33.062714
+ -11.689435,-28.220792
+ -16.531357,-16.531357
+ -11.689435,-4.841922
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 11.889511,-4.327428
+ 18.215787,-15.284860
+ 16.018694,-27.745192
+ 6.326276,-35.878097
+ -6.326276,-35.878097
+ -16.018694,-27.745192
+ -18.215787,-15.284860
+ -11.889511,-4.327428
+ 0.000000,-0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 12.033293,-3.909854
+ 19.470277,-14.145984
+ 19.470277,-26.798537
+ 12.033293,-37.034667
+ 0.000000,-40.944521
+ -12.033293,-37.034667
+ -19.470277,-26.798537
+ -19.470277,-14.145984
+ -12.033293,-3.909854
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 12.140036,-3.564636
+ 20.425696,-13.126798
+ 22.226342,-25.650566
+ 16.970281,-37.159733
+ 6.326276,-44.000219
+ -6.326276,-44.000219
+ -16.970281,-37.159733
+ -22.226342,-25.650566
+ -20.425696,-13.126798
+ -12.140036,-3.564636
+ -0.000000,0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 12.221428,-3.274722
+ 21.168134,-12.221428
+ 24.442855,-24.442855
+ 21.168134,-36.664283
+ 12.221428,-45.610989
+ 0.000000,-48.885711
+ -12.221428,-45.610989
+ -21.168134,-36.664283
+ -24.442855,-24.442855
+ -21.168134,-12.221428
+ -12.221428,-3.274722
+ -0.000000,-0.000000"/>
+ </g>
+ <g stroke="black" stroke-width="0.140582" fill="none">
+ <polyline points="0.000000,-0.000000
+ 12.284893,-3.027954
+ 21.755465,-11.418149
+ 26.242122,-23.248491
+ 24.717025,-35.808793
+ 17.529556,-46.221640
+ 6.326276,-52.101574
+ -6.326276,-52.101574
+ -17.529556,-46.221640
+ -24.717025,-35.808793
+ -26.242122,-23.248491
+ -21.755465,-11.418149
+ -12.284893,-3.027954
+ -0.000000,0.000000"/>
+ </g>
+</svg>
+