# HG changeset patch # User Tero Marttila # Date 1234627153 -7200 # Node ID 4bc4de14f00638c9baf2db2c8ef6fad93d4b011d # Parent 3297596ab60635206155356997a54a78ba9e52ad remove support for default font, as it doesn't support unicode, and implement a 1px line spacing for format_png diff -r 3297596ab606 -r 4bc4de14f006 config.py --- a/config.py Fri Feb 13 01:18:28 2009 +0200 +++ b/config.py Sat Feb 14 17:59:13 2009 +0200 @@ -73,7 +73,8 @@ # TTF fonts to use for drawing images FORMATTER_IMAGE_FONTS = { - 'default': (None, "Ugly default font" ), + # XXX: no unicode support + # 'default': (None, "Ugly default font" ), 'ttf-dejavu-mono': ("/usr/share/fonts/truetype/ttf-dejavu/DejaVuSansMono.ttf", "DejaVu Sans Mono" ), 'ttf-liberation-mono': ("/usr/share/fonts/truetype/ttf-liberation/LiberationMono-Regular.ttf", "Liberation Mono Regular" ) } @@ -91,8 +92,8 @@ PREF_FORMATTER_DEFAULT = IrssiFormatter PREF_COUNT_DEFAULT = 200 PREF_COUNT_MAX = None -PREF_IMAGE_FONT_DEFAULT = 'default' -PREF_IMAGE_FONT_SIZE_DEFAULT = 10 +PREF_IMAGE_FONT_DEFAULT = 'ttf-dejavu-mono' +PREF_IMAGE_FONT_SIZE_DEFAULT = 12 PREF_IMAGE_FONT_SIZE_MAX = 32 # search line count options diff -r 3297596ab606 -r 4bc4de14f006 log_formatter_pil.py --- 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()