summaryrefslogtreecommitdiff
path: root/pygments/formatters/rtf.py
diff options
context:
space:
mode:
authorGaurav Jain <gaurav@gauravjain.org>2014-03-21 12:31:26 -0400
committerGaurav Jain <gaurav@gauravjain.org>2014-03-21 12:31:26 -0400
commit8f72650986df0619b485294429559bb179e366d3 (patch)
tree4e85c569ae4cea16bcd7be75ea2d5e8ddb90d461 /pygments/formatters/rtf.py
parent1cc5cdc3503397d330251dd3bfd5b7286b0ead19 (diff)
downloadpygments-8f72650986df0619b485294429559bb179e366d3.tar.gz
Support fontsize option for RTF formatting
Diffstat (limited to 'pygments/formatters/rtf.py')
-rw-r--r--pygments/formatters/rtf.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/pygments/formatters/rtf.py b/pygments/formatters/rtf.py
index 59d97742..ce795bb5 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']
@@ -49,9 +50,14 @@ class RtfFormatter(Formatter):
specification claims that ``\fmodern`` are "Fixed-pitch serif
and sans serif fonts". Hope every RTF implementation thinks
the same about modern...
+
+ ``fontsize``
+ Size of the font used. Size is specified in half points. The
+ default is 24 half-points, giving a size 12 font.
"""
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 +112,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: