Friday, May 29, 2009

Syx changes web and git hosting

I'm officializing the change of web hosting and git hosting from googlecode to berlios:

The new website is up!
For several reasons, including reliability, we switched both the website and git hosting to berlios. Also the purpose of this change is to rewrite the website backend using Syx.
The mailing list and the bug tracker are still hosted at googlecode.

Some progress news in the while
We're working on a new memory management, object representation and garbage collector. On the other side the lack of time is making things harder for releasing the new version. Together with the above changes, new Smalltalk standard pieces will implemented as usual. I remind you the new code is in
the object branch.

Wednesday, May 27, 2009

Render tables with pangocairo like reportlab

lately I was wondering if there was any alternative to the well known reportlab python software for creating PDF reports. I immediately thought about Cairo. The only two problems are:
  • Cairo doesn't create multiple pages
  • No support for creating tables containing text, necessary for table-based reports
I still can't realize how to achieve the first feature, but the second one could be solved using Pango layouts.
The idea is to create the cells of the table using such layouts, so that the text get wrapped etc.

Here's the Pango tables code snippet containing the necessary classes for achieving the job. Notice that the methods in the snippet often make use of Pango units instead of pixels.
Now let's use the Table class as follows: create a table with two rows and two columns, then show it twice with different background colors.

surface = cairo.PDFSurface ("test.pdf", 300, 400)
cr = cairo.Context (surface)
cr = pangocairo.CairoContext (cairo.Context (surface))

sizes = [pango.SCALE*12*10, pango.SCALE*12*10]
data = [["first test with pango tables", "seems to work correctly"],
["though it needs", "support for borders and spans"]]

table = Table (cr, sizes, data, pango.FontDescription ("Sans 12"))
cr.rectangle (0, 0, pango.PIXELS(table.get_width ()), pango.PIXELS(table.get_height()))
cr.set_source_rgb (0.8, 0.8, 0.8)
cr.fill ()
cr.set_source_rgb (0, 0, 0)
table.show_table (cr)

cr.translate (0, 200)
cr.rectangle (0, 0, pango.PIXELS(table.get_width ()), pango.PIXELS(table.get_height()))
cr.set_source_rgb (0.4, 0.5, 0.7)
cr.fill ()
cr.set_source_rgb (0, 0, 0)
table.show_table (cr)

Here's the result test.pdf:

Monday, May 18, 2009

Blogging from Epiphany WebKit

I've been using Midori for a while. It's a great browser: innovative and light. However all my bookmarks and data are in Epiphany. Last week the new epiphany-webkit version has been uploaded in Debian Sid and I couldn't wait to test it. I'm currently using it instead of gecko; it has still some issues but I begun living without it.