Sunday, June 25, 2006

Newspaper Design Algorithm

As I was mentioning in an earlier blog entry, the part of the FeedJournal project which I have been feeling most insecure about is how to design the algorithm for laying out the articles in the newspaper. This is a critical step for a number of reasons: it has to look like a newspaper, it has to read like a newspaper, and it has to be pretty (the output PDF is essentially a part of the FeedJournal GUI).

Anyway, I am happy to report that significant progress have been in this area. I developed an algorithm which dynamically creates a newspaper with customizable:

  • number of paragraphs
  • margins
  • paper size
  • font
  • spacing between rows and various article elements

I have also implemented support for a headline font size which is a function of the article's importance/size.

Together with the masthead (newspaper lingo for the first page logotype) the whole creation starts to look pretty snazzy, if I get to say it myself.

The algorithm implementing the layout is pretty simple, but efficient. First, I gather the collection of articles which are due to be published in the upcoming issue. I sort these according to size/importance; this step is made very simple by the new Generics classes in .NET 2.0. Then I take the first article which fits into the next available space on the current page and remove the article from the collection and mark the page space as occupied. If no article fits the remaining space I will publish what fits on the page and add a page jump to another page where the article is continued. Basically that's all there is too it, and this algorithm works very well so far.

In one of the coming blog posts I will attach a sample PDF file to showcase FeedJournal.

No comments:

Post a Comment