aboutsummaryrefslogtreecommitdiff
path: root/helpers
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-20 23:38:10 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2016-06-20 23:38:10 +0200
commit956ce6fd3e47b2536f57f3359ebff26850f30aea (patch)
treef1dbabd3d625bbbc638d7ac5e9a77b4061bff9b8 /helpers
parent9de92b6dd2bd906f6a64fce7c90a6aff0dbb27a2 (diff)
downloadMusicSampler-956ce6fd3e47b2536f57f3359ebff26850f30aea.tar.gz
MusicSampler-956ce6fd3e47b2536f57f3359ebff26850f30aea.tar.zst
MusicSampler-956ce6fd3e47b2536f57f3359ebff26850f30aea.zip
Cleanup fonts
Diffstat (limited to 'helpers')
-rw-r--r--helpers/__init__.py1
-rw-r--r--helpers/font.py10
-rw-r--r--helpers/key.py15
3 files changed, 15 insertions, 11 deletions
diff --git a/helpers/__init__.py b/helpers/__init__.py
index b3ab1eb..0e29f5d 100644
--- a/helpers/__init__.py
+++ b/helpers/__init__.py
@@ -2,6 +2,7 @@
2from .music_file import * 2from .music_file import *
3from .mapping import * 3from .mapping import *
4from .lock import * 4from .lock import *
5from .font import *
5import yaml 6import yaml
6 7
7def parse_config(mapping): 8def parse_config(mapping):
diff --git a/helpers/font.py b/helpers/font.py
new file mode 100644
index 0000000..83999ef
--- /dev/null
+++ b/helpers/font.py
@@ -0,0 +1,10 @@
1import os
2import pygame
3import sys
4
5def font(size, font = "Ubuntu-Regular"):
6 if getattr(sys, 'frozen', False):
7 return pygame.font.Font(sys._MEIPASS + "/fonts/" + font + ".ttf", size)
8 else:
9 path = os.path.dirname(os.path.realpath(__file__))
10 return pygame.font.Font(path + "/../fonts/" + font + ".ttf", size)
diff --git a/helpers/key.py b/helpers/key.py
index 57fdef1..e643dc2 100644
--- a/helpers/key.py
+++ b/helpers/key.py
@@ -1,5 +1,6 @@
1from .rounded_rect import * 1from .rounded_rect import *
2from .action import * 2from .action import *
3from .font import font
3import time 4import time
4import sys 5import sys
5import pygame 6import pygame
@@ -19,7 +20,6 @@ class Key:
19 default_inner_color = (255, 255, 255) 20 default_inner_color = (255, 255, 255)
20 mapped_inner_color = ( 0, 255, 0) 21 mapped_inner_color = ( 0, 255, 0)
21 mapped_unready_inner_color = ( 0, 255, 0, 100) 22 mapped_unready_inner_color = ( 0, 255, 0, 100)
22 #mapped_unready_inner_color = (255, 165, 0)
23 23
24 def __init__(self, mapping, draw_lock, key_name, key_sym, top, left, width = 48, height = 48, disabled = False): 24 def __init__(self, mapping, draw_lock, key_name, key_sym, top, left, width = 48, height = 48, disabled = False):
25 self.draw_lock = draw_lock 25 self.draw_lock = draw_lock
@@ -89,12 +89,8 @@ class Key:
89 89
90 self.surface = self.square(all_actions_ready).surface() 90 self.surface = self.square(all_actions_ready).surface()
91 91
92 if getattr(sys, 'frozen', False): 92 police = font(14)
93 police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14) 93 text_police = font(10)
94 text_police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 10)
95 else:
96 police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
97 text_police = pygame.font.Font("Ubuntu-Regular.ttf", 10)
98 94
99 police.set_bold(True) 95 police.set_bold(True)
100 text = police.render(self.key_sym, True, (0,0,0)) 96 text = police.render(self.key_sym, True, (0,0,0))
@@ -151,10 +147,7 @@ class Key:
151 self.draw_lock.acquire() 147 self.draw_lock.acquire()
152 surface = pygame.Surface((690, 250)).convert() 148 surface = pygame.Surface((690, 250)).convert()
153 surface.fill((250, 250, 250)) 149 surface.fill((250, 250, 250))
154 if getattr(sys, 'frozen', False): 150 police = font(14)
155 police = pygame.font.Font(sys._MEIPASS + "/Ubuntu-Regular.ttf", 14)
156 else:
157 police = pygame.font.Font("Ubuntu-Regular.ttf", 14)
158 151
159 offset = 0 152 offset = 0
160 police.set_bold(True) 153 police.set_bold(True)