log_formatter_pil.py
changeset 124 4bc4de14f006
parent 80 a0662cff1d9d
--- a/log_formatter_pil.py	Fri Feb 13 01:18:28 2009 +0200
+++ b/log_formatter_pil.py	Sat Feb 14 17:59:13 2009 +0200
@@ -14,6 +14,9 @@
     # the font we load
     font = None
 
+    # line spacing in pixels
+    LINE_SPACING = 1
+
     def _load_font (self) :
         """
             Use the configured img_ttf_path for a TrueType font, or a default one
@@ -33,6 +36,10 @@
         return self.font
 
     def format_png (self, lines, **kwargs) :
+        """
+            Build and return a PNG image of the given lines, using format_txt
+        """
+
         # load font
         font = self._load_font()
 
@@ -44,7 +51,7 @@
 
         # figure out how wide/high the image will be
         width = max(width for width, height in line_sizes)
-        height = sum(height for width, height in line_sizes)
+        height = sum(height + self.LINE_SPACING for width, height in line_sizes)
 
         # create new B/W image
         img = Image.new('L', (width, height), 0xff)
@@ -61,7 +68,7 @@
             draw.text((0, offset_y), line, font=font)
 
             # next offset
-            offset_y += height
+            offset_y += height + self.LINE_SPACING
         
         # output buffer
         buf = StringIO()