Impact: Free DTP (1999)

Impact R.I.P

I started writing a DTP program, because at the time I was designing flyers and posters and there were no open source DTP packages which fitted my requirments. I abandoned this project when I found that KWord had acquired support for frames. I’ve left this page up for posterity.

First version of Impact

I’ve recently started writing a desktop publishing program, tentatively called “Impact”. This will shortly be released under the GPL. I started writing it because I wanted to do some page layout, but didn’t have access to any DTP software. It’s a classic ‘scratching an itch’ situation.

The DTP program is currently around 2500 lines of C++, using the GTK toolkit and the FreeType font rendering library. It resembles Pagemaker, because that’s the only DTP program I’ve used before. I’m not releasing the source yet because it’s still in a state of rapid flux. I want to restructure part of the code to increase modularity and facilitate extension.

Currently, I have much of the text layout code written. This includes stuff like adjustable kerning, leading, different justification, indents, text styles and text flow across multiple boxes. Line breaking is naive and there’s no hyphenation. I’ll structure things so you can add in a new linebreaking algorithm without too much difficulty. The structure of a multi-paged document is there, so you can insert/delete pages and flip between them.

I’ve put effort into making sure that page rendering runs quickly. This involves demand rendering of fonts, and lazy page layout code. Panning works smoothly, even at 800% zoom. The FreeType library produces antialiased fonts, so your page looks better onscreen too.

There is no image or shape handling code yet. Layers haven’t yet been added but they are easy. You can’t print documents either, until I either add Type 1 support or read about using Truetype font in PS. You can only load in ASCII files, but there will be an interface for adding new import filters.

So, it’s all a long way from being useful for Real page layout!

Typical page with two stories pasted into place:

Now we’re zoomed in to show the antialiasing (and probably jpg artifacts too) and kerning.

(19 August 1999)

Second version of Impact

I wrote the above description about a year ago. Since then I’ve rewritten the program from scratch. The first attempt taught me the required typographical concepts, and hinted at the internal structures required for the program. But the code was full of built-in limitations, so after a gap of several months, I started the redesign. I’ll briefly describe the new design and codebase.

The project contains a low-level layout and page management library which uses FreeType and supports an abstract drawing visitor interface to allow rendering to different devices. Currently, it renders to an RGBBuffer which is displayed using GdkRGB. I’ll probably use libart soon once more complex blitting and rendering behaviour is needed.

The project also contains an extensive unit test suite, inspired by Kent Beck’s xUnit, called QuickCppUnit which I wrote. It’s a generic framework, but is extremely useful for testing the layout code.

The project will also eventually contain GUI frontends for various platforms. There’s a very simple gtk– front end which I use for testing, but nothing which resembles a real DTP program yet. I’m concentrating on the underlying functionality for now.

I’ve took a screenshot of a test program, and I’ll use it to describe the things which the code supports. Internally, pages contain a variety of object - currently text areas and coloured boxes. Text can be layed out across arbitary shapes (shape produces spans which the layout strategy fills with text), although the screenshot only shows a box-shape. The rendered text is antialiased, thanks to FreeType. The different page objects use an alpha channel to provide transparency.

I’ve set up the boxes in the screenshot to be overlapping to show this. Not all glyph attributes have been wired up yet, but the screenshot shows different colors, sizes and fonts used. There are caches for fonts, typefaces and rendered glyphs. The layout algorithm can be easily replaced (it uses the GoF strategy pattern) - the screenshot shows a very simple text compositor. It is possible to add more complex ones, such as the one used in TeX. Stories are implemented with an emacs-style movable gap for efficient editing.

I’ve been looking at PDF output. There’s a pdflib around, but it doesn’t look like the license is GPL-compatible, so I’ve got some code which I’m working on to do much the same as pdflib, but in C++ rather than C.

So, there is no support for images and there is no real user interface. There’s very little support for one yet - no hit detection, little support for invalidated regions. These will all be coming soon. There is a flexible page/text layout engine into which you can plug various drawers, text layout algorithms and custom page objects.

The project is implemented using C++, STL, Freetype, Gtk/gdk and Gtk– libraries and will be released under the GPL.