1 This patch is pulled from upstream; once we pull in 2.1 or newer, it will |
1 This patch is pulled from upstream; once we pull in 2.1 or newer, it will |
2 no longer be necessary. |
2 no longer be necessary. |
3 |
3 |
4 --- Pygments-1.6/pygments/formatters/img.py Tue Jan 12 15:06:52 2016 |
4 --- Pygments-1.6/pygments/formatters/img.py Sun Feb 3 01:26:49 2013 |
5 +++ Pygments-1.6/pygments/formatters/img.py Tue Jan 12 15:08:24 2016 |
5 +++ Pygments-1.6/pygments/formatters/img.py Wed Jan 20 13:33:20 2016 |
6 @@ -9,6 +9,7 @@ |
6 @@ -15,6 +15,8 @@ |
7 :license: BSD, see LICENSE for details. |
7 from pygments.util import get_bool_opt, get_int_opt, \ |
8 """ |
8 get_list_opt, get_choice_opt |
9 |
9 |
10 +import shlex |
10 +import subprocess |
11 import sys |
11 + |
12 |
12 # Import this carefully |
13 from pygments.formatter import Formatter |
13 try: |
14 @@ -73,8 +74,8 @@ |
14 from PIL import Image, ImageDraw, ImageFont |
|
15 @@ -72,11 +74,11 @@ |
|
16 self._create_nix() |
15 |
17 |
16 def _get_nix_font_path(self, name, style): |
18 def _get_nix_font_path(self, name, style): |
17 from commands import getstatusoutput |
19 - from commands import getstatusoutput |
18 - exit, out = getstatusoutput('fc-list "%s:style=%s" file' % |
20 - exit, out = getstatusoutput('fc-list "%s:style=%s" file' % |
19 - (name, style)) |
21 - (name, style)) |
20 + exit, out = getstatusoutput('fc-list %s file' % |
22 - if not exit: |
21 + shlex.quote("%s:style=%s" % (name, style))) |
23 - lines = out.splitlines() |
22 if not exit: |
24 + proc = subprocess.Popen(['fc-list', "%s:style=%s" % (name, style), 'file'], |
23 lines = out.splitlines() |
25 + stdout=subprocess.PIPE, stderr=None) |
|
26 + stdout, _ = proc.communicate() |
|
27 + if proc.returncode == 0: |
|
28 + lines = stdout.splitlines() |
24 if lines: |
29 if lines: |
|
30 path = lines[0].strip().strip(':') |
|
31 return path |