diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 19:32:38 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-07-27 19:44:09 +0200 |
commit | 35bde798b6cda13579337b0ec5a803fdd5eab19a (patch) | |
tree | f0cc63dfb2b64aafbd6477b4d239899b8c9dba3c /helpers/__init__.py | |
parent | cfde9820184a3b70c70bcf396c396a4c64fa9a39 (diff) | |
download | MusicSampler-35bde798b6cda13579337b0ec5a803fdd5eab19a.tar.gz MusicSampler-35bde798b6cda13579337b0ec5a803fdd5eab19a.tar.zst MusicSampler-35bde798b6cda13579337b0ec5a803fdd5eab19a.zip |
Remove fonts from directory
Diffstat (limited to 'helpers/__init__.py')
-rw-r--r-- | helpers/__init__.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py index f1a968b..4827e6c 100644 --- a/helpers/__init__.py +++ b/helpers/__init__.py | |||
@@ -6,9 +6,43 @@ import math | |||
6 | import sounddevice as sd | 6 | import sounddevice as sd |
7 | import logging | 7 | import logging |
8 | 8 | ||
9 | from . import sysfont | ||
10 | |||
9 | class Config: | 11 | class Config: |
10 | pass | 12 | pass |
11 | 13 | ||
14 | def find_font(name, style=sysfont.STYLE_NONE): | ||
15 | if getattr(sys, 'frozen', False): | ||
16 | font = sys._MEIPASS + "/fonts/{}_{}.ttf".format(name, style) | ||
17 | else: | ||
18 | font = sysfont.get_font(name, style=style) | ||
19 | if font is not None: | ||
20 | font = font[4] | ||
21 | return font | ||
22 | |||
23 | def register_fonts(): | ||
24 | from kivy.core.text import LabelBase | ||
25 | |||
26 | ubuntu_regular = find_font("Ubuntu", style=sysfont.STYLE_NORMAL) | ||
27 | ubuntu_bold = find_font("Ubuntu", style=sysfont.STYLE_BOLD) | ||
28 | symbola = find_font("Symbola") | ||
29 | |||
30 | if ubuntu_regular is None: | ||
31 | error_print("Font Ubuntu regular could not be found, please install it.") | ||
32 | sys.exit() | ||
33 | if symbola is None: | ||
34 | error_print("Font Symbola could not be found, please install it.") | ||
35 | sys.exit() | ||
36 | if ubuntu_bold is None: | ||
37 | warn_print("Font Ubuntu Bold could not be found.") | ||
38 | |||
39 | LabelBase.register(name="Ubuntu", | ||
40 | fn_regular=ubuntu_regular, | ||
41 | fn_bold=ubuntu_bold) | ||
42 | LabelBase.register(name="Symbola", | ||
43 | fn_regular=symbola) | ||
44 | |||
45 | |||
12 | def path(): | 46 | def path(): |
13 | if getattr(sys, 'frozen', False): | 47 | if getattr(sys, 'frozen', False): |
14 | return sys._MEIPASS + "/" | 48 | return sys._MEIPASS + "/" |