Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decode output of fc-match in Python2 as UTF-8 #760

Merged
merged 2 commits into from Mar 10, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 8 additions & 2 deletions rst2pdf/findfonts.py
Expand Up @@ -8,8 +8,10 @@
"""

from __future__ import unicode_literals
import six

import os
import subprocess
import sys

from reportlab.pdfbase import pdfmetrics
Expand Down Expand Up @@ -180,7 +182,9 @@ def findFont(fname):
def findTTFont(fname):

def get_family(query):
data = os.popen("fc-match \"%s\""%query, "r").read()
data = subprocess.check_output(["fc-match", query])
if six.PY2:
data = data.decode('UTF-8')
for line in data.splitlines():
line = line.strip()
if not line:
Expand All @@ -192,7 +196,9 @@ def get_family(query):
return None

def get_fname(query):
data = os.popen("fc-match -v \"%s\""%query, "r").read()
data = subprocess.check_output(["fc-match", "-v", query])
if six.PY2:
data = data.decode('UTF-8')
for line in data.splitlines():
line = line.strip()
if line.startswith("file: "):
Expand Down