Last active
August 11, 2016 04:48
-
-
Save ethan605/8de0bd2b75d28f2a245f23c9b2d09d08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Patch for pygments/formatters/img.py | |
# Define font to use | |
DEFAULT_FONT_NAME_NIX = 'Menlo' | |
class FontManager(object): | |
# ... Other methods | |
def _get_nix_font_path(self, name, style): | |
# Fix 'fc-list' command to explore exact font to use | |
proc = subprocess.Popen(['fc-list', "%s:style=%s" % (name, style), 'file'], stdout=subprocess.PIPE) | |
stdout, _ = proc.communicate() | |
if proc.returncode == 0: | |
lines = stdout.splitlines() | |
for line in lines: | |
if line.startswith(b'Fontconfig warning:'): | |
continue | |
path = line.decode().strip().strip(':') | |
if path: | |
return path | |
return None | |
# Other methods ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Fontconfig with Brew | |
# using --universal flag for better font configs recogization | |
$ brew install fontconfig --universal | |
# Might use this to establish cache | |
$ fc-cache /Library/Fonts |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment