Architecture overview of “boxes and glue”

Here is an attempt go give you an overview of the “boxes and glue” PDF typesetting library

There is a high level API (the frontend) and a low level API. Both can be used to create PDF documents. While the frontend gives you ready to use data structures and methods, you can still use the backend and create all the items yourself.


The frontend

The typesetting frontend knows about these building blocks:

The backend

The backend has all low level functions to handle typesetting (basic font loading and accessing, language handling and hyphenation, justification of paragraphs, …). It also contains the logging API that is used in the frontend can which can be used in the underlying application.


The basic typesetting unit is a “scaled point”. 65535 scaled points are in one dtp point. There are two methods (bag.Sp() and bag.MustSp()) to convert from other units to sp.

The part that needs the most explanation is the one on nodes:


A node is a tiny piece of information that can be chained with other nodes to node lists. A node can be a glyph, a rule, an image or a box that holds other nodes.

These are the known node types:

(to be continued/extended)