{Boxes and glue: \TeX\ algorithms reimplemented} {Patrick Gundlach} {\TeX\ (and therefore \LaTeX) have enjoyed great popularity over the years as an extremely flexible, versatile, and robust text typesetting system. The flexibility comes not least from the ability to modify the behavior of \TeX\ through programming and from Knuth's foresight in recognizing the individual elements on the page as small, rectangular building blocks that can be combined into larger units and also manipulated (box). The development of Lua\TeX\ made modern applications possible for the first time in the long history of \TeX\ via some extensions: \item The number of characters in fonts is no longer limited to 256. This eliminates crutches like output encoding. \item Through the integration of \HarfBuzz\ a solid ``shaper'' is available. This allows OpenType features and complicated writing systems (e.g., Arabic) to be output without any problems. \item The system can be programmed with Lua instead of the built-in macro language. \item Due to the clever \PDF\ support, almost all \PDF\ properties and standards can be supported. I use these extensions for the program `speedata Publisher'', which is mainly made for the fully automatic creation of product catalogs and data sheets from \XML. Despite all the achievements of \TeX\ and \LuaTeX, there are still serious disadvantages: \item \TeX\ and \LuaTeX\ are anything but modular. Changing single areas is especially difficult, because \TeX\ is not designed for that. \item Some things cannot be achieved with \LuaTeX's on-board tools. For example, \HTTPS\ requests require an external library. Documents in our catalog area often get their images from image databases that are accessed via \HTTPS. \item For other tasks, too, it is better to use an external library than to reinvent the wheel. For example, an \XML\ parser or a library for bidirectional text typesetting. \item Parallelization of tasks: modern processors usually have several processor cores, which lie idle with \TeX. Several tasks in \TeX\ could be executed in parallel. Paragraphs could be wrapped with different parameters and then the best one selected. Loading font files and preparing them for subsetting in \PDF\ does not have to be done sequentially. \TeX\ does not provide such facilities. \item Distributing \LuaTeX\ binaries across platforms is difficult due to external dependencies. For single applications you don't want to ship or require a whole \TeX\ Live installation. The restrictions mentioned have disturbed me considerable. Regarding the output quality of \TeX, there are hardly comparable alternatives\Dash especially not in the opensource area. Therefore, there seemed no alternative left but to re-implement \TeX\ in a ``modern'' programming language. Some years ago there was already such an attempt (\NTS), but it failed. After long pondering, respectively to meet my requirements for a text typesetting system for catalogs and datasheets, I came to the conclusion that I ``only'' take over the algorithms and the logic of \TeX, but not the input language. \subhead{Boxes and glue} ``Boxes and glue'' is a library written in the Go programming language. The name is based on the model of \TeX\ with the stretchable spaces between the rectangular units. The development of boxes and glue is quite advanced and includes among other things: \item \TeX's smallest units (node) with ways to nest them inside each other (vbox, hbox). \item \TeX's paragraph breaking algorithm. \item The pattern-based hyphenation. \item The inclusion of TrueType and OpenType fonts and \PNG, \JPEG, and \PDF\ images. \item Text shaping with \HarfBuzz. Besides these basic parts, there is yet another library that builds on \texttt{boxesandglue}. It offers: \item Reading \XML\ files \item Interpretation of \HTML\ and \CSS \item grouping of font files into families with easy font selection \item Handling of colors of all kinds (\RGB, \CMYK, spot colors) \item Tagged \PDF The application programming interface (\API) is not yet fixed. The development of boxes and glue is being carried out in parallel with the further development of the speedata Publisher (\tbsurl{https://github.com/speedata/xts}) and the requirements here largely determine the programming interface of \texttt{boxesandglue}. Since it is a library, there is no fixed input language as with \TeX. In this respect also, \texttt{boxesandglue} is also yet suitable for and (end) user. \subhead{References} \item \NTS: \tbsurl{https://en.wikipedia.org/wiki/New_Typesetting_System} \item Boxes and glue: \tbsurl{https://github.com/speedata/boxesandglue} \item speedata Publisher: \tbsurl{https://github.com/speedata/publisher} \item \acro{XTS XML}: https://github.com/speedata/xts }