From fa4ae59b6a512f61833bf7482eb50c9039ce9d20 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 20 May 2021 20:50:46 -0400 Subject: [PATCH] De-duplicate fonts in LaTeX preamble. If the same font is used in sans + serif, then the `usepackage` gets duplicated. This appears harmless, but can be de-duplicated to simplify the produced LaTeX files. --- lib/matplotlib/texmanager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index c2fe3b687976..79b9106a4ada 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -110,12 +110,12 @@ def get_font_config(self): # The following packages and commands need to be included in the latex # file's preamble: - cmd = [fonts['serif'][1], - fonts['sans-serif'][1], - fonts['monospace'][1]] + cmd = {fonts[family][1] + for family in ['serif', 'sans-serif', 'monospace']} if self.font_family == 'cursive': - cmd.append(fonts['cursive'][1]) - self._font_preamble = '\n'.join([r'\usepackage{type1cm}', *cmd]) + cmd.add(fonts['cursive'][1]) + cmd.add(r'\usepackage{type1cm}') + self._font_preamble = '\n'.join(sorted(cmd)) return ''.join(fontconfig)