Skip to content

Commit

Permalink
Visual settings: Put default family and related fonts on the top
Browse files Browse the repository at this point in the history
  • Loading branch information
janezd committed Sep 4, 2020
1 parent 0c36403 commit d92de40
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Orange/widgets/visualize/utils/customizableplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from pyqtgraph.graphicsItems.LegendItem import ItemSample

from orangewidget.utils.visual_settings_dlg import KeyType, ValueType, \
SettingsType
SettingsType, FontList

_SettingType = Dict[str, ValueType]
_LegendItemType = Tuple[ItemSample, pg.LabelItem]
Expand All @@ -29,7 +29,18 @@ def available_font_families() -> List:
_ = QApplication(sys.argv)
fonts = QFontDatabase().families()
default = fonts.pop(fonts.index(default_font_family()))
return [default] + sorted(fonts, key=lambda s: s.replace(".", "{"))
defaults = [default]

guessed_name = default.split()[0]
i = 0
while i < len(fonts):
if fonts[i].startswith(guessed_name):
defaults.append(fonts.pop(i))
else:
i += 1
return FontList(defaults
+ [""]
+ sorted(fonts, key=lambda s: s.replace(".", "")))


def default_font_family() -> str:
Expand Down

0 comments on commit d92de40

Please sign in to comment.