doc: tune pdf fonts
authorJohn McNamara <john.mcnamara@intel.com>
Tue, 3 Feb 2015 14:11:15 +0000 (14:11 +0000)
committerThomas Monjalon <thomas.monjalon@6wind.com>
Thu, 19 Mar 2015 16:58:41 +0000 (17:58 +0100)
This mainly adds metadata but also includes an override to the
Latex formatter to control the font size in code blocks.

Signed-off-by: John McNamara <john.mcnamara@intel.com>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
doc/guides/conf.py

index 7151dfd..168efa6 100644 (file)
@@ -29,6 +29,8 @@
 #   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 import subprocess
+from sphinx.highlighting import PygmentsBridge
+from pygments.formatters.latex import LatexFormatter
 
 project = 'DPDK'
 
@@ -46,3 +48,32 @@ latex_documents = [
      '',
      'manual')
 ]
+
+# Latex directives to be included directly in the latex/pdf docs.
+latex_preamble = r"""
+\usepackage[utf8]{inputenc}
+\usepackage{DejaVuSansMono}
+\usepackage[T1]{fontenc}
+\usepackage{helvet}
+\renewcommand{\familydefault}{\sfdefault}
+\RecustomVerbatimEnvironment{Verbatim}{Verbatim}{xleftmargin=5mm}
+"""
+
+# Configuration for the latex/pdf docs.
+latex_elements = {
+    'papersize': 'a4paper',
+    'pointsize': '11pt',
+    # customize Latex formatting
+    'preamble': latex_preamble
+}
+
+# Override the default Latex formatter in order to modify the
+# code/verbatim blocks.
+class CustomLatexFormatter(LatexFormatter):
+    def __init__(self, **options):
+        super(CustomLatexFormatter, self).__init__(**options)
+        # Use the second smallest font size for code/verbatim blocks.
+        self.verboptions = r'formatcom=\footnotesize'
+
+# Replace the default latex formatter.
+PygmentsBridge.latex_formatter = CustomLatexFormatter