diff options
author | Jharrod LaFon <jharrod.lafon@gmail.com> | 2014-04-14 14:01:51 -0400 |
---|---|---|
committer | Jharrod LaFon <jharrod.lafon@gmail.com> | 2014-04-14 14:01:51 -0400 |
commit | acd5cf2113bb179731a94984bb826528a31fcb06 (patch) | |
tree | 66da33b35d68d2dc3ecbc6cfb9b401ac6351a6a9 /pygments/formatters/rtf.py | |
parent | a88ed45d9bdc2e158fe7d69be8e01f798ded7b8e (diff) | |
parent | 5d57fe78405ac06a306f5ed2dd1b630a909cbdfb (diff) | |
download | pygments-acd5cf2113bb179731a94984bb826528a31fcb06.tar.gz |
Merged head
Diffstat (limited to 'pygments/formatters/rtf.py')
-rw-r--r-- | pygments/formatters/rtf.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py index 45cb2d88..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'] @@ -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: |