diff options
author | Tim Hatch <tim@timhatch.com> | 2014-04-14 13:47:40 -0400 |
---|---|---|
committer | Tim Hatch <tim@timhatch.com> | 2014-04-14 13:47:40 -0400 |
commit | 06a720cca67ff19f873f8066c17cf4ea90ab0f0f (patch) | |
tree | 2901fe8e218cce5a8e788645d41aec654f297e23 /pygments/formatters/rtf.py | |
parent | 02683b5def213065f6b893f91fc54f313141fbdf (diff) | |
parent | 5d57fe78405ac06a306f5ed2dd1b630a909cbdfb (diff) | |
download | pygments-06a720cca67ff19f873f8066c17cf4ea90ab0f0f.tar.gz |
Merged in yloiseau/pygments-main (pull request #309)
Diffstat (limited to 'pygments/formatters/rtf.py')
-rw-r--r-- | pygments/formatters/rtf.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index 59d97742..9d87e8f1 100644 --- a/pygments/formatters/rtf.py +++ b/pygments/formatters/rtf.py @@ -10,6 +10,7 @@ """ from pygments.formatter import Formatter +from pygments.util import get_int_opt __all__ = ['RtfFormatter'] @@ -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: |