From 98a8cf07f9f44a4cac1d296b1dd75e3878530ccc Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 23 Jun 2022 20:54:26 +0000 Subject: barracuda (23jun22) git-svn-id: svn://tug.org/texlive/trunk@63701 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/doc/luatex/barracuda/PLANNER.txt | 120 +- Master/texmf-dist/doc/luatex/barracuda/README.md | 33 +- .../doc/luatex/barracuda/doc/barracuda-ga-asm.pdf | Bin 38718 -> 0 bytes .../doc/luatex/barracuda/doc/barracuda-ga-asm.tex | 148 --- .../luatex/barracuda/doc/barracuda-manual-tool.tex | 39 - .../doc/luatex/barracuda/doc/barracuda.pdf | Bin 67784 -> 0 bytes .../doc/luatex/barracuda/doc/barracuda.tex | 413 ------ .../doc/ga-graphic-asm/barracuda-ga-asm.pdf | Bin 0 -> 38718 bytes .../doc/ga-graphic-asm/barracuda-ga-asm.tex | 148 +++ .../luatex/barracuda/doc/image/8006194056290.pdf | Bin 5682 -> 0 bytes .../barracuda/doc/manual/barracuda-manual-tool.tex | 49 + .../barracuda/doc/manual/barracuda-manual.pdf | Bin 0 -> 125819 bytes .../barracuda/doc/manual/barracuda-manual.tex | 1312 ++++++++++++++++++++ .../barracuda/doc/manual/image/8006194056290.pdf | Bin 0 -> 5682 bytes .../01-barracuda-latex-test.pdf | Bin 3810 -> 4047 bytes .../01-barracuda-latex-test.tex | 17 +- .../test-barracuda-package/02-ord_iter-test.tex | 2 +- .../test/test-code128/001-code128-test.lua | 32 - .../test/test-code128/001-code128-test.tex | 39 + .../test/test-code128/002-code128-test.pdf | Bin 22132 -> 24385 bytes .../test/test-code128/002-code128-test.tex | 114 +- .../test/test-code128/02-05-pdfliteral.txt | 8 + .../barracuda/test/test-code39/001-code39-test.lua | 41 - .../barracuda/test/test-code39/001-code39-test.tex | 39 + .../barracuda/test/test-code39/002-code39-test.pdf | Bin 22701 -> 23271 bytes .../barracuda/test/test-code39/002-code39-test.tex | 35 +- .../barracuda/test/test-code39/003-code39-test.pdf | Bin 19827 -> 19829 bytes .../barracuda/test/test-code39/003-code39-test.tex | 18 +- .../barracuda/test/test-code39/004-code39-test.pdf | Bin 15329 -> 15341 bytes .../barracuda/test/test-code39/004-code39-test.tex | 11 +- .../barracuda/test/test-code39/006-code39-test.lua | 12 +- .../barracuda/test/test-code39/007-code39-test.pdf | Bin 0 -> 18589 bytes .../barracuda/test/test-code39/007-code39-test.tex | 39 + .../barracuda/test/test-ean/001-13-ean-test.pdf | Bin 23620 -> 23924 bytes .../barracuda/test/test-ean/001-13-ean-test.tex | 29 +- .../barracuda/test/test-ean/002-ean-test.pdf | Bin 10601 -> 10674 bytes .../barracuda/test/test-ean/003-ean-test.pdf | Bin 3901 -> 3986 bytes .../barracuda/test/test-ean/004-ean-test.lua | 9 - .../barracuda/test/test-ean/004-ean-test.tex | 6 + .../barracuda/test/test-ean/005-isbn-test.pdf | Bin 19829 -> 19910 bytes .../barracuda/test/test-ean/006-issn-test.pdf | Bin 14883 -> 15099 bytes .../barracuda/test/test-ean/006-issn-test.tex | 20 +- .../barracuda/test/test-ean/8006194056290.svg | 16 +- .../doc/luatex/barracuda/test/test-ean/ars.svg | 16 +- .../test-ga-pdfliteral/001-ga-pdfliteral-test.pdf | Bin 30290 -> 30029 bytes .../test-ga-pdfliteral/001-ga-pdfliteral-test.tex | 222 ++-- .../test/test-ga-pdfliteral/002-polyline.pdf | Bin 0 -> 15101 bytes .../test/test-ga-pdfliteral/002-polyline.tex | 69 + .../barracuda/test/test-ga-pdfliteral/polygon.svg | 132 ++ .../barracuda/test/test-ga-svg/002-ga-svg-test.lua | 2 +- .../barracuda/test/test-i2of5/001-i2of5-test.pdf | Bin 19136 -> 20158 bytes .../barracuda/test/test-i2of5/001-i2of5-test.tex | 59 +- .../barracuda/test/test-i2of5/002-ITF14-test.pdf | Bin 16052 -> 16541 bytes .../barracuda/test/test-i2of5/002-ITF14-test.tex | 23 +- .../luatex/barracuda/test/test-i2of5/02-itf14.svg | 76 ++ .../barracuda/test/test-libgeo/001-libgeo-test.pdf | Bin 0 -> 14087 bytes .../barracuda/test/test-libgeo/001-libgeo-test.tex | 48 + .../barracuda/test/test-libgeo/003-ga-svg-test.pdf | Bin 0 -> 1130 bytes .../barracuda/test/test-libgeo/003-ga-svg-test.tex | 41 + .../doc/luatex/barracuda/test/test-libgeo/test.svg | 79 ++ .../barracuda/test/test-upc/001-upca-test.pdf | Bin 0 -> 17692 bytes .../barracuda/test/test-upc/001-upca-test.tex | 41 + .../luatex/barracuda/test/test-upc/002-upca.pdf | Bin 0 -> 3344 bytes .../luatex/barracuda/test/test-upc/002-upca.tex | 9 + 64 files changed, 2560 insertions(+), 1006 deletions(-) delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.pdf delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.tex delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-manual-tool.tex delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.pdf delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.tex delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/image/8006194056290.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual-tool.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/doc/manual/image/8006194056290.pdf delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.lua create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.tex delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.lua create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.tex delete mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.lua create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/polygon.svg create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/02-itf14.svg create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/test.svg create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.tex create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.pdf create mode 100644 Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.tex (limited to 'Master/texmf-dist/doc') diff --git a/Master/texmf-dist/doc/luatex/barracuda/PLANNER.txt b/Master/texmf-dist/doc/luatex/barracuda/PLANNER.txt index ca7a9e041f9..f6f613ddbae 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/PLANNER.txt +++ b/Master/texmf-dist/doc/luatex/barracuda/PLANNER.txt @@ -5,7 +5,7 @@ Basic rules ----------- + Every new version will be uploaded to CTAN network -+ For each single task there will be a correspomding commit ++ For each single task there will be a single commit Hypothetical development task list: ----------------------------------- @@ -18,52 +18,101 @@ Hypothetical development task list: 20__-__-__: [dev] proportional options 20__-__-__: [dev] a number parameter can be a string? unit measure... 20__-__-__: [prj] a command line program to print barcodes -20__-__-__: [dev] guard text in EAN simbology -20__-__-__: [dev] UPC support 20__-__-__: [dev] make optional file name in all the Driver methods 20__-__-__: [prj] test l3build for testing and CTAN files packaging 20__-__-__: [dev] load barcode parameters from an external file 20__-__-__: [dev] new Parameter Class +202_-__-__: [dev][barcode] new `alias` feature +202_-__-__: [dev][barcode] new `preset` feature +202_-__-__: [project][build] make a Lua script to easily create the CTAN upload + : compressed files +202_-__-__: [dev] statistical data on how many barcode symbols was printed +202_-__-__: [upc] UPC-E barcode symbology -Scheduled task list for Data Matrix 2D simbology implementation: +Scheduled task list for Data Matrix 2D symbology implementation: ---------------------------------------------------------------- -2020-__-__: [dmx] data matrix first run -2020-__-__: [dmx] ecc200 error correction code -2020-__-__: [svg] opcode for grids -2020-__-__: [pdf] opcode for grids -2020-__-__: [gas] ga-asm grid opcode -2020-__-__: [geo] grid vector object -2020-__-__: [dev] init source file encoder for Data Matrix -2020-__-__: [dev] parameter preset - -Dev Planner: -============ +202_-__-__: [dmx] data matrix first run +202_-__-__: [dmx] ecc200 error correction code +202_-__-__: [svg] opcode for grids +202_-__-__: [pdf] opcode for grids +202_-__-__: [ga] ga new grid opcode +202_-__-__: [geo] grid vector object +202_-__-__: [dev] init source file encoder for Data Matrix + +Ongoing Scheduler: +================== +------------------------------------------------------------------------------- +202_-__-__: [milestone] version 0.1 +202_-__-__: [test] update test files with recent changes +202_-__-__: [dev][ean] fix the `ean:checksum()` to include ISBN and ISSN variant +202_-__-__: [dev] control the method call on the right class +202_-__-__: [code128] add human readeable text +202_-__-__: [breaking change] refactor Text libgeo object +202_-__-__: [project] adhere to semver specification +202_-__-__: [doc] API reference +202_-__-__: [doc] barcode symbologies reference: code39 + +------------------------------------------------------------------------------- +2022-06-22: [code128] fix a bug in the encoder (complete rewriting) ------------------------------------------------------------------------------- -2020-__-__: [milestone] version completed task/commit list -2020-__-__: [doc] barcode symbologies reference -2020-__-__: [doc] put ga-asm-spec together with the manual -2020-__-__: [dev][barcode] new `alias` feature -2020-__-__: [dev][barcode] new `preset` feature -2020-__-__: [dev][i2of5] human readeable text for i2of5 -2020-__-__: [dev][libgeo] new `Vbar_group` class -2020-__-__: [test] update test files with recent changes -2020-__-__: [dev][libgeo][breaking change] return `ok, err` instead of `err` +2020-05-03: [barcode] debug_bbox option +2020-05-03: [libgeo] optional tx, ty moving point for encode_ +2020-04-06: [driver] new methods for gaCanvas class and default style graphic +2020-03-20: [upc] new UPC-A barcode symbology +2020-03-13: [barcode] new method get_code() and get_hri() +2020-03-11: [breaking change][barcode] new `draw()` method +2020-03-07: [ga] new and opcodes +2020-03-06: [doc] new section explains `Vbar` +2020-03-02: [doc] add a chess example for `ga` stream + +[merge]<--------+ + | + 2020-03-02: [doc] put ga-asm-spec together with the manual + | +[doc-basic-ref]-+ + +2020-02-27:*[dev][i2of5] human readeable text for i2of5 and ITF14 + +[merge]<--------+ + | + 2020-02-26: [ean] guard text in EAN symbology + 2020-02-25: [libgeo][gaCanvas] Polyline object test file + 2020-02-25: [libgeo][gaCanvas] new Polyline object + | +[Polyline]------+ + +2020-02-22: [dev] new methods _process_char() and _process_digit() +2020-02-09: [dev] new constructor `Barcode:new()` + +[merge]<--------+ + | + 2020-02-17: [libgeo] delete `Vbar_archive` in favour of `Archive` + 2020-02-16: [libgeo] arithmetic of new object `Queue` + 2020-02-12: [libgeo] new class `Archive` + 2020-02-12: [dev][libgeo] add method `Vbar_archive:add_space()` + 2020-02-12: [dev][libgeo] refactor `Vbar_archive:push_queue()` method + 2020-02-12: [dev][ean] refactor ean to use `Vbar_archive` + 2020-02-11: [dev][i2to5] refactor i2of5 to use `Vbar_archive` + 2020-02-10: [dev][code128] refactor code128 to use `Vbar_archive` + 2020-02-09: [dev][libgeo] refactor code39 to use `Vbar_archive` + 2020-02-06: [dev][libgeo] new `Vbar_archive` class in libgeo + | +[vbar_archive]--+ + +2020-02-05: [dev][libgeo][breaking change] return `ok, err` instead of `err` for canvas methods -2020-__-__: [dev] new constructor `Barcode:new()` -2020-__-__: [project][build] make a Lua script to easily create the CTAN upload - : compressed files -2020-__-__: [dev][ean] fix the `ean:checksum()` to include ISBN and ISSN variant -2020-__-__: [dev][i2of5] `encoder:_init_parse_state()` adoption for ITF14 +2020-02-04: [dev][ean] new function `encoder:_init_parse_state()`, and EAN + : family adoption; + : [dev][i2of5] `encoder:_init_parse_state()` adoption for ITF14 : variant -2020-__-__: [dev][ean] new function `encoder:_init_parse_state()`, and EAN - : family adoption -2020-__-__: update version number in preparetion of the next version. + : [project] update version number in preparation of the next version ------------------------------------------------------------------------------- + ------------------------------------------------------------------------------- -2020-02-04: [milestone] version completed task/commit list +2020-02-04: [milestone] version completed task/commit list: ------------------------------------------------------------------------------- -2020-02-04:*[dev][ean] ISSN support +2020-02-04: [dev][ean] ISSN support 2020-02-03: [dev][ean] move out of `_config()` `finalize()` method as in i2of5 2020-02-02: [dev][i2of5] new ITF14 variant, plan for the next version 2020-02-01: [dev] new semantic for barcode parameter: alternative family @@ -83,8 +132,7 @@ Dev Planner: : [api][breaking change] new encoder naming convention : reuse or create a new encoder object in barracuda:hbox() and : barracuda:save() methods - -(*) this commit +------------------------------------------------------------------------------- Task history and previous version: ================================== diff --git a/Master/texmf-dist/doc/luatex/barracuda/README.md b/Master/texmf-dist/doc/luatex/barracuda/README.md index 49bab5cb241..d1880c3d2c8 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/README.md +++ b/Master/texmf-dist/doc/luatex/barracuda/README.md @@ -1,42 +1,41 @@ # `barracuda` project -This a pure Lua library is for drawing barcode symbols. The project components -are able to typeset barcode from within a LuaTeX document. Therefore is also -possible to use `barracuda` with a Lua standalone interpreter to draw barcodes -with different graphic format such as `SVG` (see an example below). This package -does not have dependences. +This is a pure Lua library for drawing barcode symbols. `barracuda` components' +are able to typeset barcode from within a LuaTeX document in order to produce a +PDF file, or is also possible to use a Lua standalone interpreter to draw +barcodes in different graphic format such as `SVG` (see an example below). ![a Code39 symbol in SVG format](/test/test-ga-svg/test-code39.svg) -Internal modules are structured to ensure good performance and to give a -complete user control over barcode symbol parameters :thumbsup: . +The internal modules are structured to ensure good performance beside of a +complete user control over barcode symbol parameters :thumbsup: Although development is in beta stage, `barracuda` has a good level of -stability. +stability. The package does not have any dependences. ## Current version -Version: v0.0.10 -Date: 2020-02-04 +Version: 0.0.12 - Date: 2022-06-23 ## Barcode symbologies list -So far, the barcode symbologies included in the package are: +So far, the barcode symbologies supported by the package are: - Code 39 - Code 128 -- Interleaved 2 of 5 +- Interleaved 2 of 5 (ITF14, i2of5 general) - EAN family (ISBN, ISSN, EAN8, EAN13, and the add-ons EAN5 and EAN2) +- UPC-A -Other 1D encoding symbology will be added to the project, then it will be the -turn of 2D barcode types like Datamatrix, QRCode or PDF417. +Other 1D encoding symbology will be eventually added to the project, then it +will be the turn of 2D barcode types like Datamatrix, QRCode or PDF417. ## A very simple LaTeX example The LaTeX package `barracuda.sty` under the cover uses Lua code so you need to compile your source files with LuaTeX or LuajitTeX with the LaTeX format. -For instance, here is a minimal working example for LuaLaTeX: +For instance, the follow is a minimal working example for LuaLaTeX: ```latex % !TeX program = LuaLaTeX @@ -71,7 +70,7 @@ releases can be found only at . TeX Live distribution or Lua interpreter executable are available for a very large number of Operating Systems so it is also for `barracuda`. -Step by step istruction can be found in the INSTALL.txt file. +Step by step instruction can be found in the INSTALL.txt file. ## Contribute @@ -91,4 +90,4 @@ program. Please, for more legal details refer to LICENSE.txt file or visit the web page -Copyright (C) 2020 Roberto Giacomelli +Copyright (C) 2019-2022 Roberto Giacomelli diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.pdf deleted file mode 100644 index 18ba18b9c27..00000000000 Binary files a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.tex deleted file mode 100644 index 014cb9d1c41..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-ga-asm.tex +++ /dev/null @@ -1,148 +0,0 @@ -% !TeX program = LuaLaTeX -% Copyright (C) 2020 Roberto Giacomelli - -\documentclass{article} - -\usepackage{fontspec} -\setmainfont{Libertinus Serif} - -\usepackage[margin=18mm]{geometry} -\usepackage{array} -\usepackage{booktabs} - -\newcolumntype{C}{>{\ttfamily}c} -\newcolumntype{L}{>{\ttfamily}l} - -\begin{document} -Goal: describe geometrical object like lines and rectangles -mainly for a barcode drawing library. - - - -\section{\texttt{ga} instruction set} - -A graphic data specification format called '\texttt{ga}' \emph{graphic alchemy}, -or if you want \emph{generic graphic assembler}. - -\begin{verbatim} -ga := generic graphic assembler - := numeric type parameter for dimension, for example f64 or i32 - := numeric type parameter for quantity, an unsigned integer, i.e. u8 - -ga := +Elem - -Elem := Code + Args - -Code := State | Object | Fn - State := 1 -> 31 -- graphic properties - Object := 32 -> 239 -- graphic objects - Fn := 240 -> 255 -- functions - -Args : | | | - := a dimension value of type DIM - := an enumeration value of type u8 (unsigned byte) - := an unsigned integer for multiplicity - := chars sequence ended with 0 -\end{verbatim} - - - -\section{Properties} - -Colors, linecap style etc\dots - -\noindent\begin{tabular}{CLlL} -\toprule -OpCode & Mnemonic key & Graphic property & Operands\\ -\midrule - 1 & pen\_thick & Line thick & \\ - 2 & line\_cap\_style & Line cap style & \\ - 3 & line\_join\_style & Line join style & \\ - 8 & color & ... \\ -\midrule -30 & start\_bbox\_group & Stop to check the bounding box & -\\ -31 & end\_bbox\_group & Set a bounding box and restart to check & \\ -\bottomrule -\end{tabular} - - - -\section{Objects} - -\subsection{Lines} - -A segment that starts from point P1 (x1, y1) and ends to P2 (x2, y2). - -\noindent\begin{tabular}{CLlL} -\toprule -OpCode & Mnemonic key & Graphic object & Operands\\ -\midrule -32 & line & Line & \\ -33 & hline & Horizontal line & \\ -34 & vline & Vertical line & \\ -\midrule -36 & vbar & Vertical bars & ...\\ -37 & hbar & Horizontal bars & ...\\ -\midrule -38 & polyline & Open polyline & ...\\ -39 & c\_polyline & Closed polyline & ...\\ -\bottomrule -\end{tabular} - - -\subsection{Rectangles} - -\noindent\begin{tabular}{CLlL} -\toprule -OpCode & Mnemonic key & Graphic object & Operands\\ -\midrule - 48 & rect & Rectangle & \\ - 49 & f\_rect & Filled rectangle & \\ - 50 & rect\_size & Rectangle & \\ - 51 & f\_rect\_size & Filled rectangle & \\ - -\bottomrule -\end{tabular} - - -\subsection{Text} - -\noindent\begin{tabular}{CLl} -\toprule -OpCode & Mnemonic key & Graphic object/Operands\\ -\midrule - 130 & text & A text with several glyphs\\ - & & \ttfamily \\ -\midrule - 131 & text\_xspaced & A text with glyphs equally spaced on its vertical axis\\ - & & \ttfamily \\ -\midrule - 132 & text\_xwidth & Glyphs equally spaced on vertical axis between two x coordinates\\ - & & \ttfamily \\ -\midrule - & under design assessment\\ - 140 & \_text\_group & Texts on the same baseline \\ - & & \ttfamily < > \\ -\bottomrule -\end{tabular} - - -\subsection{Function} - - -\noindent\begin{tabular}{CLlL} -\toprule -OpCode & Mnemonic key & Function & Operands\\ -\midrule - 240 & move & Translate objects & \\ - 241 & copy & Copy object & ...\\ - 242 & and\_copy & Place and copy objects & ...\\ - 243 & grid & Copy next \(n\) objects on a grid & \\ - 244 & sl\_grid\\ - 250 & mirror\\ - 255 & comment & A string comment & \\ -\bottomrule -\end{tabular} - - -\end{document} diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-manual-tool.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-manual-tool.tex deleted file mode 100644 index 8b00e1c2b5a..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda-manual-tool.tex +++ /dev/null @@ -1,39 +0,0 @@ -% an auxiliary package for the manual -\directlua{ - barracuda = require "barracuda" - local v = barracuda._VERSION - local p = v:find(" ") - brcd_data = { - version = v:sub(p+1), - date = barracuda._DATE - } -} - -\newcommand{\code}[1]{\texttt{#1}} -\newcommand{\brcd}{\code{barracuda}} - -\newbox\barracudabox -\newcommand\barracuda[3][_brcd_empty_=true]{\directlua{ - local enc_name = [[#2]] - local data = [[#3]] - local opt = {#1}; - if opt._brcd_empty_ == true then - barracuda:hbox(enc_name, data, "barracudabox") - else - barracuda:hbox(enc_name, data, "barracudabox", opt) - end -}% -\leavevmode\box\barracudabox -} - -\newcommand{\brcdkey}[1]{\directlua{ - local key = [===[#1]===] - if brcd_data[key] then - tex.sprint(brcd_data[key]) - else - error("Key '"..key.."' not found") - end -}} - - - diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.pdf deleted file mode 100644 index 99d8034ea34..00000000000 Binary files a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.tex deleted file mode 100644 index 0fc6fbac28d..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/doc/barracuda.tex +++ /dev/null @@ -1,413 +0,0 @@ -% !TeX program = LuaLaTeX -% Copyright (C) 2020 Roberto Giacomelli -% Barracuda manual, main TeX source file - -\documentclass[11pt,a4paper]{article} -\usepackage{fontspec} -\usepackage{geometry} -\usepackage{fancyvrb} -\usepackage{graphicx} -\usepackage{hyperref} - -% special macro for manual typesetting -\input{barracuda-manual-tool} - -\hypersetup{ -hidelinks, -linktoc = all, -pdfinfo={ - Title={the Barracuda manual}, - Subject={Barcode printing package}, - Author={Roberto Giacomelli}, - Keywords={Barcode EAN Code128 Lua} -}} - -\setmainfont{Libertinus Serif} -\setmonofont[Scale=0.82]{Fira Mono} -\fvset{ - fontsize=\small, - frame=single, - labelposition=topline, - framesep=5pt -} -\geometry{ - left=32mm, - right=40mm, - top=22mm, - bottom=28mm -} - -\author{Roberto Giacomelli\\\small email: \url{giaconet.mailbox@gmail.com}} -\title{the \code{barracuda} manual\\[1ex] -\small \url{https://github.com/robitex/barracuda}} -\date{\small Date \brcdkey{date} --- Version \brcdkey{version} --- Beta stage} - -\begin{document} -\maketitle - -\abstract{% -Welcome to the \brcd{} software project devoted to barcode printing. - -This manual shows you how to print barcodes in your \TeX{} documents and how to -export such graphic content to an external file, using \brcd{}. - -\brcd{} is written in Lua programming language and is free software released -under the GPL 2 License.% -} - -\tableofcontents -\newpage - - -\section{Getting started} -\label{secStart} - -\subsection{Introduction} -\label{secIntro} - -Barcode symbols are usually a sequence of vertical lines representing encoded -data that can be retrived with special laser scanner or more simpler with a -smartphone running dedicated apps. Almost every store item has a label with a -printed barcode for automatic identification purpose. - -So far, \brcd{} supported symbologies are as the following: -\begin{itemize} - \item Code 39, - \item Code 128, - \item EAN family (ISBN, ISSN, EAN 8, EAN 13, and the add-ons EAN 2 and EAN 5), - \item ITF 2of5, interleaved Two of Five. -\end{itemize} - -The package provides different output graphic format. At the moment they are: -\begin{itemize} - \item PDF Portable Document Format (a modern \TeX{} engine is required), - \item SVG Scalable Vector Graphic. -\end{itemize} - -The name \brcd{} is an assonance to the name Barcode. I started the project back -in 2016 for getting barcode in my \TeX{} generated PDF documents, studying the -Lua\TeX{} technology such as direct \emph{pdfliteral node} creation. - -At the moment \brcd{} is in \emph{beta} stage. In this phase the Lua API can -change respect to the result of development research. - - -\subsection{Manual Content} - -The manual is divided into five part. In part~\ref{secIntro} introduces the -package and gives to the user a proof of concept to how to use it. The next -parts present detailed information about option parameter of each barcode -symbology and methods description to change the \emph{module} width of a EAN-13 -barcode. It's also detailed how the Lua code works internally and how to -implement a barcode symbology not already included in the package. - -The plan of the manual is (but some sections are not completed yet): -\begin{description} -\item[Part 1:] Getting started -\begin{itemize} - \item general introduction \( \to \) \pageref{secIntro} - \item print your first barcode \( \to \) \pageref{secEnter} - \item installing \brcd{} on your system \( \to \) \pageref{secInstall} -\end{itemize} - -\item[Part 2:] \LaTeX{} packages -\begin{itemize} - \item \brcd{} \LaTeX{} package \( \to \) \pageref{secLaTeXPkg} -\end{itemize} - -\item[Part 3:] Barcode Reference and Parameters -\begin{itemize} - \item encoder identification rule \( \to \) \pageref{secEncName} - \item barcode symbologies reference \( \to \) \pageref{secBcRef} -\end{itemize} - -\item[Part 4:] Advanced Work with \brcd{} -\begin{itemize} - \item Lua framework description \( \to \) \pageref{secFramework} - \item API reference \( \to \) \pageref{secAPI} - \item \code{ga} specification \( \to \) \pageref{secGA} -\end{itemize} - -\item[Part 5:] Real examples -\begin{itemize} - \item working example and use cases \( \to \) \pageref{secExample} -\end{itemize} -\end{description} - - -\subsection{Required knowledge and useful resources} - -\brcd{} is a Lua package that can be executed by any Lua interpreter. To use it, -it's necessary a minimal knowledge of Lua programming language and a certain -ability with the terminal of your computer system in order to run command line -task or make software installation. - -It's also possible to run \brcd{} directly within a \TeX{} source file, and -compile it with a suitable typesetting engine like Lua\TeX{}. In this case a -minimal \TeX{} system knowledge is required. As an example of this workflow you -simply can look to this manual because itself is typesetted with LuaLa\TeX{}, -running \brcd{} to include barcodes as a vector graphic object. - -A third way is to use the \LaTeX{} package \code{barracuda.sty} with its high -level macros. A minimal knowledge of the \LaTeX{} format is obviously required. - -Here is a collection of useful learning resources: -\begin{description} -\item[Lua:] to learn Lua the main reference is the book called PIL, Programming -in Lua from one of the language's Author Roberto Ierusalimschy. -\item[\LaTeX:] \dots -\item[Lua\TeX:] \dots -\end{description} - - -\subsection{Running Barracuda} -\label{secEnter} - -The starting point to work with \brcd{} is always a plain text file with some -code processed by a command line program with a Lua interpreter. - -The paradigm of \brcd{} is the Object Oriented Programming. Generally speaking -every object must be created with a function called \emph{costructor} and every -action must be run calling a \emph{method} of it. - -In this section you'll take a taste of \brcd{} coding in three different -execution context: a Lua script, a Lua\TeX{} document and a \LaTeX{} source file -using the macro package \code{barracuda.sty} providing an high level interface -to Lua code. - -High level package like \code{barracuda.sty} make to write Lua code unnecessary. -It will be always possible return to Lua code in order to resolve complex -barcode requirements. - - -\subsubsection{A Lua script} - -As a practical example to produce an EAN~13 barcode, open a text editor of your -choice on an empty file and save it as \code{first-run.lua} with the content of -the following two lines of code: -\medskip -\begin{Verbatim}[label=\footnotesize\code{first-run.lua}] -local barracuda = require "barracuda" -barracuda:save("ean-13", "8006194056290", "my_barcode", "svg") -\end{Verbatim} - -What you have done is to write a \emph{script}. If you have installed a Lua -interpreter along with \brcd{}, open a terminal and run it with the command: -\begin{Verbatim} -$ lua first-run.lua -\end{Verbatim} - -You will see in the same directory of your script, appearing a new file called -\code{my\_barcode.svg} with the drawing: -\begin{center} -\includegraphics{image/8006194056290} -\end{center} - -Coming back to the script first of all, it's necessary to load the library -\brcd{} with the standard Lua function \code{require()} that returns an -object---more precisely a reference to a table where are stored all the -package machinery. - -With the second line of code, an EAN~13 barcode is saved as -\code{my\_barcode.svg} using the method \code{save()} of the \brcd{} object. The -\code{save()} method takes in order the barcode symbology identifier called -\emph{treename}, an argument as a string or as a whole number that represents -data to be encoded, the output file name and the optional output format. With a -fifth optional argument we can pass options to the barcode encoder as a Lua -table. - -Each encoder has an own identifier called treename explained at -section~\ref{secEncName}. In short, in \brcd{} we can build more encoders of the -same symbology with different parameters. - - -\subsubsection{A Lua\TeX{} source file} - -\brcd{} can also runs with Lua\TeX{} and any others Lua powered \TeX{} -engines. The source file is a bit difference respect to the previuos script: the -Lua code lives inside the argument of a \verb=\directlua= primitive, moreover we -must use an horizontal box register as output destination. -\begin{Verbatim} -% !TeX program = LuaTeX -\newbox\mybox -\directlua{ - local require "barracuda" - barracuda:hbox("ean-13", "8006194056290", "mybox") -}\leavevmode\box\mybox -\bye -\end{Verbatim} - -The method \code{hbox()} works only with Lua\TeX{}. It takes three\footnote{A -fourth argment is optional as a table with user defined barcode parameters.} -arguments: encoder \emph{treename}, encoding data as a string, the \TeX{} -horizontal box name. - - -\subsubsection{A Lua\LaTeX{} source file} - -\LaTeX{} working minimal example would be: -\begin{Verbatim} -% !TeX program = LuaLaTeX -\documentclass{article} -\usepackage{barracuda} -\begin{document} -\barracuda{ean-13}{8006194056290} -\end{document} -\end{Verbatim} - - -\subsection{A more deep look} - -\brcd{} is designed to be modular and flexible. For example it is possible to -draw different barcodes on the same canvas or tune barcode parameters. - -The main workflow to draw a barcode object reveals more details on internal -structure. In fact, to draw an EAN~13 barcode we must do at least the following -steps: -\begin{enumerate} -\item load the library, -\item get a reference to the \code{Barcode} abstract class, -\item build an \code{ean} encoder of the variant \code{13}, -\item build an EAN~13 symbol passing data to a costructor, -\item get a reference to a new canvas object, -\item draw barcode on the canvas object, -\item get a reference of the driver object, -\item print the graphic material saving an external \code{svg} file. -\end{enumerate} - -Following that step by step procedure the corresponding code is translated in -the next listing: -\begin{Verbatim} --- lua script -local barracuda = require "barracuda" -- step 1 -local barcode = barracuda:barcode() -- step 2 - -local ean13, err_enc = barcode:new_encoder("ean-13") -- step 3 -assert(ean13, err_enc) - -local symb, err_symb = ean13:from_string("8006194056290") -- step 4 -assert(symb, err_symb) - -local canvas = barracuda:new_canvas() -- step 5 -symb:append_ga(canvas) -- step 6 - -local driver = barracuda:get_driver() -- step 7 -local ok, err_out = driver:save("svg", canvas, "my_barcode") -- step 8 -assert(ok, err_out) -\end{Verbatim} - -Late the manual will give objects and methods references at -section~\ref{secAPI}. - - -\subsection{Installing} -\label{secInstall} - -\subsubsection{Installing for Lua} - -Manually copy \code{src} folder content to a suitable directory of your system -that is reachable to the system Lua interpreter. - -\subsubsection{Installing for TeX Live} - -If you have TeX Live installed from CTAN or from DVD TeX Collection, before any -modification to your system check if the package is already installed looking -for \emph{installed} key in the output of the command: -\begin{Verbatim} -$ tlmgr show barracuda -\end{Verbatim} - -If `barracuda` is not present, run the command: -\begin{Verbatim} -$ tlmgr install barracuda -\end{Verbatim} - -If you have installed TeX Live via Linux OS repository try your distribution's -package management system running a software update. - -It's also possible to install the package manually: -\begin{enumerate} -\item Grab the sources from CTAN or \url{https://github.com/robitex/barracuda}. -\item Unzip it at the root of one or your TDS trees (local or personal). -\item You may need to update some filename database after this, see your \TeX{} -distribution's manual for details. -\end{enumerate} - - -\section{Barracuda \LaTeX{} Package} -\label{secLaTeXPkg} - -The \LaTeX{} package delivered with \brcd{} is still under an early stage of -development. The only macro available is \verb=\barracuda{encoder}{data}=. -A simple example is the following source file for Lua\LaTeX{}: -\begin{Verbatim} -% !TeX program = LuaLaTeX -\documentclass{article} -\usepackage{barracuda} -\begin{document} -\leavevmode -\barracuda{code39}{123ABC}\\ -\barracuda{code128}{123ABC} -\end{document} -\end{Verbatim} - -Every macro \verb=\barracuda= typesets a barcode symbol with the encoder defined -in the first argument, encoding data defined by the second. - - -\section{Barcode parameters} -\label{secBarcodeReference} - -\subsection{Encoder treename} -\label{secEncName} - -TODO - -\subsection{Barcode Reference} -\label{secBcRef} - -TODO - -\section{Developer zone} - -\subsection{The Barracuda Framework} -\label{secFramework} - -The \brcd{} package framework consists in indipendent modules: a barcode class -hierarchy encoding a text into a barcode symbology; a geometrical library called -\code{libgeo} representing several graphic objects; an encoding library for the -\code{ga} format (graphic assembler) and several driver to \emph{print} a ga -stream into a file or a \TeX{} hbox register. - -To implement a barcode encoder you have to write a component called -\emph{encoder} defining every parameters and implementing the encoder builder, -while a driver must understand ga opcode stream and print the corresponding -graphic object. - -Every barcode encoder come with a set of parameters, some of them can be -reserved and can't be edit after the encoder was build. So, you can create many -instances of the same encoder for a single barcode type, with its own parameter -set. - -The basic idea is getting faster encoders, for which the user may set up -paramenters at any level: barcode abstract class, encoder globally, down to a -single symbol object. - -The Barcode class is completely indipendent from the ouput driver and viceversa. - -\subsection{Lua API reference} -\label{secAPI} - -TODO - -\subsection{\code{ga} specification} -\label{secGA} - -TODO - -\section{Example and use cases} -\label{secExample} - -TODO - -\end{document} diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.pdf new file mode 100644 index 00000000000..18ba18b9c27 Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.tex new file mode 100644 index 00000000000..ff8d3e1ff4c --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/doc/ga-graphic-asm/barracuda-ga-asm.tex @@ -0,0 +1,148 @@ +% !TeX program = LuaLaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli + +\documentclass{article} + +\usepackage{fontspec} +\setmainfont{Libertinus Serif} + +\usepackage[margin=18mm]{geometry} +\usepackage{array} +\usepackage{booktabs} + +\newcolumntype{C}{>{\ttfamily}c} +\newcolumntype{L}{>{\ttfamily}l} + +\begin{document} +Goal: describe geometrical object like lines and rectangles +mainly for a barcode drawing library. + + + +\section{\texttt{ga} instruction set} + +A graphic data specification format called '\texttt{ga}' \emph{graphic alchemy}, +or if you want \emph{generic graphic assembler}. + +\begin{verbatim} +ga := generic graphic assembler + := numeric type parameter for dimension, for example f64 or i32 + := numeric type parameter for quantity, an unsigned integer, i.e. u8 + +ga := +Elem + +Elem := Code + Args + +Code := State | Object | Fn + State := 1 -> 31 -- graphic properties + Object := 32 -> 239 -- graphic objects + Fn := 240 -> 255 -- functions + +Args : | | | + := a dimension value of type DIM + := an enumeration value of type u8 (unsigned byte) + := an unsigned integer for multiplicity + := chars sequence ended with 0 +\end{verbatim} + + + +\section{Properties} + +Colors, linecap style etc\dots + +\noindent\begin{tabular}{CLlL} +\toprule +OpCode & Mnemonic key & Graphic property & Operands\\ +\midrule + 1 & pen\_thick & Line thick & \\ + 2 & line\_cap\_style & Line cap style & \\ + 3 & line\_join\_style & Line join style & \\ + 8 & color & ... \\ +\midrule +29 & enable\_bbox & start to update the bounding box & -\\ +30 & disable\_bbox & Stop to check the bounding box & -\\ +31 & set\_bbox & Set a bounding box & \\ +\bottomrule +\end{tabular} + + + +\section{Objects} + +\subsection{Lines} + +A segment that starts from point P1 (x1, y1) and ends to P2 (x2, y2). + +\noindent\begin{tabular}{CLlL} +\toprule +OpCode & Mnemonic key & Graphic object & Operands\\ +\midrule +32 & line & Line & \\ +33 & hline & Horizontal line & \\ +34 & vline & Vertical line & \\ +\midrule +36 & vbar & Vertical bars & ...\\ +37 & hbar & Horizontal bars & ...\\ +\midrule +38 & polyline & Open polyline & ...\\ +39 & c\_polyline & Closed polyline & ...\\ +\bottomrule +\end{tabular} + + +\subsection{Rectangles} + +\noindent\begin{tabular}{CLlL} +\toprule +OpCode & Mnemonic key & Graphic object & Operands\\ +\midrule + 48 & rect & Rectangle & \\ + 49 & f\_rect & Filled rectangle & \\ + 50 & rect\_size & Rectangle & \\ + 51 & f\_rect\_size & Filled rectangle & \\ +\bottomrule +\end{tabular} + + +\subsection{Text} + +\noindent\begin{tabular}{CLl} +\toprule +OpCode & Mnemonic key & Graphic object/Operands\\ +\midrule + 130 & text & A text with several glyphs\\ + & & \ttfamily \\ +\midrule + 131 & text\_xspaced & A text with glyphs equally spaced on its vertical axis\\ + & & \ttfamily \\ +\midrule + 132 & text\_xwidth & Glyphs equally spaced on vertical axis between two x coordinates\\ + & & \ttfamily \\ +\midrule + & under design assessment\\ + 140 & \_text\_group & Texts on the same baseline \\ + & & \ttfamily < > \\ +\bottomrule +\end{tabular} + + +\subsection{Function} + + +\noindent\begin{tabular}{CLlL} +\toprule +OpCode & Mnemonic key & Function & Operands\\ +\midrule + 240 & move & Translate objects & \\ + 241 & copy & Copy object & ...\\ + 242 & and\_copy & Place and copy objects & ...\\ + 243 & grid & Copy next \(n\) objects on a grid & \\ + 244 & sl\_grid\\ + 250 & mirror\\ + 255 & comment & A string comment & \\ +\bottomrule +\end{tabular} + + +\end{document} diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/image/8006194056290.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/image/8006194056290.pdf deleted file mode 100644 index 8effe87846a..00000000000 Binary files a/Master/texmf-dist/doc/luatex/barracuda/doc/image/8006194056290.pdf and /dev/null differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual-tool.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual-tool.tex new file mode 100644 index 00000000000..3b19fd5ab58 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual-tool.tex @@ -0,0 +1,49 @@ +% an auxiliary package for the manual +\directlua{ + barracuda = require "barracuda" + local v = barracuda._VERSION + local p = v:find(" ") + brcd_data = { + version = v:sub(p+1), + date = barracuda._DATE + } +} + +\newcommand{\code}[1]{\texttt{#1}} +\newcommand{\brcd}{\code{barracuda}} + +\newbox\barracudabox +\newcommand\barracuda[3][_brcd_empty_=true]{\directlua{ + local enc_name = [[#2]] + local data = [[#3]] + local opt = {#1}; + if opt._brcd_empty_ == true then + barracuda:hbox(enc_name, data, "barracudabox") + else + barracuda:hbox(enc_name, data, "barracudabox", opt) + end +}% +\leavevmode\box\barracudabox +} + +\newcommand{\brcdkey}[1]{\directlua{ + local key = [===[#1]===] + if brcd_data[key] then + tex.sprint(brcd_data[key]) + else + error("Key '"..key.."' not found") + end +}} + +\newcommand{\brcdparametertab}[1]{\directlua{ + local enc_id = [=[#1]=] + local t = {} + tex.print() + + local barcode = barracuda:barcode() + local info = barcode:info() + local param = info.param + +}} + +\endinput diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.pdf new file mode 100644 index 00000000000..af224cc148f Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.tex b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.tex new file mode 100644 index 00000000000..971650e8136 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/barracuda-manual.tex @@ -0,0 +1,1312 @@ +% !TeX program = LuaLaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli +% Barracuda manual, main TeX source file + +\documentclass[11pt,a4paper]{article} +\usepackage{fontspec} +\usepackage{geometry} +\usepackage{fancyvrb} +\usepackage{graphicx} +\usepackage{booktabs} +\usepackage{array} +\usepackage{tikz} +\usepackage{tcolorbox} +\usepackage{hyperref} + +\newcolumntype{C}{>{\ttfamily}c} +\newcolumntype{L}{>{\ttfamily}l} + +\usetikzlibrary{arrows.meta} + +% special macro for manual typesetting +\input{barracuda-manual-tool} + +\tcbuselibrary{skins} +\tcbset{ + sharpish corners, + drop shadow=gray!75, + halign lower=center, + left=5pt, + boxrule=1.2pt, + titlerule=0.8pt, + colback=green!10!white, + colbacktitle=green!10!white, + coltitle=black, + bicolor,colbacklower=white, + righthand width=80pt +} + +\hypersetup{ +hidelinks, +linktoc = all, +pdfinfo={ + Title={The Barracuda manual}, + Subject={Barcode printing package}, + Author={Roberto Giacomelli}, + Keywords={Barcode EAN UPC Code128 ITF14 Lua} +}} +\definecolor{CodeBlue}{rgb}{0.05,0.05,0.80} +\setmainfont{Libertinus Serif} +\setmonofont[Scale=0.82]{Fira Mono} +\fvset{ + fontsize=\small, + labelposition=topline, + formatcom=\color{black}, +} +\geometry{ + left=38mm, + right=28mm, + top=22mm, + bottom=28mm +} + +\author{Roberto Giacomelli\\\small email: \url{giaconet.mailbox@gmail.com}} +\title{the \code{barracuda} manual\\[1ex] +\small \url{https://github.com/robitex/barracuda}} +\date{\small Date \brcdkey{date} --- Version \brcdkey{version} --- Beta stage} + +\newbox\mybox + +\begin{document} +\maketitle + +\abstract{% +Welcome to the \brcd{} software project devoted to barcode printing. + +This manual shows you how to print barcodes in your \TeX{} documents and how to +export such graphic content to an external file. + +\brcd{} is written in Lua and is free software released under the GPL 2 License. +} + +\tableofcontents +\newpage + + +\section{Getting started} +\label{secStart} + +\subsection{Introduction} +\label{secIntro} + +Barcode symbols are usually a sequence of vertical lines representing encoded +data that can be retrived with special laser scanner or more simpler with a +smartphone running dedicated apps. Almost every store item has a label with a +printed barcode for automatic identification purpose. + +So far, \brcd{} supported symbologies are as the following: +\begin{itemize} +\item Code 39, +\item Code 128, +\item EAN family (ISBN, ISSN, EAN 8, EAN 13, and the add-ons EAN 2 and EAN 5), +\item ITF 2of5, interleaved Two of Five (ITF14, i2of5 in general), +\item UPC-A. +\end{itemize} + +The package provides different output graphic format. At the moment they are: +\begin{itemize} +\item PDF Portable Document Format (a modern \TeX{} engine is required), +\item SVG Scalable Vector Graphic. +\end{itemize} + +The name \brcd{} is an assonance to the name Barcode. I started the project back +in 2016 for getting barcode in my \TeX{} generated PDF documents, studying the +Lua\TeX{} technology such as direct \emph{pdfliteral} node creation. + +At the moment \brcd{} is in \emph{beta} stage. In this phase the Lua API may +change respect to the result of development activity. + + +\subsection{Manual Content} + +The manual is divided into five part. In part~\ref{secIntro} introduces the +package and gives to the user a proof of concept to how to use it. The next +parts present detailed information about option parameter of each barcode +symbology and methods description to change the \emph{module} width of a EAN-13 +barcode. It's also detailed how the Lua code works internally and how to +implement a barcode symbology not already included in the package. + +The manual plan is: +\begin{description} +\item[Part 1:] Getting started +\begin{itemize} + \item general introduction \( \to \) \pageref{secIntro} + \item print your first barcode \( \to \) \pageref{secEnter} + \item installing \brcd{} on your system \( \to \) \pageref{secInstall} +\end{itemize} + +\item[Part 2:] \LaTeX{} packages +\begin{itemize} + \item \brcd{} \LaTeX{} package \( \to \) \pageref{secLaTeXPkg} +\end{itemize} + +\item[Part 3:] Barcode Reference +\begin{itemize} + \item barcode symbologies reference \( \to \) \pageref{secBcRef} +\end{itemize} + +\item[Part 4:] Developer zone +\begin{itemize} + \item the Lua framework \( \to \) \pageref{secFramework} + \item encoder identification rule \( \to \) \pageref{secEncName} + \item API reference \( \to \) \pageref{secAPI} + \item \code{ga} specification \( \to \) \pageref{secGA} +\end{itemize} + +\item[Part 5:] Real examples +\begin{itemize} + \item working example and use cases \( \to \) \pageref{secExample} +\end{itemize} +\end{description} + + +\subsection{Required knowledge and useful resources} + +\brcd{} is a Lua package that can be executed by any Lua interpreter. To use it, +it's necessary a minimal knowledge of Lua programming language and a certain +ability with the terminal of your computer system in order to run command line +task or make software installation. + +It's also possible to run \brcd{} directly within a \TeX{} source file, and +compile it with a suitable typesetting engine like Lua\TeX{}. In this case a +minimal \TeX{} system knowledge is required. As an example of this workflow you +simply can look to this manual because itself is typesetted with LuaLa\TeX{}, +running \brcd{} to include barcodes as a vector graphic object. + +A third way is to use the \LaTeX{} package \code{barracuda.sty} with its high +level macros. A minimal knowledge of the \LaTeX{} format is obviously required. + +Here is a collection of useful learning resources: +\begin{description} +\item[Lua:] to learn Lua the main reference is the book called PIL that stands +for Programming in Lua from one of the language's Author Roberto Ierusalimschy. +\item[Lua\TeX:] the typesetting engine manual can be opened running the +\code{texdoc} utility in a terminal window of your system, typing the command: +\begin{Verbatim} +$ texdoc luatex +\end{Verbatim} +\end{description} + + +\subsection{Running Barracuda} +\label{secEnter} + +The starting point to work with \brcd{} is always a plain text file with some +code processed by a command line program with a Lua interpreter. + +In this section you'll take a taste of \brcd{} coding in three different +execution context: a Lua script, a Lua\TeX{} document and a \LaTeX{} source file +using the macro package \code{barracuda.sty} providing an high level interface +to the Lua library. + +High level package like \code{barracuda.sty} make to write Lua code unnecessary. +It will be always possible to return to Lua code in order to resolve complex +barcode requirements. + + +\subsubsection{A Lua script} + +The paradigm of \brcd{} is the Object Oriented Programming. Generally speaking +every library object must be created with a function called \emph{constructor} +and every action on it must be run calling an object \emph{method}. + +In Lua a constructor or even a method call syntax it's a little bit different +from the usual form because we have to use the \emph{colon notation}: +\begin{BVerbatim} +object:method(args) +\end{BVerbatim} + +As a practical example, to produce an EAN~13 barcode, open a text editor of your +choice on an empty file and save it as \code{first-run.lua} with the content of +the following two lines of code: +\begin{tcolorbox}[ + title={\code{first-run.lua}} +] +\begin{BVerbatim} +local barracuda = require "barracuda" +barracuda:save("ean-13", "8006194056290", "my_barcode", "svg") +\end{BVerbatim} +\end{tcolorbox} + +What you have done is to write a \emph{script}. If you have installed a Lua +interpreter along with \brcd{}, open a terminal and run it with the command: +\begin{BVerbatim} +$ lua first-run.lua +\end{BVerbatim} + +Into the same directory of your script you will see a new file called +\code{my\_barcode.svg} with the drawing: +\begin{center} +\includegraphics{image/8006194056290} +\end{center} + +Coming back to the script, the first statement loads the library \brcd{} with +the standard Lua function \code{require()} that returns an object---more +precisely a reference to a table where are stored all the package machinery. + +With the second line of code, an EAN~13 barcode is saved as +\code{my\_barcode.svg} using the method \code{save()} of the \brcd{} object. The +\code{save()} method takes four mandatory argumetns: the barcode symbology +identifier called \emph{treename}, an argument as a string or as a whole number +that represents data to be encoded, the output file name and the optional output +format. With a fifth optional argument we can pass options to the barcode +encoder as a Lua table in the \code{option=value} format. + +In more detail, thanks to treename identifier explained at +section~\ref{secEncName} is possible to build more encoders of the same +symbology each with a different set of parameters. + +It's also possible to run a Lua script with \code{texlua}, the Lua interpreter +improved with certain Lua\TeX{} libraries delivered by any modern \TeX{} +distribution. \code{texlua} saves you to install Lua if you are a \TeX{} user. + +The command to run \code{first-run.lua} is the same as before, just a +substitution of the name \code{lua} with \code{texlua}, but an adjustment is +required if we want to run the script with \TeX{} delivered \brcd{} library +leaving untouched the system outside \code{texmf}. + +An alternative path searching procedure consists to find the main file of +\brcd{} with an internal Lua\TeX{} library called \code{kpse}: +\begin{Verbatim} +-- texlua script +kpse.set_program_name("luatex") +local path_to_brcd = kpse.find_file("barracuda", "lua") +local barracuda = dofile(path_to_brcd) +barracuda:save("ean-13", "8006194056290", "my_barcode", "svg") +\end{Verbatim} + + +\subsubsection{A Lua\TeX{} source file} + +\brcd{} can also runs with Lua\TeX{} and any others Lua powered \TeX{} +engines. The source file is a bit difference respect to the previous script: the +Lua code lives inside the argument of a \verb=\directlua= primitive, moreover we +must use an horizontal box register as the output destination. +\begin{tcolorbox}[ + title={\code{first-run.tex}: Lua\TeX{} version} +] +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local require "barracuda" + barracuda:hbox("ean-13", "8006194056290", "mybox") +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\end{tcolorbox} +The method \code{hbox()} works only with Lua\TeX{}. It takes three\footnote{A +fourth argment is optional as a table with user defined barcode parameters.} +arguments: encoder \emph{treename}, encoding data as a string, the \TeX{} +horizontal box name. + + +\subsubsection{A Lua\LaTeX{} source file} + +A \LaTeX{} working minimal example would be: +\begin{tcolorbox}[ + sidebyside, + title={\code{first-run.tex}: Lua\LaTeX{} version}, + righthand width=120pt +] +\begin{BVerbatim} +% !TeX program = LuaLaTeX +\documentclass{article} +\usepackage{barracuda} +\begin{document} +\barracuda{ean-13}{8006194056290} +\end{document} +\end{BVerbatim} +\tcblower\ttfamily +\hfill\barracuda{ean-13}{8006194056290}\hfill\hbox{} +\end{tcolorbox} + + +\subsection{A more deep look} + +\brcd{} is designed to be modular and flexible. For example it is possible to +draw different barcodes on the same canvas or tuning barcode parameters. + +The low level workflow to draw a barcode object reveals more details on the +internal architecture. In fact, we must do at least the following steps divided +into three phases: +\begin{description} +\item[a.1] load the library, +\item[a.2] get a reference to the \code{Barcode} abstract class, +\item[a.3] build an encoder, +\item[a.4] build a symbol passing data to an encoder's constructor, +\item[b.1] get a reference to a new canvas object, +\item[b.2] draw barcode on the canvas object, +\item[c.1] load the driver, +\item[c.2] print the figure as an external \code{svg} file. +\end{description} + +In the phase \textbf{a} a barcode symbols is created, then in phase \textbf{b} a +canvas object is filled with the graphic elements of the symbol, and finally in +the phase \textbf{c} the canvas is sent to the driver output channel. + +Following the procedure step by step, the resulting code is as the following +listing, where the encoder is EAN variant 13: +\begin{tcolorbox} +\begin{BVerbatim} +-- a lua script +local barracuda = require "barracuda" -- step a.1 +local barcode = barracuda:barcode() -- step a.2 +local ean13, err_enc = barcode:new_encoder("ean-13") -- step a.3 +assert(ean13, err_enc) +local symb, err_symb = ean13:from_string("8006194056290") -- step a.4 +assert(symb, err_symb) + +local canvas = barracuda:new_canvas() -- step b.1 +symb:draw(canvas) -- step b.2 + +local drv = barracuda:get_driver() -- step c.1 +local ok, err_out = drv:save("svg", canvas, "my_barcode") -- step c.2 +assert(ok, err_out) +\end{BVerbatim} +\end{tcolorbox} + +Anyway, more abstract methods allow the user to write a more compact code. For +instance, phase \textbf{b} can be fuse with \textbf{c}, thanks to a +a reference to the driver object included in the \code{canvas} object: +\begin{Verbatim} +-- phase b + c +local canvas = barracuda:new_canvas() -- step bc.1 +symb:draw(canvas) -- step bc.2 +local ok, err_out = canvas:save("svg", "my_barcode") -- step bc.3 +assert(ok, err_out) +\end{Verbatim} + +As we have been seen before an high level method provides a way to unify all the +phases: +\begin{Verbatim} +-- unique phase version +local require "barracuda" +barracuda:save("ean-13", "8006194056290", "my_barcode", "svg") +\end{Verbatim} + +Low level code offers more control while high level programming is quite +compact. Late in the manual you will find the objects and methods reference at +section~\ref{secAPI}. + + +\subsection{Installing \brcd} +\label{secInstall} + +\subsubsection{Installing for Lua} + +Manually copy \code{src} folder content to a suitable directory of your system +that is reachable to the system Lua interpreter. + + +\subsubsection{Installing for TeX Live} + +If you have TeX Live installed from CTAN or from DVD TeX Collection, before any +modification to your system check if the package is already installed looking +for \emph{installed} key in the output of the command: +\begin{Verbatim} +$ tlmgr show barracuda +\end{Verbatim} + +If \brcd{} is reported as not installed, run the command: +\begin{Verbatim} +$ tlmgr install barracuda +\end{Verbatim} + +If you have installed TeX Live via your Linux repository, try your +distribution's package manager an update or check for optional packages not yet +installed. + +It's also possible to install \brcd{} manually with these steps: +\begin{enumerate} +\item Grab the sources from CTAN or from the official repository +\url{https://github.com/robitex/barracuda}. +\item Unzip it at the root of one of your TDS trees (local or personal). +\item You may need to update some filename database after this, see your \TeX{} +distribution's manual for details. +\end{enumerate} + + +\section{Barracuda \LaTeX{} Package} +\label{secLaTeXPkg} + +The \LaTeX{} package delivered with \brcd{} is still under an early stage of +development. The only macro available is +\verb=\barracuda[option]{encoder}{data}=. A simple example is the following +source file for Lua\LaTeX{}: +\begin{tcolorbox}[sidebyside] +\begin{BVerbatim} +% !TeX program = LuaLaTeX +\documentclass{article} +\usepackage{barracuda} +\begin{document} +\leavevmode +\barracuda{code128}{123ABC}\\[2ex] +\barracuda[text_star=true]{code39}{123ABC} +\end{document} +\end{BVerbatim} +\tcblower +\leavevmode +\barracuda{code128}{123ABC}\\[2ex] +\barracuda[text_star=true]{code39}{123ABC} +\end{tcolorbox} + +Every macro \brcd{} typesets a barcode symbol with the encoder defined in the +first argument, encoding data defined by the second. + + +\section{Barcode Reference} +\label{secBcRef} + +\begin{figure} +\centering +\begin{tikzpicture} +\ttfamily +\draw (-20mm, -20mm) rectangle (20mm, 20mm); +\end{tikzpicture} +\caption{Barcode class hierarchy.} +\label{figBarcodeHierarchy} +\end{figure} + +\subsection{Common, Global and Local Barcode Options} + +Every barcode encoder inherits from \code{Barcode} abstract class methods and +options. If we change its option values, the changes will be global for all the +encoders except if the encoder has not an own local option overwritten before. + +The same schema applying also for encoder and the barcode symbols build apart +from it. Every symbol inherits methods and options from its encoder. + +Such three levels option system is designed to allow the user to set up option +not only in a certain point in the tree object, but also any time in the code. +When changes are accepted by an object they become valid for that time on. + +The architecture of barcode classes is shown in more details in +figure~\ref{figBarcodeHierarchy}. At the top of the hierarchy there is the +\code{Barcode} class. It's an abstract class in the sense that no symbols can be +printed by that class. + +At an intermediate level we found a \code{Builder} with an instance of one of +its \code{Encoder} class. When we call method \code{new\_encoder()} provided by +\code{Barcode} class, what really happen is the loading of the \code{Builder} if +not just loaded before, that is the actual library of the specific simbology, +and a linked \code{Encoder} object incorporates its own options. + +At the last level are placed the symbol instances derived both from the +\code{Builder} and \code{Encoder}, the first provides methods while the second +provides option values. Only these objects are printable in a barcode graphic. + +Common options of \code{Barcode} are the following: +\begin{center} +\begin{tabular}{@{}ccp{75mm}@{}} +\toprule +Option Id & Type/default & Description\\ +\midrule +\code{ax} & numeric/0 & Relative x-coordinate for insertion point of the barcode symbol\\ +\midrule +\code{ay} & numeric/0 & Relative y-coordinate for insertion point of the barcode symbol\\ +\midrule +\code{debug\_bbox} & enum/\code{none} & Draw symbol bounding box with a thin dashed line\\ + & \code{none} & \small do nothing\\ + & \code{symb} & \small draw the bbox of the symbol\\ + & \code{qz} & \small draw the bbox at quietzone border\\ + & \code{qzsymb} & \small draw symbol and quietzone bboxes\\ +\bottomrule +\end{tabular} +\end{center} + + +For each barcode symbologies the next section reports parameters and optional +methods of it. + +\subsection{Code39} +\label{secCode39} + +\code{Code39} is one of the oldest symbologies ever invented. It doesn't include +any checksum digit and the only encodable characters are digits, uppercase +letters and a few symbol like \code{+} or \code{\$}. + + + + + +\subsection{Code128} +\label{secCode128} + + + +% devzone color setup +\tcbset{ + colback=blue!10!white, + colbacktitle=blue!10!white, +} + +\section{Developer zone} + +\subsection{The Barracuda Framework} +\label{secFramework} + +The \brcd{} package framework consists in independent modules: a barcode class +hierarchy encoding a text into a barcode symbology; a geometrical library called +\code{libgeo} modeling several graphic objects; an encoding library for the +\code{ga} format (graphic assembler) and several driver to \emph{print} a +\code{ga} stream into a file or in a \TeX{} \code{hbox} register. + +To implement a barcode encoder you have to write a component called +\emph{encoder} defining every parameters and implementing the encoder builder, +while a driver must understand ga opcode stream and print the corresponding +graphic object. + +Every barcode encoder come with a set of parameters, some of them can be +reserved and can't be edit after the encoder was build. So, you can create many +instances of the same encoder for a single barcode type, with its own parameter +set. + +The basic idea is getting faster encoders, for which the user may set up +parameters at any level: barcode abstract class, encoder globally, down to a +single symbol object. + +The Barcode class is completely independent from the output driver and vice +versa. + + +\subsection{Error Management} + +Functions in Lua may return more than one parameters. \brcd{} methods takes +advantage by this feature for the error management. In fact, \brcd{} as a +library, remind the responsibility to the caller in order to choose what to do +in case an error is reported. + +When a method may fail depending on the correctness of the input, it returns two +parameters alternatively valid: the first is the expected result while the +second is the error description. + +This behavior perfectly match the arguments required by the \code{assert()} +built-in function. + + + + +\subsection{Encoder Treename} +\label{secEncName} + +In \brcd{} in order to draw a barcode symbol it's necessary to create an +\code{Encoder} object + + +\subsection{API reference of Lua modules} +\label{secAPI} + +TODO + +\subsection{\code{ga} specification} +\label{secGA} + +This section defines and explains with code examples the \code{ga} instruction +stream. \code{ga} stands for \emph{graphic assembler}, a sort of essential +language that describes geometrical object like lines and rectangles mainly for +a barcode drawing library on a cartesian plane \( (O, x, y) \). + +The major goal of any \brcd{} encoder is to create the \code{ga} stream +corresponding to a vector drawing of a barcode symbol. + +In details, a \code{ga} stream is a numeric sequence that like a program defines +what must be draw. It is not a fully binary sequence---which is a byte stream +and ideally is what a \code{ga} stream would really be---but a sequence of +integers or floating point numbers. + +In Lua this is very easy to implement. Simply append a numeric value to a table +that behave as an array. Anyway \code{ga} must be basically a binary format +almost ready to be sent or received by means of a network channel. + +In the Backus–Naur form a valid \code{ga} stream grammar is described by the +following code: +\begin{Verbatim} + ::= + ::= + | + ::= + | + + ::= + | + | + ::= 1 .. 31; graphic properties + ::= 32 .. 239; graphic objects + ::= 240 .. 255; functions + + ::= + | + ::= + | + | + | + | + | + | + | + + ::= f64; unit measure scaled point sp = 1/65536pt + ::= f64; unit measure scaled point sp = 1/65536pt + ::= u64 + ::= 0 + ::= + | + ::= u64 + ::= u8 + ::= f64 + ::= + | + ::= + ::= + ::= + ::= + | + := + +; u8 unsigned 8 bit integer +; u64 unsigned 64 bit integer +; f64 floating point 64 bit number +\end{Verbatim} + + +Every \code{} changes the graphic state---for instance the current +line width---or defines a graphic object, depending on the \code{opcode} value. +Coordinates or dimensions must be expressed as \emph{scaled point}, the +basic unit of measure of \TeX{} equivalent to \( 1/65536\, \)pt. + + +\subsubsection{Hard coded an horizontal line} + +The \code{opcode} for the \code{linewidth} operation is 1, while +for the \code{hline} operation is 33. An horizontal line 6pt width from the +point (0pt, 0pt) to the point (32pt, 0pt) is represented by this \code{ga} +stream: +\begin{Verbatim} +1 393216 33 0 2097152 0 +\end{Verbatim} + +Introducing \code{mnemonic opcode} in \code{opcode} places and separate the +operations in a multiline fashion, the same sequence become more readable and +more similar to an assembler listing: +\begin{Verbatim} +linewidth 393216 ; set line width to 393216sp +hline 0 2097152 0 ; draw hline x1 x2 y +\end{Verbatim} + +To prove and visualize the meaning of the stream, we can simply use the native +graphic driver of \brcd{} compiling this Lua\TeX{} source file: +\begin{Verbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local ga = {1, 393216, 33, 0, 2097152, 0} + local drv = barracuda:get_driver() + drv:ga_to_hbox(ga, "mybox") +}\leavevmode\box\mybox +\bye +\end{Verbatim} + +The result is:\directlua{ +local ga = {1, 393216, 33, 0, 2097152, 0} +local drv = barracuda:get_driver() +drv:ga_to_hbox(ga, "mybox") +}\box\mybox + + +\subsubsection{Encoding \code{ga} with the \code{gaCanvas} class} + +A more abstract way to write a \code{ga} stream is provided by the +\code{gaCanvas} class of the \code{libgeo} module. Every operation with +identifier \code{opcode} is mapped to a method named \code{encode\_()} +of a canvas object: +\begin{Verbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local canvas = barracuda:new_canvas() + local pt = canvas.pt + canvas:encode_linewidth(6*pt) + canvas:encode_hline(0, 32*pt, 0) + local drv = barracuda:get_driver() + drv:ga_to_hbox(canvas, "mybox") + tex.print("[") + for _, n in ipairs(canvas:get_stream()) do + tex.print(tostring(n)) + end + tex.print("]") +} results in \box\mybox +\bye +\end{Verbatim} + +The stream is printed beside the drawing in the output PDF file. Therefore the +same \code{ga} stream can also generate a different output, for instance a SVG +file. For this purpose execute the \code{save()} method of the \code{Driver} +class (the drawing is showed side-by-side the listing): +\begin{tcolorbox}[sidebyside] +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local canvas = barracuda:new_canvas() + local pt = canvas.pt + local side = 16*pt + local s = side/2 - 1.5*pt + local l = side/2 - 2*pt + local dim = 4 + canvas:encode_linewidth(1*pt) + canvas:encode_disable_bbox() + for c = 0, dim do + for r = 0, dim do + local x, y = c*side, r*side + canvas:encode_hline(x-l, x+l, y-s) + canvas:encode_hline(x-l, x+l, y+s) + canvas:encode_vline(y-l, y+l, x-s) + canvas:encode_vline(y-l, y+l, x+s) + end + end + local b1 = -s - 0.5*pt + local b2 = dim*side + s + 0.5*pt + canvas:encode_set_bbox(b1, b1, b2, b2) + canvas:ga_to_hbox("mybox") + canvas:save("svg", "grid") +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\tcblower +\directlua{ + local canvas = barracuda:new_canvas() + local pt = canvas.pt + local side = 16*pt + local s = side/2 - 1.5*pt + local l = side/2 - 2*pt + local dim = 4 + canvas:encode_linewidth(1*pt) + canvas:encode_disable_bbox() + for c = 0, dim do + for r = 0, dim do + local x, y = c*side, r*side + canvas:encode_hline(x-l, x+l, y-s) + canvas:encode_hline(x-l, x+l, y+s) + canvas:encode_vline(y-l, y+l, x-s) + canvas:encode_vline(y-l, y+l, x+s) + end + end + local b1 = -s - 0.5*pt + local b2 = dim*side + s + 0.5*pt + canvas:encode_set_bbox(b1, b1, b2, b2) + canvas:ga_to_hbox("mybox") +}\hfill\box\mybox\hfill{} +\end{tcolorbox} + +An automatic process updates the bounding box of the figure meanwhile the stream +is read instruction after instruction. The \code{disable\_bbox} operation +produces a more fast execution and the figure maintains the bounding box +computed until that point. The \code{set\_bbox} operation imposes a bounding box +in comparison to the current one of the figure. + +The initial bounding box is simply empty. As a consequence, different +strategies can be used to optimize runtime execution, such as in the previous +code example, where bounding box is always disabled and it is set up at the last +\code{canvas} method call. More often than not, we know the bounding box of the +barcode symbol including quiet zones. + +Every encoding method of \code{gaCanvas} class gives two output result: a +boolean value called \code{ok} plus an error \code{err}. If \code{ok} is +\code{true} then \code{err} is \code{nil} and, viceversa, when \code{ok} is +\code{false} then \code{err} is a string describing the error. + +The error management is a responsability of the caller. For instance, if we +decide to stop the execution this format is perfectly suitable for the Lua +function \code{assert()}, otherwise we can explicity check the output pair: +\begin{Verbatim} +local pt = 65536 +assert(canvas:encode_linewidth(6*pt)) --> true, nil +local ok, err = canvas:encode_hline(nil, 32*pt, 0) +-- ok = false +-- err = "[ArgErr] 'x1' number expected" +\end{Verbatim} + + +\subsubsection{\code{ga} reference} +\label{secGAtabref} + +\noindent +\begin{tabular}{CLlL} +\toprule +\multicolumn{4}{l}{\textbf{Properties of the graphic state}}\\ +OpCode & Mnemonic key & Graphic property & Operands\\ +\midrule + 1 & linewidth & Line width & w \\ + 2 & linecap & Line cap style & e \\ + &&& 0: Butt cap\\ + &&& 1: Round cap\\ + &&& 2: Projecting square cap\\ + 3 & linejoin & Line join style & e \\ + &&& 0: Miter join\\ + &&& 1: Round join\\ + &&& 2: Bevel join\\ + 5 & dash\_pattern & Dash pattern line style & p n [bi ]+\\ + &&& p: phase lenght\\ + &&& n: number of array element\\ + &&& bi: dash array lenght\\ + 6 & reset\_pattern & Set the solid line style & -\\ +\midrule +29 & enable\_bbox & Compute bounding box & -\\ +30 & disable\_bbox & Do not compute bounding box & -\\ +31 & set\_bbox & Overlap current bounding box & x1 y1 x2 y2 \\ +\bottomrule +\end{tabular} + +\bigskip +\noindent +\begin{tabular}{CLlL} +\toprule +\multicolumn{4}{l}{\textbf{Lines}}\\ +OpCode & Mnemonic key & Graphic object & Operands\\ +\midrule +32 & line & Line & x1 y1 x2 y2 \\ +33 & hline & Horizontal line & x1 x2 y \\ +34 & vline & Vertical line & y1 y2 x \\ +\bottomrule +\end{tabular} + +\bigskip +\noindent +\begin{tabular}{CLlL} +\toprule +\multicolumn{4}{l}{\textbf{Group of bars}}\\ +OpCode & Mnemonic key & Graphic object & Operands\\ +\midrule +36 & vbar & Vertical bars & y1 y2 b [xi wi ]+\\ + & & & y1: bottom y-coord\\ + & & & y2: top y-coord\\ + & & & b: number of bars\\ + & & & xi: axis x-coord of bars number i\\ + & & & wi: width of bars number i\\ +37 & hbar & Horizontal bars & x1 x2 b [yi wi ]+\\ + & & & unimplemented\\ +\midrule +38 & polyline & Opened polyline & n [xi yi ]+\\ + & & & n: number of points\\ + & & & xi: x-coord of point i\\ + & & & yi: y-coord of point i\\ +39 & c\_polyline & Closed polyline & n [xi yi ]\\ + & & & unimplemented\\ +\bottomrule +\end{tabular} + +\bigskip +\noindent +\begin{tabular}{CLlL} +\toprule +\multicolumn{4}{l}{\textbf{Rectangles}}\\ +OpCode & Mnemonic key & Graphic object & Operands\\ +\midrule +48 & rect & Rectangle & x1 y1 x2 y2 \\ +49 & f\_rect & Filled rectangle & x1 y1 x2 y2 \\ + &&& unimplemented\\ +50 & rect\_size & Rectangle & x1 y1 w h \\ + &&& unimplemented\\ +51 & f\_rect\_size & Filled rectangle & x1 y1 w h \\ + &&& unimplemented\\ +\bottomrule +\end{tabular} + +\bigskip +\noindent +\begin{tabular}{CLl} +\toprule +\multicolumn{3}{l}{\textbf{Text}}\\ +OpCode & Mnemonic key & Graphic object/Operands\\ +\midrule +130 & text & A text with several glyphs\\ + & & \ttfamily ax ay xpos ypos [c ]+\\ +\midrule +131 & text\_xspaced & A text with glyphs equally spaced on its vertical axis\\ + & & \ttfamily x1 xgap ay ypos [c ]+\\ +\midrule +132 & text\_xwidth & Glyphs equally spaced on vertical axis between two x coordinates\\ + & & \ttfamily ay x1 x2 y c \\ +\midrule +140 & \_text\_group & Texts on the same baseline\\ +& & \ttfamily ay y n [xi ai ci ]+\\ +& & unimplemented\\ +\bottomrule +\end{tabular} + + +\subsection{\code{Vbar} class} + +This section show you how to draw a group of vertical lines, the main component +of every 1D barcode symbol. In the \brcd{} jargon a group of vertical lines is +called \code{Vbar} and is defined by a flat array of pair numbers sequence: the +first one is the x-coordinate of the bar while the second is its width. + +For instance, consider a \code{Vbar} of three bars for which width is a +multiple of the fixed length called \code{mod}, defined by the array and figure +showed below: +\begin{Verbatim} +-- { x1, w1, x2, w2, x3, w3} + {1.5*mod, 3*mod, 5.5*mod, 1*mod, 7.5*mod, 1*mod} +\end{Verbatim} +\directlua{ +local libgeo = barracuda:libgeo() +local Vbar = libgeo.Vbar +local drv = barracuda:get_driver() +local mm = drv.mm +local b = Vbar:from_int(32111, 2*mm) +local canvas = barracuda:new_canvas() +canvas:encode_vbar(b, 0, 0, 25*mm) +drv:ga_to_hbox(canvas, "mybox") +} +\begin{center} +\begin{tikzpicture} +\foreach \i in {0,2,...,16} +\draw[help lines] (\i mm, -2mm) -- (\i mm, 28mm); +\node at (8mm, 12.5mm) {\box\mybox}; +\draw[-{Latex[open]}] (0, 0) -- (20mm, 0); +\draw[-{Latex[open]}] (0, 0) -- (0, 30mm); +\draw[white, dashed] (3mm, 0) -- (3mm, 25mm); +\draw[white, dashed] (11mm, 0) -- (11mm, 25mm); +\draw[white, dashed] (15mm, 0) -- (15mm, 25mm); +\end{tikzpicture} +\end{center} + +For clearness, to the drawing were added a gray vertical grid stepping one +module and white dashed lines at every vbar axis. + +Spaces between bars can be seen as white bars. In fact, an integer number can +represents the sequence of black and white bars with the rule that the single +digit is the width module multiplier. So, the previous \code{Vbar} can be +defined by 32111 with module equals to 2 mm. + +The class \code{Vbar} of module \code{libgeo} has several constructors one of +which is \code{from\_int()}. Its arguments are the multiplier integer +\code{ngen}, the module length \code{mod} and the optional boolean flag +\code{is\_bar}, true if the first bar is black (default to true): +\begin{Verbatim} +b = Vbar:from_int(32111, 2*mm) +\end{Verbatim} + +A \code{Vbar} object has a local axis \( x \) and is unbounded. Constructors +place the axis origin at the left of the first bar. Bars are infinite vertical +straight lines. In order to draw a \code{Vbar} addition information must be +passed to \code{encode\_vbar()} method of the \code{gaCanvas} class: the global +position of the local origin \( x_0 \), and the bottom and top limit \( y_1 \) +\( y_2 \): +\begin{Verbatim} +canvas:encode_vbar(ovbar, x0, y1, y2) +\end{Verbatim} + +The following listing is the complete source code to draw the \code{Vbar} taken +as example in this section: +\begin{Verbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local Vbar = barracuda:libgeo().Vbar + local drv = barracuda:get_driver() + local mm = drv.mm + local b = Vbar:from_int(32111, 2*mm) + local canvas = barracuda:new_canvas() + canvas:encode_vbar(b, 0, 0, 25*mm) + drv:ga_to_hbox(canvas, "mybox") +}\leavevmode\box\mybox +\bye +\end{Verbatim} + + +\subsubsection{\code{Vbar} class arithmetic} + +Can two \code{Vbar} objects be added? Yes, they can! And also with numbers. +Thanks to metamethod and metatable feature of Lua, \code{libgeo} module can +provide arithmetic for \code{Vbar}s. More in detail, to add two \code{Vbar}s +deploy them side by side while to add a number put a distance between the +previous or the next object, depending on the order of addends. + +Anyway, every sum creates or modifies a \code{VbarQueue} object that can be +encoded in a \code{ga} stream with the method \code{encode\_vbar\_queue()}. The +method arguments' are the same needed to encode a \code{Vbar}: an axis position +\( x_0 \) and the two y-coordinates bound \( y_1 \) and \( y_2 \). + +A \code{VbarQueue} code example is the following: +\begin{tcolorbox} +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local Vbar = barracuda:libgeo().Vbar + local canvas = barracuda:new_canvas() + local mm = canvas.mm + local mod = 2 * mm + local queue = Vbar:from_int(32111, mod) + for _, ngen in ipairs {131, 21312, 11412} do + queue = queue + mod + Vbar:from_int(ngen, mod) + end + canvas:encode_vbar_queue(queue, 0, 0, 25*mm) + canvas:ga_to_hbox "mybox" +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\tcblower +\directlua{ + local Vbar = barracuda:libgeo().Vbar + local canvas = barracuda:new_canvas() + local mm = canvas.mm + local mod = 2 * mm + local queue = Vbar:from_int(32111, mod) + for _, ngen in ipairs {131, 21312, 11412} do + queue = queue + mod + Vbar:from_int(ngen, mod) + end + canvas:encode_vbar_queue(queue, 0, 0, 25*mm) + canvas:ga_to_hbox "mybox" +} +\hfill +\begin{tikzpicture} +\fill[orange!50!white] (16mm, -3mm) rectangle (18mm, 28mm); % +\fill[orange!50!white] (28mm, -3mm) rectangle (30mm, 28mm); % +\fill[orange!50!white] (48mm, -3mm) rectangle (50mm, 28mm); % +\foreach \i in {0,2,...,68} +\draw[help lines] (\i mm, -3mm) -- (\i mm, 28mm); +\node at (34mm, 12.5mm) {\box\mybox}; +\end{tikzpicture} +\hfill\hbox{} + +\footnote{Respect to the showed code some graphical helps has been added: a +vertical grid marks the module wide steps and light colored bars mark the +space added between two \code{Vbar}s.} +\end{tcolorbox} + +\subsection{\code{ga} programming} + +To provide a better learning experience several \code{ga} stream examples is +discussed, each of which must be compiled with Lua\TeX{}. + +\subsubsection{Example 1: a rectangle} + +Suppose we want to draw a simple rectangle. In the \code{ga} reference of +section~\ref{secGAtabref} there is a dedicated instruction \code{}. +Let's give it a try: + +\begin{tcolorbox}[ + title={Example 1: dealing with raw \code{ga} stream}, + sidebyside, +] +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local pt = 65536 + local ga = {48, 0, 0, 72*pt, 36*pt} + local drv = barracuda:get_driver() + drv:ga_to_hbox(ga, "mybox") +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\tcblower +\directlua{ + local pt = 65536 + local side = 36*pt + local ga = {48, 0, 0, 2*side, side} + local drv = barracuda:get_driver() + drv:ga_to_hbox(ga, "mybox") +}\box\mybox +\end{tcolorbox} + +Dealing with low level \code{ga} stream is not necessary. We can use more safely +a \code{gaCanvas} object running its \code{encode\_rect()} method: +\begin{Verbatim} +... +local canvas = barracuda:new_canvas() +assert(canvas:encode_rect(0, 0, 2*side, side)) +assert(canvas:ga_to_hbox("mybox")) +... +\end{Verbatim} + + +\subsubsection{Example 2: a chessboard} + +A more complex drawing is a chessboard. Let's begin to draw a single cell with a +square 1cm wide: +\begin{Verbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local canvas = barracuda:new_canvas() + local mm = canvas.mm + local s, t = 7.5*mm, 1.5*mm + canvas:encode_linewidth(t) + assert(canvas:encode_rect(t/2, t/2, s-t/2, s-t/2)) + assert(canvas:ga_to_hbox("mybox")) +}\leavevmode\box\mybox +\bye +\end{Verbatim} + +Then repeat the game for the entire grid: +\begin{tcolorbox} +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local canvas = barracuda:new_canvas() + local mm = canvas.mm + local s, t = 6*mm, 1*mm + assert(canvas:encode_linewidth(t)) + for row = 1, 5 do + for col = 1, 5 do + local l = (row + col)/2 + if l == math.floor(l) then + local x = (col - 1)*s + local y = (row - 1)*s + local x1, y1 = x + t/2, y + t/2 + local x2, y2 = x + s - t/2, y + s - t/2 + assert(canvas:encode_rect(x1, y1, x2, y2)) + end + end + end + drv:ga_to_hbox(canvas, "mybox") +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\vspace*{-10pt} +\tcblower +\directlua{ + local barracuda = require "barracuda" + local canvas = barracuda:new_canvas() + local mm = canvas.mm + local s, t = 6*mm, 1*mm + assert(canvas:encode_linewidth(t)) + for row = 1, 5 do + for col = 1, 5 do + local l = (row + col)/2 + if l == math.floor(l) then + local x = (col - 1)*s + local y = (row - 1)*s + local x1, y1 = x + t/2, y + t/2 + local x2, y2 = x + s - t/2, y + s - t/2 + assert(canvas:encode_rect(x1, y1, x2, y2)) + end + end + end + canvas:ga_to_hbox("mybox") +}\hfill\box\mybox\hfill\hbox{} +\end{tcolorbox} + +\subsubsection{Example 3: a staircase} + +A drawing of a zig zag staircase can be represented by a \code{ga} stream with +a \code{} operation. The \code{gaCanvas} method we have to call is +\code{encode\_polyline()} that accept a Lua table as a flat structure with the +coordinates of every point of the polyline: +\begin{BVerbatim} +{x1, y1, x2, y2, ..., xn, yn} +\end{BVerbatim} + +It is what we do with this code: +\begin{tcolorbox} +\begin{BVerbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local pt = 65536 + local side = 16*pt + local dim = 5 + local x, y = 0, 0 + local point = {x, y} + local i = 3 + for _ = 1, dim do + y = y + side + point[i] = x; i = i + 1 + point[i] = y; i = i + 1 + x = x + side + point[i] = x; i = i + 1 + point[i] = y; i = i + 1 + end + local canvas = barracuda:new_canvas() + canvas:encode_linewidth(2.25*pt) + canvas:encode_polyline(point) + canvas:ga_to_hbox("mybox") +}\leavevmode\box\mybox +\bye +\end{BVerbatim} +\vspace*{-10pt} +\tcblower +\directlua{ + local pt = 65536 + local side = 16*pt + local dim = 5 + local x, y = 0, 0 + local point = {x, y} + local i = 3 + for _ = 1, dim do + y = y + side + point[i] = x; i = i + 1 + point[i] = y; i = i + 1 + x = x + side + point[i] = x; i = i + 1 + point[i] = y; i = i + 1 + end + local canvas = barracuda:new_canvas() + canvas:encode_linewidth(2.25*pt) + canvas:encode_polyline(point) + canvas:ga_to_hbox("mybox") +}\hfill\box\mybox\hfill\hbox{} +\end{tcolorbox} + +A feature of \code{encode\_()} methods is their \emph{polymorphic} +behavior for their first argument. They accept different types as an object +of a geometric class or the raw geometric data. + +Method \code{encode\_polyline} is not an exception: it accepts a \code{Polyline} +object provided by the \code{libgeo} module, or instead a flat array of +coordinates. For instance the previous code may be re-implement as: +\begin{Verbatim} +% !TeX program = LuaTeX +\newbox\mybox +\directlua{ + local barracuda = require "barracuda" + local pt = 65536 + local side = 18*pt + local dim = 5 + local Polyline = barracuda:libgeo().Polyline + local pl = Polyline:new(0, 0) + for _ = 1, dim do + pl:add_relpoint(0, side) + pl:add_relpoint(side, 0) + end + local canvas = barracuda:new_canvas() + canvas:encode_linewidth(2.5*pt) + canvas:encode_polyline(pl) + canvas:ga_to_hbox("mybox") +}\leavevmode\box\mybox +\bye +\end{Verbatim} + +Pretty sure that this new version is more clear and intuitive. + + +%\subsubsection{Example 4: } + +% A polyline that represents a path of ... Hilbert curve +% Text pyramid + + +\section{Practical examples and use cases} +\label{secExample} + +Previous sections as shown how \brcd{} is capable to draw simple graphics. This +section is dedicated to barcode applications. + + + +\end{document} diff --git a/Master/texmf-dist/doc/luatex/barracuda/doc/manual/image/8006194056290.pdf b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/image/8006194056290.pdf new file mode 100644 index 00000000000..8effe87846a Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/doc/manual/image/8006194056290.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.pdf index b05ed417eb8..9da41b5c507 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.tex index 8932f9eaaf3..ba055eb9d5d 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/01-barracuda-latex-test.tex @@ -1,7 +1,7 @@ % !TeX program = LuaLaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli -% test file: make a Code39 barcodes in a LaTeX document +% test file: make Code39 barcodes in a LaTeX document \documentclass{article} \usepackage{barracuda} @@ -10,6 +10,17 @@ A\barracuda{code39}{123QWE}A B\barracuda[text_vpos='top']{code39}{123QWE}B -\end{document} +%\barracudasetup[option]{ treename } + +\directlua{ +local barracuda = require "barracuda" +local barcode = barracuda:barcode() +local code39 = assert(barcode:enc_by_name("code39")) +assert(code39:set_param{debug_bbox = "qz"}) +}\bigskip + +A\barracuda{code39}{123QWE}A +B\barracuda[text_vpos='top']{code39}{123QWE}B +\end{document} diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/02-ord_iter-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/02-ord_iter-test.tex index 1b5d6509d48..89236a8bfc6 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/02-ord_iter-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-barracuda-package/02-ord_iter-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \directlua{ local barracuda = require "barracuda" diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.lua b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.lua deleted file mode 100644 index 33dd927dc72..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.lua +++ /dev/null @@ -1,32 +0,0 @@ --- Copyright (C) 2020 Roberto Giacomelli - -local barracuda = require "barracuda" -local barcode = barracuda:barcode() -local c128, err = barcode:new_encoder("code128") -assert(not err, err) - -print(c128._NAME) -print(c128._VERSION) - -local info = c128:info() -print("encoder name = ", info.name) -print("description = ", info.description) -for k, tp in ipairs(info.param) do - print(k, tp.name, tp.value) -end - -local symb = c128:from_string("123") -print("Symbol char list:") -for _, c in ipairs(symb._code_data) do - print(c) -end - -local canvas = barracuda:new_canvas() - -symb:append_ga(canvas) - --- driver library -local drv = barracuda:get_driver() -drv:save("svg", canvas, "c128-123") - - diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.tex new file mode 100644 index 00000000000..335b880d5be --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/001-code128-test.tex @@ -0,0 +1,39 @@ +% !TeX program = LuaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli + +\directlua{ +local barracuda = require "barracuda" +local barcode = barracuda:barcode() +local c128 = assert(barcode:new_encoder("code128")) +print() +print(c128._NAME) +print(c128._VERSION) + +local info = c128:info() +print("encoder name = ", info.name) +print("description = ", info.description) +for k, tp in ipairs(info.param) do + print(k, tp.name, tp.value) +end + +local symb = c128:new("123") +print("Symbol char list:") +for _, c in ipairs(symb:get_code()) do + print(c) +end +print("Symbol hri char list:") +for _, c in ipairs(symb:get_hri()) do + print(c) +end + + +local canvas = barracuda:new_canvas() + +symb:draw(canvas) + +% driver library +local drv = barracuda:get_driver() +drv:save("svg", canvas, "c128-123") +} +\bye + diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.pdf index 4cf993a396d..731c7ca2793 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.tex index b5c081659e3..9bb39159083 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/002-code128-test.tex @@ -1,12 +1,12 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers Code 128 encoder test. -Test 1: one simple barcode with default parameter: +Test 1: one simple barcode with default parameters: \directlua{ barracuda = require "barracuda" @@ -14,7 +14,7 @@ barracuda = require "barracuda" \directlua{ local barcode = barracuda:barcode() - +barcode:set_param{debug_bbox="symb"} local c128, err = barcode:new_encoder("code128") assert(not err, err) @@ -22,7 +22,7 @@ local symbo, err = c128:from_string("5465468132546812") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -51,8 +51,8 @@ local s2_ax = s2:get_param("ax") assert(s2.ax == 0, "0 ax is "..tostring(s2.ax)) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) -s2:append_ga(canvas) +s1:draw(canvas) +s2:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -69,13 +69,13 @@ assert(c128, err) local s, err = c128:from_string("123456"); assert(s, err) local canvas = barracuda:new_canvas() -s:append_ga(canvas) +s:draw(canvas) local ok, err = s:set_param("ydim", tex.sp "30mm") -s:append_ga(canvas, tex.sp "20mm") +s:draw(canvas, tex.sp "20mm") local ok, err = s:set_param("ydim", tex.sp "60mm") -s:append_ga(canvas, tex.sp "40mm") +s:draw(canvas, tex.sp "40mm") local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -93,14 +93,14 @@ local c128, err = barcode:enc_by_name "code128"; assert(c128, err) local s, err = c128:from_string("ABCDEFGHI"); assert(s, err) local canvas = barracuda:new_canvas() -local _, err = s:append_ga(canvas); assert(not err, err) +local _, err = s:draw(canvas); assert(not err, err) % set ay to 0.5 for the encoder local ok, err = c128:set_param("ay", 0.5); assert(ok, err) -local _, err = s:append_ga(canvas, tex.sp "30mm"); assert(not err, err) +local _, err = s:draw(canvas, tex.sp "30mm"); assert(not err, err) % set locally to the symbol ay to 1.0 local ok, err = s:set_param("ay", 1) -local _, err = s:append_ga(canvas, tex.sp "60mm"); assert(not err, err) +local _, err = s:draw(canvas, tex.sp "60mm"); assert(not err, err) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -114,14 +114,96 @@ local c128, err = barcode:enc_by_name("code128"); assert(c128, err) local s, e = c128:from_uint(1234567890); assert(s, e) local canvas = barracuda:new_canvas() -local _, errc = s:append_ga(canvas); assert(not errc, errc) +local _, errc = s:draw(canvas); assert(not errc, errc) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") drv:save("native", canvas, "02-05-pdfliteral") }\box\mybox -That's all folks! +Test 6: encode ABC123: -\bye +\directlua{ +local barcode = barracuda:barcode() +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("ABC123"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +Test 7: encode ABC123999: + +\directlua{ +local barcode = barracuda:barcode() +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("ABC123999"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +Test 8: encode ABC123456789: + +\directlua{ +local barcode = barracuda:barcode() +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("ABC123456789"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +Test 9: encode A1B2C3D999: -function Driver:save(id_drv, ga, filename, ext) --> ok, err \ No newline at end of file +\directlua{ +local barcode = barracuda:barcode() +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("A1B2C3D999"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +Test 10: encode 123abcedfg: + +\directlua{ +local barcode = barracuda:barcode() +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("123abcedfg"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +Test 11: encode 999Aaaa: + +\directlua{ +local barcode = barracuda:barcode() +barcode:set_param{debug_bbox="none"} +local c128, err = barcode:enc_by_name "code128"; assert(c128, err) +local s, err = c128:from_string("999Aaaa"); assert(s, err) + +local canvas = barracuda:new_canvas() +local _, err = s:draw(canvas); assert(not err, err) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\box\mybox + +That's all folks! +\bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/02-05-pdfliteral.txt b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/02-05-pdfliteral.txt index fe16d33c50b..894b9f1d4ab 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/02-05-pdfliteral.txt +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code128/02-05-pdfliteral.txt @@ -1,4 +1,8 @@ q +1.000000 w +0 J +0 j +[] 0 d -53.574521 -14.173154 1.190545 28.346308 re -51.788704 -14.173154 0.595272 28.346308 re -50.002887 -14.173154 1.785817 28.346308 re @@ -40,4 +44,8 @@ S -1.190545 -14.173154 1.190545 28.346308 re f S +0.100000 w +[6.000000 3.000000] 3.000000 d +-53.524521 -14.123154 53.474521 28.246308 re S +[] 0 d Q \ No newline at end of file diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.lua b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.lua deleted file mode 100644 index a9d8894ba06..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.lua +++ /dev/null @@ -1,41 +0,0 @@ --- Copyright (C) 2020 Roberto Giacomelli --- test Code 39 encoder - -local barracuda = require "barracuda" - -for k, v in pairs(barracuda) do - print(k,v) -end - -local barcode = barracuda:barcode() - -local c39, err = barcode:new_encoder("code39") -assert(not err, err) - -print(c39._NAME) -print(c39._VERSION) - -local info = c39:info() - -print("encoder name = ", info.name) -print("description = ", info.description) - -for k, tp in ipairs(info.param) do - print(k, tp.name, tp.value) -end - -local symb = c39:from_string("123") - -print("print internal representation of chars") -for _, c in ipairs(symb._code_data) do - print(c) -end -print() - -local canvas = barracuda:new_canvas() -symb:append_ga(canvas) - --- native driver -local drv = barracuda:get_driver() - -for _, code in ipairs(canvas._data) do print(code) end diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.tex new file mode 100644 index 00000000000..c08e1f242a3 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/001-code39-test.tex @@ -0,0 +1,39 @@ +% !TeX program = LuaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli +% test Code 39 encoder + +\directlua{ +local barracuda = require "barracuda" + +for k, v in pairs(barracuda) do + print(k, v) +end + +local barcode = barracuda:barcode() + +local c39, err = barcode:new_encoder("code39") +assert(not err, err) + +print(c39._NAME) +print(c39._VERSION) + +local info = c39:info() + +print("encoder name = ", info.name) +print("description = ", info.description) +for k, tp in ipairs(info.param) do + print(k, tp.name, tp.value) +end + +local symb = c39:from_string("123") + +print("print internal representation of chars") +print(table.concat(symb:get_code(), " ")) +print("end") +assert(symb:get_hri() == nil) + +local canvas = barracuda:new_canvas() +symb:draw(canvas) +% canvas:prettyprint_ga() +} +\bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.pdf index 63ced9a3423..c114e9339f7 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.tex index eb1693b5ba8..f242fafa4d7 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/002-code39-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers @@ -19,10 +19,10 @@ local symbol, err = c39:from_string("ABC12QJ31") assert(not err, err) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\leavevmode\box\mybox Test 2: get the reference of the previous encoder and typeset two Code 39 symbols on the same canvas, one above to the other: @@ -36,13 +36,13 @@ local s1, err = c39:from_string("ZKPQJ31"); assert(s1, err) local s2, err = c39:from_string("RTFG746", {text_vpos="top"}); assert(s2, err) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) +s1:draw(canvas) local h2 = s2:get_param("height") -s2:append_ga(canvas, 0.0, h2 + tex.sp "5pt") +s2:draw(canvas, 0.0, h2 + tex.sp "5pt") local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\leavevmode\box\mybox Test 3: with the same encoder print a symbol, change globally the height, and reprint the same symbol again on the same canvas: @@ -55,17 +55,17 @@ assert(c39, err) local s1, err = c39:from_string("ZKPQJ31"); assert(s1, err) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) +s1:draw(canvas) local h = s1:get_param("height") c39:set_param("height", 2*h) c39:set_param {text_vpos = "top"} -s1:append_ga(canvas, 0.0, h + tex.sp "5pt") +s1:draw(canvas, 0.0, h + tex.sp "5pt") local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\leavevmode\box\mybox Test 4: do the same in test 3 but change locally parameters as height and text properties: @@ -78,7 +78,7 @@ assert(c39, err) local s1, err = c39:from_string("0123456789"); assert(s1, err) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) +s1:draw(canvas) local h, err = s1:get_param("height"); assert(h, err) local ok, err = s1:set_param{ height = h/2, @@ -88,27 +88,30 @@ local ok, err = s1:set_param{ text_star = true, ay = 1, }; assert(ok, err) -s1:append_ga(canvas, 0.0, - tex.sp "5pt") +s1:draw(canvas, 0.0, - tex.sp "5pt") local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\leavevmode\box\mybox -Test 5: create a new encoder with a large module value: +Test 5: create a new encoder with a large module value. +It's also activeted the debug\_bbox\_on option. + +\bigskip \directlua{ local barcode = barracuda:barcode() -local c39, err = barcode:new_encoder("code39:e2", {module = tex.sp "0.5mm"}) +local c39, err = barcode:new_encoder("code39:e2", {module = tex.sp "0.5mm", debug_bbox_on = true}) assert(c39, err) local s1, err = c39:from_string("02040608"); assert(s1, err) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) +s1:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\leavevmode\box\mybox \bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.pdf index 544a4b34ff0..3dcd314a4a3 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.tex index 884cdd0df49..d9df0e8110b 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/003-code39-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers @@ -18,33 +18,35 @@ local ok, err = c39:set_param("text_vpos", "top") assert(ok, err) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) local ok, err = symbol:set_param("text_hpos", "center") assert(ok, err) -symbol:append_ga(canvas, tex.sp "4.5cm") +symbol:draw(canvas, tex.sp "4.5cm") local ok, err = symbol:set_param("text_hpos", "right") assert(ok, err) -symbol:append_ga(canvas, tex.sp "9.0cm") +symbol:draw(canvas, tex.sp "9.0cm") local ok, err = c39:set_param("text_vpos", "bottom") assert(ok, err) local ok, err = symbol:set_param("text_hpos", "left") -symbol:append_ga(canvas, 0, tex.sp "-2.0cm") +symbol:draw(canvas, 0, tex.sp "-2.0cm") local ok, err = symbol:set_param("text_hpos", "center") assert(ok, err) -symbol:append_ga(canvas, tex.sp "4.5cm", tex.sp "-2.0cm") +symbol:draw(canvas, tex.sp "4.5cm", tex.sp "-2.0cm") local ok, err = symbol:set_param("text_hpos", "right") assert(ok, err) -symbol:append_ga(canvas, tex.sp "9.0cm", tex.sp "-2.0cm") +symbol:draw(canvas, tex.sp "9.0cm", tex.sp "-2.0cm") local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +} +\bigskip +\leavevmode\box\mybox \bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.pdf index 0e5bfa42d09..660dd4a1fa7 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.tex index 9066d4dee80..1af5fdaaa04 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/004-code39-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers @@ -17,11 +17,11 @@ symbol, err = c39:from_uint(0, {text_hpos="center"}) assert(not err, err) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox +}\bigskip\leavevmode\box\mybox \directlua{ local c39, err = barracuda:barcode() @@ -33,10 +33,9 @@ symbol, e = c39:from_uint(0123456789, {text_hpos="spaced",text_star=true}) assert(not e, e) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -}\box\mybox - +}\bigskip\leavevmode\box\mybox \bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/006-code39-test.lua b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/006-code39-test.lua index 1b8ee9f4a1b..0ad6169fca7 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/006-code39-test.lua +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/006-code39-test.lua @@ -14,29 +14,29 @@ local ok, err = c39:set_param("text_vpos", "top") assert(ok, err) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) local ok, err = symbol:set_param("text_hpos", "center") assert(ok, err) -symbol:append_ga(canvas, 4.5*cm) +symbol:draw(canvas, 4.5*cm) local ok, err = symbol:set_param("text_hpos", "right") assert(ok, err) -symbol:append_ga(canvas, 9.0*cm) +symbol:draw(canvas, 9.0*cm) local ok, err = c39:set_param("text_vpos", "bottom") assert(ok, err) local ok, err = symbol:set_param("text_hpos", "left") -symbol:append_ga(canvas, 0, -2.0*cm) +symbol:draw(canvas, 0, -2.0*cm) local ok, err = symbol:set_param("text_hpos", "center") assert(ok, err) -symbol:append_ga(canvas, 4.5*cm, -2.0*cm) +symbol:draw(canvas, 4.5*cm, -2.0*cm) local ok, err = symbol:set_param("text_hpos", "right") assert(ok, err) -symbol:append_ga(canvas, 9.0*cm, -2.0*cm) +symbol:draw(canvas, 9.0*cm, -2.0*cm) local drv = barracuda:get_driver() drv:save("svg", canvas, "006-six") diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.pdf new file mode 100644 index 00000000000..e49b38b256f Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.tex new file mode 100644 index 00000000000..5090e540583 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-code39/007-code39-test.tex @@ -0,0 +1,39 @@ +% !TeX program = LuaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli + +\newbox\mybox +\nopagenumbers + +\directlua{ +barracuda = require "barracuda" +local c39 = assert( + barracuda:barcode() + :new_encoder("code39", {debug_bbox_on = true}) +) + +local bars = c39:new { + 123456, + "123456", + "ABCDEF", + 87429, + 982398, + "HDUHBE" +} + +local canvas = barracuda:new_canvas() +local tx, ty = 0, 0 +local dh = tex.sp "40pt" +for _, b in ipairs(bars) do + b:draw(canvas, tx, ty) + ty = ty + dh +end + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +} + +Test 1: check Barcode recursive costructor new(): +\bigskip +\leavevmode\box\mybox +\bye + diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.pdf index 12eac36ba17..bc9d8f894b4 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.tex index 7c7b373a6c5..42850bcd130 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/001-13-ean-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers @@ -11,6 +11,7 @@ Test 1: one simple barcode EAN13 with default parameter: \directlua{ barracuda = require "barracuda" local barcode = barracuda:barcode() +barcode:set_param{debug_bbox="qz"} local ean13, err = barcode:new_encoder("ean-13") assert(not err, err) @@ -19,7 +20,7 @@ local symbo, err = ean13:from_string("8006194056290") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -39,7 +40,7 @@ local symbo, err = ean8:from_string("96385074") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -56,7 +57,7 @@ assert(not err, err) local symbo, err = ean5:from_string("54495") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -72,7 +73,7 @@ assert(not err, err) local symbo, err = ean2:from_string("53") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -89,7 +90,7 @@ local c = assert(ean:checksum(n)) local symbo, err = ean:from_string(n..c.."12345") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -107,7 +108,7 @@ local s = n .. c local symbo, err = ean:from_string(s.."12") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -125,7 +126,7 @@ local s = n .. c local symbo, err = ean:from_string(s.."12345") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -143,7 +144,7 @@ local s = n .. c local symbo, err = ean:from_string(s.."88") assert(not err, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } @@ -167,10 +168,10 @@ local s = n .. c local symbo, err = ean:from_string(s); assert(not err, err) local ok, err = symbo:set_param("height", tex.sp "5mm"); assert(ok, err) local canvas = barracuda:new_canvas() -symbo:append_ga(canvas) +symbo:draw(canvas) local s2, err = ean:from_uint(8001120972163); assert(not err, err) -s2:append_ga(canvas, tex.sp "45mm", 0) +s2:draw(canvas, tex.sp "45mm", 0) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") @@ -191,12 +192,12 @@ local ok, err = ean:set_param("height", tex.sp "5mm"); assert(ok, err) local n = 758458535897; local c = ean:checksum(n); local s = n .. c local s1, err = ean:from_string(s); assert(not err, err) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) +s1:draw(canvas) local s2, err = ean:from_uint(8001120972163); assert(not err, err) -s2:append_ga(canvas, tex.sp "40mm", 0) +s2:draw(canvas, tex.sp "40mm", 0) local s3, err = ean:from_uint(8000570000310); assert(not err, err) local ok, e = s3:set_param{height = tex.sp "10mm"}; assert(ok, e) -s3:append_ga(canvas, tex.sp "90mm", 0) +s3:draw(canvas, tex.sp "90mm", 0) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") } diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/002-ean-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/002-ean-test.pdf index 796ad29ab03..54762d4dfc1 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/002-ean-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/002-ean-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/003-ean-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/003-ean-test.pdf index c52c77a8471..cfeea7167f6 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/003-ean-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/003-ean-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.lua b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.lua deleted file mode 100644 index 017e0725b8b..00000000000 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.lua +++ /dev/null @@ -1,9 +0,0 @@ - -local barracuda = require "barracuda" -barracuda:save("ean-13", "8006194056290", "8006194056290") - - - - - - diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.tex new file mode 100644 index 00000000000..4d9b5208e95 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/004-ean-test.tex @@ -0,0 +1,6 @@ +% !TeX program = LuaTeX +\directlua{ +local barracuda = require "barracuda" +barracuda:save("ean-13", "8006194056290", "8006194056290") +} +\bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/005-isbn-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/005-isbn-test.pdf index d71e87141de..ad4028750ca 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/005-isbn-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/005-isbn-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.pdf index 57f3739fb7e..a40f50669e3 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.tex index 576963bd810..61148b0b700 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/006-issn-test.tex @@ -30,28 +30,30 @@ barracuda:hbox("ean-issn+5", ars_issn.online.."00028", "mybox") \vskip10pt \leavevmode -\directlua{barracuda:hbox("ean-issn", "1828-2350", "mybox")} +\directlua{ +local barcode = barracuda:barcode() +barcode:set_param("debug_bbox_on", true) +barracuda:hbox("ean-issn", "1828-2350", "mybox") +} \box\mybox \vskip10pt \leavevmode -\directlua{barracuda:hbox("ean-issn", "1828-2350 [01]", "mybox")} +\directlua{ +barracuda:hbox("ean-issn+2", "1828-2350 [01] 22", "mybox") +barracuda:save("ean-issn+2", "1828-2350 [01] 22", "ars") +} \box\mybox \vskip10pt \leavevmode -\directlua{barracuda:hbox("ean-issn+5", "1828-2350 [01] 00028", "mybox")} +\directlua{barracuda:hbox("ean-issn", "1828-2350 [01]", "mybox")} \box\mybox \vskip10pt \leavevmode -\directlua{ -barracuda:hbox("ean-issn+2", "1828-2350 [01] 22", "mybox") -barracuda:save("ean-issn+2", "1828-2350 [01] 22", "ars") -} +\directlua{barracuda:hbox("ean-issn+5", "1828-2350 [01] 00028", "mybox")} \box\mybox - \bye - diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/8006194056290.svg b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/8006194056290.svg index f7965e94d4c..e5538003701 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/8006194056290.svg +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/8006194056290.svg @@ -11,6 +11,14 @@ + + + + + + + + @@ -35,10 +43,6 @@ - - - - @@ -63,10 +67,6 @@ - - - - 8 diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/ars.svg b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/ars.svg index 5bfc01d0f3c..8f48c1054ec 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/ars.svg +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ean/ars.svg @@ -11,6 +11,14 @@ + + + + + + + + @@ -35,10 +43,6 @@ - - - - @@ -63,10 +67,6 @@ - - - - 9 diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf index b3f3336f436..d741453c5bb 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex index c51fa3dfb09..a40ba4ec8bc 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/001-ga-pdfliteral-test.tex +++ b/Master/texmf-dist/doc/luatex/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 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/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.pdf new file mode 100644 index 00000000000..72d4eddc05f Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/002-polyline.tex new file mode 100644 index 00000000000..14a713dee92 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/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/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/polygon.svg b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/polygon.svg new file mode 100644 index 00000000000..fd00ed2912d --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-pdfliteral/polygon.svg @@ -0,0 +1,132 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-svg/002-ga-svg-test.lua b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-svg/002-ga-svg-test.lua index b5a2e3c4ae2..e116fe75f46 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-svg/002-ga-svg-test.lua +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-ga-svg/002-ga-svg-test.lua @@ -13,6 +13,6 @@ local symbol, err = c39:from_string("ABC000Z") assert(not err, err) local canvas = barracuda:new_canvas() -symbol:append_ga(canvas) +symbol:draw(canvas) driver:save("svg", canvas, "test-code39") \ No newline at end of file diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.pdf index f2dbd6f9ea6..5bf43e574b8 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.tex index 0062b74d3e4..3f5a4dff751 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/001-i2of5-test.tex @@ -1,10 +1,14 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers -\directlua{barracuda = require "barracuda"} +\directlua{ +barracuda = require "barracuda" +local barcode = barracuda:barcode() +barcode:set_param("debug_bbox", "symb") +} Interleaved 2 of 5 encoder test. @@ -12,14 +16,13 @@ Test 1: one simple barcode with default parameters: \directlua{ local barcode = barracuda:barcode() - local enc, err = barcode:new_encoder("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(54654681); assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 54654681: \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 2: one simple barcode with default parameter: @@ -28,11 +31,11 @@ Test 2: one simple barcode with default parameter: local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(1234567895); assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 1234567895: \vrule A\vrule\box\mybox \vrule A\vrule % check digit tests @@ -104,11 +107,11 @@ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(454473, {check_digit_policy="add"}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 454473: \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 4: a second simple barcode with check digit automatically added: @@ -118,11 +121,11 @@ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(74223, {check_digit_policy="add"}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 74223: \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 5: a symbol with native check digits: @@ -132,11 +135,11 @@ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(121891259, {check_digit_policy="verify"}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 121891259: \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 6: bearer bars please: @@ -144,13 +147,13 @@ Test 6: bearer bars please: \directlua{ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) -local symbo, err = enc:from_uint(747867239, {bearer_bars_enabled = true}) +local symbo, err = enc:from_string("747867239", {bearer_bars_enabled = true}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input string "747867239": \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 7: bearer bars all around the symbol: @@ -160,11 +163,11 @@ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_uint(986790868, {bearer_bars_enabled = true, bearer_bars_layout="frame"}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input code 986790868: \vrule A\vrule\box\mybox \vrule A\vrule \bigskip Test 8: bearer bars all around the symbol (with string costructor): @@ -174,11 +177,11 @@ local barcode = barracuda:barcode() local enc, err = barcode:enc_by_name("i2of5"); assert(not err, err) local symbo, err = enc:from_string("986790868", {bearer_bars_enabled = true, bearer_bars_layout="frame"}) assert(not err, err) -local canvas = barracuda:new_canvas(); symbo:append_ga(canvas) +local canvas = barracuda:new_canvas(); symbo:draw(canvas) local drv = barracuda:get_driver() drv:ga_to_hbox(canvas, "mybox") -} -\vrule A\vrule\box\mybox \vrule A\vrule +}% +input string "986790868": \vrule A\vrule\box\mybox \vrule A\vrule That's all folks! diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.pdf index 79a05eca420..449a7b63a8f 100644 Binary files a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.pdf and b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.tex index 52784b66bbc..7b6229b483d 100644 --- a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.tex +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/002-ITF14-test.tex @@ -1,5 +1,5 @@ % !TeX program = LuaTeX -% Copyright (C) 2020 Roberto Giacomelli +% Copyright (C) 2019-2022 Roberto Giacomelli \newbox\mybox \nopagenumbers @@ -15,9 +15,8 @@ local enc = assert(barcode:new_encoder("i2of5-ITF14")) local s1 = assert(enc:from_uint(1234567890123)) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) -local drv = barracuda:get_driver() -drv:ga_to_hbox(canvas, "mybox") +s1:draw(canvas) +canvas:ga_to_hbox("mybox") } \vskip 10pt 12345678901231 is \vrule A\vrule\box\mybox \vrule A\vrule @@ -28,9 +27,8 @@ local enc = assert(barcode:enc_by_name("i2of5-ITF14")) local s1 = assert(enc:from_string("1234567890123")) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) -local drv = barracuda:get_driver() -drv:ga_to_hbox(canvas, "mybox") +s1:draw(canvas) +canvas:ga_to_hbox("mybox") } \vskip 10pt 12345678901231 is \vrule A\vrule\box\mybox \vrule A\vrule @@ -39,15 +37,12 @@ drv:ga_to_hbox(canvas, "mybox") local barcode = barracuda:barcode() local enc = assert(barcode:enc_by_name("i2of5-ITF14")) local s1 = assert(enc:from_string("(12) 34 56 78 90 12 3")) - +s1:set_param("debug_bbox_on", true) local canvas = barracuda:new_canvas() -s1:append_ga(canvas) -local drv = barracuda:get_driver() -drv:ga_to_hbox(canvas, "mybox") +s1:draw(canvas) +canvas:ga_to_hbox("mybox") +canvas:save("svg", "02-itf14") } \vskip 10pt 12345678901231 is \vrule A\vrule\box\mybox \vrule A\vrule - \bye - - diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/02-itf14.svg b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/02-itf14.svg new file mode 100644 index 00000000000..2f8ee069968 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-i2of5/02-itf14.svg @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + (12) 34 56 78 90 12 31 + + + diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.pdf new file mode 100644 index 00000000000..46c326513aa Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.tex new file mode 100644 index 00000000000..ec43ad00915 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/001-libgeo-test.tex @@ -0,0 +1,48 @@ +% !TeX program = LuaTeX +% test for ga-canvas pdfliteral driver +% +% Copyright (C) 2019-2022 Roberto Giacomelli +% see LICENSE.txt file + +\newbox\mybox +\directlua{ + barracuda = require [[barracuda]] + pt = tex.sp [[1pt]] % 1pt = 65536sp +} + +Test 1: test Archive class and Vbar arithmetic: + +\medskip +\directlua{ + % retrive the Vbar class + local libgeo = barracuda:libgeo() + local Vbar = libgeo.Vbar + % create three Vbar objects + local b1 = Vbar:from_int(22556, 2*pt) + local b2 = Vbar:from_int(3134563, 2*pt) + local b3 = Vbar:from_int(1111111, 2*pt) + % retrive the Archive class + local Archive = libgeo.Archive + % create a new instance of an archive and insert vbars + local archive = Archive:new() + assert(archive:insert(b1, 1)) + assert(archive:insert(b2, 2)) + assert(archive:insert(b3, 3)) + % fill a queue (an array) two times + local queue = assert(archive:get(1)) + 20*pt + queue = queue + assert(archive:get(2)) + 20*pt + queue = queue + assert(archive:get(3)) + 20*pt + queue = queue + assert(archive:get(1)) + 20*pt + queue = queue + assert(archive:get(2)) + 20*pt + queue = queue + assert(archive:get(3)) + % retrive a canvas instance + local ga = barracuda:new_canvas() + % draw the canvas with the driver component + assert(ga:encode_vbar_queue(queue, 0, 0, 30*pt)) + local driver = barracuda:get_driver() + driver:ga_to_hbox(ga, [[mybox]]) +}A\box\mybox A + +\bye + + \ No newline at end of file diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.pdf new file mode 100644 index 00000000000..1465413c8ae Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.tex new file mode 100644 index 00000000000..c3692c282e8 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/003-ga-svg-test.tex @@ -0,0 +1,41 @@ +% !TeX program = LuaTeX + +\newbox\mybox +\nopagenumbers +\directlua{ +local barracuda = require "barracuda" +local barcode = barracuda:barcode() +local driver = barracuda:get_driver() +local mm = driver.mm + +local canvas = barracuda:new_canvas() +canvas:encode_linewidth(1*mm) + +canvas:encode_dash_pattern(0, 2*mm) +canvas:encode_hline(0, 30*mm, 5*mm) + +canvas:encode_dash_pattern(0, 2*mm, 4*mm) +canvas:encode_hline(0, 30*mm, 10*mm) + +canvas:encode_dash_pattern(1*mm, 2*mm, 2*mm, 4*mm) +canvas:encode_hline(0, 30*mm, 15*mm) + +canvas:encode_linewidth(0.05*mm) +canvas:encode_reset_pattern() +for i=0, 15 do + canvas:encode_vline(0, 20*mm, i*2*mm) +end + +canvas:encode_dash_pattern(0.5*mm, 1*mm) +canvas:encode_polyline{ + 1*mm, 1*mm, + 29*mm, 1*mm, + 29*mm, 19*mm, + 1*mm, 19*mm, + 1*mm, 1*mm +} + +driver:save("svg", canvas, "test") +assert(driver:ga_to_hbox(canvas, [[mybox]])) +}\leavevmode\box\mybox +\bye \ No newline at end of file diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/test.svg b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/test.svg new file mode 100644 index 00000000000..d9614096c4f --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-libgeo/test.svg @@ -0,0 +1,79 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.pdf new file mode 100644 index 00000000000..c4637e681a3 Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.tex new file mode 100644 index 00000000000..3be12aa5026 --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/001-upca-test.tex @@ -0,0 +1,41 @@ +% !TeX program = LuaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli + +\newbox\mybox +\nopagenumbers + +UPC encoder test. + +Test 1: one simple barcode UPC-A with default parameter: + +\directlua{ +barracuda = require "barracuda" +local barcode = barracuda:barcode() +barcode:set_param("debug_bbox", "qz") +local upca, err = barcode:new_encoder("upc-A") +assert(not err, err) + +local symbo, err = upca:from_string("042100005264") +assert(not err, err) + +local canvas = barracuda:new_canvas() +symbo:draw(canvas) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +} +\vrule A\box\mybox A\vrule + +\bigskip\directlua{ +local barcode = barracuda:barcode() +barcode:set_param("debug_bbox", "none") +local upca = assert(barcode:enc_by_name("upc-A")) + +local symbo = assert(upca:new("012345678905")) +local canvas = barracuda:new_canvas() +symbo:draw(canvas) + +local drv = barracuda:get_driver() +drv:ga_to_hbox(canvas, "mybox") +}\leavevmode\box\mybox +\bye diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.pdf b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.pdf new file mode 100644 index 00000000000..ed5363d1de1 Binary files /dev/null and b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.pdf differ diff --git a/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.tex b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.tex new file mode 100644 index 00000000000..5196ecbc7ae --- /dev/null +++ b/Master/texmf-dist/doc/luatex/barracuda/test/test-upc/002-upca.tex @@ -0,0 +1,9 @@ +% !TeX program = LuaLaTeX +% Copyright (C) 2019-2022 Roberto Giacomelli + +\documentclass[border=5pt]{standalone} +\usepackage{barracuda} + +\begin{document} +\barracuda[debug_bbox="qz"]{upc-A}{121212343430} +\end{document} \ No newline at end of file -- cgit v1.2.3