![]() |
The renderer interface | ![]() |
All graphical output of TeXmacs goes through one abstract class, renderer_rep, declared in
Graphics/Renderer/renderer.hpp
. A renderer is a drawing surface: the screen (or rather a backing store of a window), an off-screen pixmap, an image in memory, a PostScript file or a PDF file. The typesetter produces a tree of boxes; every box knows how to paint itself on an arbitrary renderer, and it never needs to know which concrete device it is painting on. The same box_rep::redraw code is used for repainting a window, for printing, for exporting a document to PDF and for rasterizing a snippet into a png file.
The abstract class provides three things:
A coordinate system: an origin, a zoom factor and a clipping rectangle, together with the conversion routines between the logical coordinates of the typesetter and device pixels. This part is implemented once and for all in
Graphics/Renderer/renderer.cpp
.
A graphical state (the current pencil, brush and background) and a small set of drawing primitives: glyphs, lines, polylines, rectangles, arcs, polygons and pictures. Most of these are pure virtual and must be supplied by the concrete renderers.
A few device-specific services: shadows for double buffering on the screen, off-screen rendering into pictures, and, for printers, pages, hyperlinks, a table of contents and metadata.
The type renderer is simply a plain pointer typedef renderer_rep* renderer; renderers are not reference counted. They are created with tm_new and destroyed with tm_delete or delete_renderer. For printers, destroying the renderer is what finishes and writes the output file.
The relevant source files are:
Graphics/Renderer/
The abstract class (
renderer.hpp
,
renderer.cpp
), the common base class of the screen renderers (
basic_renderer.hpp
,
basic_renderer.cpp
), the PostScript renderer (
printer.hpp
,
printer.cpp
), pencils (
pencil.hpp
), brushes (
brush.hpp
) and paper sizes (
page_type.hpp
).
Graphics/Pictures/
The picture abstraction (
picture.hpp
), portable raster pictures (
raster.hpp
,
raster_picture.hpp
), scalable images (
scalable.hpp
) and graphical effects (
effect.hpp
).
The Qt screen renderer (
qt_renderer.hpp
,
qt_renderer.cpp
) and Qt native pictures (
qt_picture.hpp
,
qt_picture.cpp
). The directory
Plugins/Qt6/
contains a slightly different copy of these files.
Plugins/Pdf/
The PDF renderer based on the PDFHummus library (
pdf_hummus_renderer.hpp
,
pdf_hummus_renderer.cpp
).
The X11 renderer (
Plugins/X11/x_drawable.hpp
,
x_shadow.cpp
,
x_picture.cpp
), the MuPDF renderers of the SDL and Vue ports and of PDF export (
Plugins/MuPDF/
), the GPU renderer of Vue (
vue_gpu.cpp
), the Cocoa renderer (
ns_renderer.mm
), and the older Cairo renderer (
Plugins/Cairo/
).