diff -r 85345abbd46a -r 43ac75054d5c preferences.py --- a/preferences.py Tue Feb 10 01:24:59 2009 +0200 +++ b/preferences.py Tue Feb 10 02:57:16 2009 +0200 @@ -244,6 +244,47 @@ return tz.zone +class ImageFont (Preference) : + """ + Font for ImageFormatter + """ + + # set name + name = 'image_font' + + def __init__ (self, font_dict, default_name) : + """ + Use the given { name: (path, title) } dict and default the given name + """ + + self.font_dict = font_dict + self.default = self.parse(default_name) + + def parse (self, name) : + """ + name -> (name, path, title) + """ + + path, title = self.font_dict[name] + + return name, path, title + + def build (self, font_info) : + """ + (name, path, title) -> name + """ + + name, path, title = font_info + + return name + +class ImageFontSize (urltree.URLIntegerType, Preference) : + # set name, default + name = 'image_font_size' + default = config.PREF_IMAGE_FONT_SIZE_DEFAULT + + # XXX: params + class Formatter (Preference) : """ LogFormatter to use @@ -276,10 +317,13 @@ def process (self, prefs, fmt_cls) : """ - class LogFormatter -> LogFormatter(tz, time_fmt) + class LogFormatter -> LogFormatter(tz, time_fmt, image_font.path) """ - return fmt_cls(prefs[timezone], prefs[time_format]) + font_name, font_path, font_title = prefs[image_font] + font_size = prefs[image_font_size] + + return fmt_cls(prefs[timezone], prefs[time_format], font_path, font_size) class Count (urltree.URLIntegerType, Preference) : """ @@ -299,6 +343,8 @@ time_format = TimeFormat() date_format = DateFormat() timezone = Timezone() +image_font = ImageFont(config.FORMATTER_IMAGE_FONTS, config.PREF_IMAGE_FONT_DEFAULT) +image_font_size = ImageFontSize() formatter = Formatter(config.LOG_FORMATTERS, config.PREF_FORMATTER_DEFAULT) count = Count() @@ -306,6 +352,8 @@ time_format, date_format, timezone, + image_font, + image_font_size, formatter, count, ])