ThirdParty/Pygments/pygments/formatters/img.py

Sat, 14 Dec 2013 23:44:25 +0100

author
T.Rzepka <Tobias.Rzepka@gmail.com>
date
Sat, 14 Dec 2013 23:44:25 +0100
branch
Py2 comp.
changeset 3145
a9de05d4a22f
parent 2525
8b507a9a2d40
child 4172
4f20dba37ab6
permissions
-rw-r--r--

# __IGNORE_WARNING__ added/ removed.

808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
1 # -*- coding: utf-8 -*-
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
2 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
3 pygments.formatters.img
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
4 ~~~~~~~~~~~~~~~~~~~~~~~
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
5
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
6 Formatter for Pixmap output.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
7
2426
da76c71624de Updated to Pygments 1.6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1705
diff changeset
8 :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS.
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
9 :license: BSD, see LICENSE for details.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
10 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
11
3145
a9de05d4a22f # __IGNORE_WARNING__ added/ removed.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2525
diff changeset
12 from __future__ import unicode_literals
2525
8b507a9a2d40 Script changes: Future import added, super calls modified and unicode behavior for str.
T.Rzepka <Tobias.Rzepka@gmail.com>
parents: 2426
diff changeset
13
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
14 import sys
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
15
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
16 from pygments.formatter import Formatter
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
17 from pygments.util import get_bool_opt, get_int_opt, \
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
18 get_list_opt, get_choice_opt
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
19
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
20 # Import this carefully
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
21 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
22 from PIL import Image, ImageDraw, ImageFont
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
23 pil_available = True
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
24 except ImportError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
25 pil_available = False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
26
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
27 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
28 import winreg
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
29 except ImportError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
30 _winreg = None
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
31
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
32 __all__ = ['ImageFormatter', 'GifImageFormatter', 'JpgImageFormatter',
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
33 'BmpImageFormatter']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
34
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
35
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
36 # For some unknown reason every font calls it something different
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
37 STYLES = {
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
38 'NORMAL': ['', 'Roman', 'Book', 'Normal', 'Regular', 'Medium'],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
39 'ITALIC': ['Oblique', 'Italic'],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
40 'BOLD': ['Bold'],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
41 'BOLDITALIC': ['Bold Oblique', 'Bold Italic'],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
42 }
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
43
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
44 # A sane default for modern systems
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
45 DEFAULT_FONT_NAME_NIX = 'Bitstream Vera Sans Mono'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
46 DEFAULT_FONT_NAME_WIN = 'Courier New'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
47
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
48
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
49 class PilNotAvailable(ImportError):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
50 """When Python imaging library is not available"""
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
51
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
52
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
53 class FontNotFound(Exception):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
54 """When there are no usable fonts specified"""
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
55
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
56
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
57 class FontManager(object):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
58 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
59 Manages a set of fonts: normal, italic, bold, etc...
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
60 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
61
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
62 def __init__(self, font_name, font_size=14):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
63 self.font_name = font_name
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
64 self.font_size = font_size
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
65 self.fonts = {}
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
66 self.encoding = None
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
67 if sys.platform.startswith('win'):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
68 if not font_name:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
69 self.font_name = DEFAULT_FONT_NAME_WIN
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
70 self._create_win()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
71 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
72 if not font_name:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
73 self.font_name = DEFAULT_FONT_NAME_NIX
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
74 self._create_nix()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
75
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
76 def _get_nix_font_path(self, name, style):
2426
da76c71624de Updated to Pygments 1.6.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 1705
diff changeset
77 from subprocess import getstatusoutput
808
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
78 exit, out = getstatusoutput('fc-list "%s:style=%s" file' %
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
79 (name, style))
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
80 if not exit:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
81 lines = out.splitlines()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
82 if lines:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
83 path = lines[0].strip().strip(':')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
84 return path
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
85
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
86 def _create_nix(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
87 for name in STYLES['NORMAL']:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
88 path = self._get_nix_font_path(self.font_name, name)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
89 if path is not None:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
90 self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
91 break
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
92 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
93 raise FontNotFound('No usable fonts named: "%s"' %
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
94 self.font_name)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
95 for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
96 for stylename in STYLES[style]:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
97 path = self._get_nix_font_path(self.font_name, stylename)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
98 if path is not None:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
99 self.fonts[style] = ImageFont.truetype(path, self.font_size)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
100 break
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
101 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
102 if style == 'BOLDITALIC':
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
103 self.fonts[style] = self.fonts['BOLD']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
104 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
105 self.fonts[style] = self.fonts['NORMAL']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
106
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
107 def _lookup_win(self, key, basename, styles, fail=False):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
108 for suffix in ('', ' (TrueType)'):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
109 for style in styles:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
110 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
111 valname = '%s%s%s' % (basename, style and ' '+style, suffix)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
112 val, _ = winreg.QueryValueEx(key, valname)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
113 return val
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
114 except EnvironmentError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
115 continue
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
116 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
117 if fail:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
118 raise FontNotFound('Font %s (%s) not found in registry' %
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
119 (basename, styles[0]))
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
120 return None
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
121
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
122 def _create_win(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
123 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
124 key = winreg.OpenKey(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
125 winreg.HKEY_LOCAL_MACHINE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
126 r'Software\Microsoft\Windows NT\CurrentVersion\Fonts')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
127 except EnvironmentError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
128 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
129 key = winreg.OpenKey(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
130 winreg.HKEY_LOCAL_MACHINE,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
131 r'Software\Microsoft\Windows\CurrentVersion\Fonts')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
132 except EnvironmentError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
133 raise FontNotFound('Can\'t open Windows font registry key')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
134 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
135 path = self._lookup_win(key, self.font_name, STYLES['NORMAL'], True)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
136 self.fonts['NORMAL'] = ImageFont.truetype(path, self.font_size)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
137 for style in ('ITALIC', 'BOLD', 'BOLDITALIC'):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
138 path = self._lookup_win(key, self.font_name, STYLES[style])
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
139 if path:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
140 self.fonts[style] = ImageFont.truetype(path, self.font_size)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
141 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
142 if style == 'BOLDITALIC':
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
143 self.fonts[style] = self.fonts['BOLD']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
144 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
145 self.fonts[style] = self.fonts['NORMAL']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
146 finally:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
147 winreg.CloseKey(key)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
148
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
149 def get_char_size(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
150 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
151 Get the character size.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
152 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
153 return self.fonts['NORMAL'].getsize('M')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
154
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
155 def get_font(self, bold, oblique):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
156 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
157 Get the font based on bold and italic flags.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
158 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
159 if bold and oblique:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
160 return self.fonts['BOLDITALIC']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
161 elif bold:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
162 return self.fonts['BOLD']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
163 elif oblique:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
164 return self.fonts['ITALIC']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
165 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
166 return self.fonts['NORMAL']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
167
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
168
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
169 class ImageFormatter(Formatter):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
170 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
171 Create a PNG image from source code. This uses the Python Imaging Library to
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
172 generate a pixmap from the source code.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
173
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
174 *New in Pygments 0.10.*
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
175
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
176 Additional options accepted:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
177
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
178 `image_format`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
179 An image format to output to that is recognised by PIL, these include:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
180
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
181 * "PNG" (default)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
182 * "JPEG"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
183 * "BMP"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
184 * "GIF"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
185
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
186 `line_pad`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
187 The extra spacing (in pixels) between each line of text.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
188
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
189 Default: 2
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
190
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
191 `font_name`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
192 The font name to be used as the base font from which others, such as
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
193 bold and italic fonts will be generated. This really should be a
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
194 monospace font to look sane.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
195
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
196 Default: "Bitstream Vera Sans Mono"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
197
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
198 `font_size`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
199 The font size in points to be used.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
200
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
201 Default: 14
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
202
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
203 `image_pad`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
204 The padding, in pixels to be used at each edge of the resulting image.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
205
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
206 Default: 10
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
207
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
208 `line_numbers`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
209 Whether line numbers should be shown: True/False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
210
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
211 Default: True
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
212
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
213 `line_number_start`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
214 The line number of the first line.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
215
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
216 Default: 1
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
217
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
218 `line_number_step`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
219 The step used when printing line numbers.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
220
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
221 Default: 1
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
222
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
223 `line_number_bg`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
224 The background colour (in "#123456" format) of the line number bar, or
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
225 None to use the style background color.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
226
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
227 Default: "#eed"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
228
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
229 `line_number_fg`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
230 The text color of the line numbers (in "#123456"-like format).
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
231
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
232 Default: "#886"
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
233
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
234 `line_number_chars`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
235 The number of columns of line numbers allowable in the line number
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
236 margin.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
237
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
238 Default: 2
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
239
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
240 `line_number_bold`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
241 Whether line numbers will be bold: True/False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
242
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
243 Default: False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
244
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
245 `line_number_italic`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
246 Whether line numbers will be italicized: True/False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
247
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
248 Default: False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
249
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
250 `line_number_separator`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
251 Whether a line will be drawn between the line number area and the
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
252 source code area: True/False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
253
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
254 Default: True
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
255
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
256 `line_number_pad`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
257 The horizontal padding (in pixels) between the line number margin, and
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
258 the source code area.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
259
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
260 Default: 6
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
261
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
262 `hl_lines`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
263 Specify a list of lines to be highlighted. *New in Pygments 1.2.*
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
264
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
265 Default: empty list
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
266
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
267 `hl_color`
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
268 Specify the color for highlighting lines. *New in Pygments 1.2.*
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
269
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
270 Default: highlight color of the selected style
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
271 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
272
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
273 # Required by the pygments mapper
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
274 name = 'img'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
275 aliases = ['img', 'IMG', 'png']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
276 filenames = ['*.png']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
277
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
278 unicodeoutput = False
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
279
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
280 default_image_format = 'png'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
281
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
282 def __init__(self, **options):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
283 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
284 See the class docstring for explanation of options.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
285 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
286 if not pil_available:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
287 raise PilNotAvailable(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
288 'Python Imaging Library is required for this formatter')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
289 Formatter.__init__(self, **options)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
290 # Read the style
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
291 self.styles = dict(self.style)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
292 if self.style.background_color is None:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
293 self.background_color = '#fff'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
294 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
295 self.background_color = self.style.background_color
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
296 # Image options
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
297 self.image_format = get_choice_opt(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
298 options, 'image_format', ['png', 'jpeg', 'gif', 'bmp'],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
299 self.default_image_format, normcase=True)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
300 self.image_pad = get_int_opt(options, 'image_pad', 10)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
301 self.line_pad = get_int_opt(options, 'line_pad', 2)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
302 # The fonts
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
303 fontsize = get_int_opt(options, 'font_size', 14)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
304 self.fonts = FontManager(options.get('font_name', ''), fontsize)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
305 self.fontw, self.fonth = self.fonts.get_char_size()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
306 # Line number options
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
307 self.line_number_fg = options.get('line_number_fg', '#886')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
308 self.line_number_bg = options.get('line_number_bg', '#eed')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
309 self.line_number_chars = get_int_opt(options,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
310 'line_number_chars', 2)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
311 self.line_number_bold = get_bool_opt(options,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
312 'line_number_bold', False)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
313 self.line_number_italic = get_bool_opt(options,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
314 'line_number_italic', False)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
315 self.line_number_pad = get_int_opt(options, 'line_number_pad', 6)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
316 self.line_numbers = get_bool_opt(options, 'line_numbers', True)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
317 self.line_number_separator = get_bool_opt(options,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
318 'line_number_separator', True)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
319 self.line_number_step = get_int_opt(options, 'line_number_step', 1)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
320 self.line_number_start = get_int_opt(options, 'line_number_start', 1)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
321 if self.line_numbers:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
322 self.line_number_width = (self.fontw * self.line_number_chars +
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
323 self.line_number_pad * 2)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
324 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
325 self.line_number_width = 0
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
326 self.hl_lines = []
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
327 hl_lines_str = get_list_opt(options, 'hl_lines', [])
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
328 for line in hl_lines_str:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
329 try:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
330 self.hl_lines.append(int(line))
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
331 except ValueError:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
332 pass
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
333 self.hl_color = options.get('hl_color',
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
334 self.style.highlight_color) or '#f90'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
335 self.drawables = []
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
336
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
337 def get_style_defs(self, arg=''):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
338 raise NotImplementedError('The -S option is meaningless for the image '
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
339 'formatter. Use -O style=<stylename> instead.')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
340
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
341 def _get_line_height(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
342 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
343 Get the height of a line.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
344 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
345 return self.fonth + self.line_pad
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
346
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
347 def _get_line_y(self, lineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
348 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
349 Get the Y coordinate of a line number.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
350 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
351 return lineno * self._get_line_height() + self.image_pad
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
352
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
353 def _get_char_width(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
354 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
355 Get the width of a character.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
356 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
357 return self.fontw
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
358
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
359 def _get_char_x(self, charno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
360 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
361 Get the X coordinate of a character position.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
362 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
363 return charno * self.fontw + self.image_pad + self.line_number_width
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
364
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
365 def _get_text_pos(self, charno, lineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
366 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
367 Get the actual position for a character and line position.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
368 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
369 return self._get_char_x(charno), self._get_line_y(lineno)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
370
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
371 def _get_linenumber_pos(self, lineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
372 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
373 Get the actual position for the start of a line number.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
374 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
375 return (self.image_pad, self._get_line_y(lineno))
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
376
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
377 def _get_text_color(self, style):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
378 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
379 Get the correct color for the token from the style.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
380 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
381 if style['color'] is not None:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
382 fill = '#' + style['color']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
383 else:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
384 fill = '#000'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
385 return fill
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
386
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
387 def _get_style_font(self, style):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
388 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
389 Get the correct font for the style.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
390 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
391 return self.fonts.get_font(style['bold'], style['italic'])
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
392
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
393 def _get_image_size(self, maxcharno, maxlineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
394 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
395 Get the required image size.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
396 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
397 return (self._get_char_x(maxcharno) + self.image_pad,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
398 self._get_line_y(maxlineno + 0) + self.image_pad)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
399
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
400 def _draw_linenumber(self, posno, lineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
401 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
402 Remember a line number drawable to paint later.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
403 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
404 self._draw_text(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
405 self._get_linenumber_pos(posno),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
406 str(lineno).rjust(self.line_number_chars),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
407 font=self.fonts.get_font(self.line_number_bold,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
408 self.line_number_italic),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
409 fill=self.line_number_fg,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
410 )
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
411
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
412 def _draw_text(self, pos, text, font, **kw):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
413 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
414 Remember a single drawable tuple to paint later.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
415 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
416 self.drawables.append((pos, text, font, kw))
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
417
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
418 def _create_drawables(self, tokensource):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
419 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
420 Create drawables for the token content.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
421 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
422 lineno = charno = maxcharno = 0
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
423 for ttype, value in tokensource:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
424 while ttype not in self.styles:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
425 ttype = ttype.parent
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
426 style = self.styles[ttype]
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
427 # TODO: make sure tab expansion happens earlier in the chain. It
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
428 # really ought to be done on the input, as to do it right here is
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
429 # quite complex.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
430 value = value.expandtabs(4)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
431 lines = value.splitlines(True)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
432 #print lines
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
433 for i, line in enumerate(lines):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
434 temp = line.rstrip('\n')
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
435 if temp:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
436 self._draw_text(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
437 self._get_text_pos(charno, lineno),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
438 temp,
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
439 font = self._get_style_font(style),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
440 fill = self._get_text_color(style)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
441 )
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
442 charno += len(temp)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
443 maxcharno = max(maxcharno, charno)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
444 if line.endswith('\n'):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
445 # add a line for each extra line in the value
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
446 charno = 0
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
447 lineno += 1
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
448 self.maxcharno = maxcharno
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
449 self.maxlineno = lineno
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
450
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
451 def _draw_line_numbers(self):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
452 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
453 Create drawables for the line numbers.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
454 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
455 if not self.line_numbers:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
456 return
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
457 for p in range(self.maxlineno):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
458 n = p + self.line_number_start
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
459 if (n % self.line_number_step) == 0:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
460 self._draw_linenumber(p, n)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
461
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
462 def _paint_line_number_bg(self, im):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
463 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
464 Paint the line number background on the image.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
465 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
466 if not self.line_numbers:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
467 return
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
468 if self.line_number_fg is None:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
469 return
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
470 draw = ImageDraw.Draw(im)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
471 recth = im.size[-1]
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
472 rectw = self.image_pad + self.line_number_width - self.line_number_pad
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
473 draw.rectangle([(0, 0),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
474 (rectw, recth)],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
475 fill=self.line_number_bg)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
476 draw.line([(rectw, 0), (rectw, recth)], fill=self.line_number_fg)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
477 del draw
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
478
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
479 def format(self, tokensource, outfile):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
480 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
481 Format ``tokensource``, an iterable of ``(tokentype, tokenstring)``
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
482 tuples and write it into ``outfile``.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
483
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
484 This implementation calculates where it should draw each token on the
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
485 pixmap, then calculates the required pixmap size and draws the items.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
486 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
487 self._create_drawables(tokensource)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
488 self._draw_line_numbers()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
489 im = Image.new(
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
490 'RGB',
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
491 self._get_image_size(self.maxcharno, self.maxlineno),
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
492 self.background_color
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
493 )
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
494 self._paint_line_number_bg(im)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
495 draw = ImageDraw.Draw(im)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
496 # Highlight
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
497 if self.hl_lines:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
498 x = self.image_pad + self.line_number_width - self.line_number_pad + 1
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
499 recth = self._get_line_height()
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
500 rectw = im.size[0] - x
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
501 for linenumber in self.hl_lines:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
502 y = self._get_line_y(linenumber - 1)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
503 draw.rectangle([(x, y), (x + rectw, y + recth)],
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
504 fill=self.hl_color)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
505 for pos, value, font, kw in self.drawables:
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
506 draw.text(pos, value, font=font, **kw)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
507 im.save(outfile, self.image_format.upper())
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
508
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
509
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
510 # Add one formatter per format, so that the "-f gif" option gives the correct result
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
511 # when used in pygmentize.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
512
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
513 class GifImageFormatter(ImageFormatter):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
514 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
515 Create a GIF image from source code. This uses the Python Imaging Library to
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
516 generate a pixmap from the source code.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
517
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
518 *New in Pygments 1.0.* (You could create GIF images before by passing a
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
519 suitable `image_format` option to the `ImageFormatter`.)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
520 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
521
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
522 name = 'img_gif'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
523 aliases = ['gif']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
524 filenames = ['*.gif']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
525 default_image_format = 'gif'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
526
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
527
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
528 class JpgImageFormatter(ImageFormatter):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
529 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
530 Create a JPEG image from source code. This uses the Python Imaging Library to
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
531 generate a pixmap from the source code.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
532
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
533 *New in Pygments 1.0.* (You could create JPEG images before by passing a
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
534 suitable `image_format` option to the `ImageFormatter`.)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
535 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
536
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
537 name = 'img_jpg'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
538 aliases = ['jpg', 'jpeg']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
539 filenames = ['*.jpg']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
540 default_image_format = 'jpeg'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
541
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
542
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
543 class BmpImageFormatter(ImageFormatter):
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
544 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
545 Create a bitmap image from source code. This uses the Python Imaging Library to
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
546 generate a pixmap from the source code.
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
547
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
548 *New in Pygments 1.0.* (You could create bitmap images before by passing a
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
549 suitable `image_format` option to the `ImageFormatter`.)
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
550 """
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
551
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
552 name = 'img_bmp'
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
553 aliases = ['bmp', 'bitmap']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
554 filenames = ['*.bmp']
8f85926125ef Updated Pygments to version 1.4.0.
Detlev Offenbach <detlev@die-offenbachs.de>
parents: 684
diff changeset
555 default_image_format = 'bmp'

eric ide

mercurial