GUI - Revert Conda default font fix

This commit is contained in:
torzdf 2020-11-01 00:44:12 +00:00
parent ef099665f7
commit c24bf2b480
2 changed files with 8 additions and 21 deletions

View File

@ -110,4 +110,10 @@ def get_clean_fonts():
fonts.setdefault(font.name, dict())["bold"] = True
valid_fonts = {key for key, val in fonts.items() if len(val) == 2}
retval = sorted(list(valid_fonts.intersection(tk_font.families())))
if not retval:
# Return the font list with any @prefixed or non-Unicode characters stripped and default
# prefixed
logger.debug("No bold/regular fonts found. Running simple filter")
retval = sorted([fnt for fnt in tk_font.families()
if not fnt.startswith("@") and not any([ord(c) > 127 for c in fnt])])
return ["default"] + retval

View File

@ -182,7 +182,7 @@ class FileHandler(): # pylint:disable=too-few-public-methods
if len(filetypes[key]) > 2:
multi = ["{} Files".format(key.title())]
multi.append(" ".join([ftype[1]
for ftype in filetypes[key] if ftype[0] != "All files"]))
for ftype in filetypes[key] if ftype[0] != "All files"]))
filetypes[key].insert(0, tuple(multi))
return filetypes
@ -771,7 +771,7 @@ class Config():
def __init__(self, root, cli_opts, statusbar):
logger.debug("Initializing %s: (root %s, cli_opts: %s, statusbar: %s)",
self.__class__.__name__, root, cli_opts, statusbar)
self._default_font = self._set_default_font()
self._default_font = tk.font.nametofont("TkDefaultFont").configure()["family"]
self._constants = dict(
root=root,
scaling_factor=self._get_scaling(root),
@ -894,25 +894,6 @@ class Config():
logger.debug("dpi: %s, scaling: %s'", dpi, scaling)
return scaling
@classmethod
def _set_default_font(cls):
""" Set the default font.
For macOS and Windows, this just pulls back the system default font.
For Linux, quite often the default is not ideal, so we try to pull a sane default from
installed fonts.
"""
if platform.system() == "Linux":
for family in ("DejaVu Sans", "Noto Sans", "Nimbus Sans"):
if family in tk.font.families():
logger.debug("Setting default font to: '%s'", family)
tk.font.nametofont("TkDefaultFont").configure(family=family)
tk.font.nametofont("TkHeadingFont").configure(family=family)
tk.font.nametofont("TkMenuFont").configure(family=family)
break
return tk.font.nametofont("TkDefaultFont").configure()["family"]
def set_default_options(self):
""" Set the default options for :mod:`lib.gui.projects`