diff options
Diffstat (limited to 'pygments/formatters/rtf.py')
-rw-r--r-- | pygments/formatters/rtf.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index 3efda284..9d87e8f1 100644 --- a/pygments/formatters/rtf.py +++ b/pygments/formatters/rtf.py @@ -5,11 +5,12 @@ A formatter that generates RTF files. - :copyright: Copyright 2006-2013 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2014 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ from pygments.formatter import Formatter +from pygments.util import get_int_opt __all__ = ['RtfFormatter'] @@ -21,7 +22,7 @@ class RtfFormatter(Formatter): documents with color information and other useful stuff. Perfect for Copy and Paste into Microsoft® Word® documents. - *New in Pygments 0.6.* + .. versionadded:: 0.6 Additional options accepted: @@ -32,6 +33,12 @@ class RtfFormatter(Formatter): `fontface` The used font famliy, for example ``Bitstream Vera Sans``. Defaults to some generic font which is supposed to have fixed width. + + `fontsize` + Size of the font used. Size is specified in half points. The + default is 24 half-points, giving a size 12 font. + + .. versionadded:: 2.0 """ name = 'RTF' aliases = ['rtf'] @@ -49,9 +56,11 @@ class RtfFormatter(Formatter): specification claims that ``\fmodern`` are "Fixed-pitch serif and sans serif fonts". Hope every RTF implementation thinks the same about modern... + """ Formatter.__init__(self, **options) self.fontface = options.get('fontface') or '' + self.fontsize = get_int_opt(options, 'fontsize', 0) def _escape(self, text): return text.replace('\\', '\\\\') \ @@ -106,6 +115,8 @@ class RtfFormatter(Formatter): )) offset += 1 outfile.write(r'}\f0') + if self.fontsize: + outfile.write(r'\fs%d' % (self.fontsize)) # highlight stream for ttype, value in tokensource: |