Skip to content

Commit

Permalink
Minor font related updates
Browse files Browse the repository at this point in the history
  • Loading branch information
imiolek-ireneusz committed May 14, 2021
1 parent d4050f2 commit c496e3d
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 18 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
Changelog:
eduActiv8 - 4.21.05:
- Added NotoSerifMalayalam font to be used alongside the Malayalam translation.
- Malayam translation unavaliable - so temporarily disabled in the program
eduActiv8 - 4.20.12:
- Arabic language added provisionally - recommends python-pyfribidi library, alternatively uses embedded
arabic_reshaper library
Expand Down
1 change: 1 addition & 0 deletions CREDITS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ Fonts:
FreeSans, FreeSansBold - GPL
LinBiolinum_RBah - LinuxLibertine - GPL - https://sourceforge.net/projects/linuxlibertine/
KacstOne - KACST holds the copyright of the included Arabic font which is donated under GPL by KACST.
NotoSerifMalayalam - OFL - https://scripts.sil.org/cms/scripts/page.php?item_id=OFL-FAQ_web#b2e49b82

Sounds Licence - Public Domain:
Most of the sounds were created with help of: http://www.superflashbros.net/as3sfxr/ these are being released under Public Domain licence:
Expand Down
15 changes: 15 additions & 0 deletions classes/board.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def set_font_color(self, color):
def update_font_size(self, font_size):
self.font = self.board.font_sizes[font_size]

def update_lng_font_size(self, key):
if key in self.board.font_sizes_lng:
self.font = self.board.font_sizes_lng[key]

def set_fraction_lines(self, top, bottom, color, length=90):
if top:
self.fraction_line_top = True
Expand Down Expand Up @@ -1008,6 +1012,7 @@ def __init__(self, mainloop, x_count=10, y_count=10, scale=8):
self.font_path_default2 = None
self.font_path_hand = None
self.font_path_print = None
self.font_sizes_lng = dict()

self.load_default_fonts()
self.level_start(x_count, y_count, scale)
Expand All @@ -1026,6 +1031,9 @@ def load_default_fonts(self):
self.font_path_print = os.path.join('res', 'fonts', 'eduactiv8Fonts', 'eduactiv8LatinPrint.ttf')

self.font_path_clock = os.path.join('res', 'fonts', 'eduactiv8Fonts', 'eduactiv8Clock.ttf')
self.font_ml = os.path.join('res', 'fonts', self.mainloop.config.font_dir_noto,
self.mainloop.config.font_ml)
self.font_def = os.path.join('res', 'fonts', 'LinLibertine', 'LinBiolinum_RB_merged_with_Kacst.ttf')

self.load_fonts()

Expand Down Expand Up @@ -1119,6 +1127,13 @@ def level_start(self, x_count, y_count, scale):
#font 36
self.font_sizes.append(pygame.font.Font(self.font_path_default, (int(self.points / 0.5))))

self.font_sizes_lng = dict()
self.font_sizes_lng["ml_1.75"] = pygame.font.Font(self.font_ml, (int(float(self.points) / 1.75)))
self.font_sizes_lng["ml_1.25"] = pygame.font.Font(self.font_ml, (int(float(self.points) / 1.25)))
self.font_sizes_lng["def_1.75"] = pygame.font.Font(self.font_def, (int(float(self.points) / 1.75)))
self.font_sizes_lng["def_1.25"] = pygame.font.Font(self.font_def, (int(float(self.points) / 1.25)))
self.font_sizes_lng["def_2.0"] = pygame.font.Font(self.font_def, (int(float(self.points) / 2.0)))

self.board_bg = BoardBg(self, 0, 0, x_count, y_count, "", (255, 255, 255))
self.unit_list.add(self.board_bg)
self.all_sprites_list.add(self.board_bg)
Expand Down
14 changes: 13 additions & 1 deletion classes/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def __init__(self, android):
if ex.fribidi_loaded or ex.ar_reshaper_loaded:
s = ex.unival('العربية')
self.arabic = ex.ar_rtl(s)
# Malayam: "മലയാളം" 22: "",
self.lang_titles = ["English", "American English", "Català", "Deutsch", "Español", "Français", "Italiano",
"Lakȟótiyapi", "Nederlands", "Polski", "Português", "Suomalainen", "Ελληνικά",
"Български", "Русский", "Српски", "Українська", "תירבע", self.arabic]
Expand Down Expand Up @@ -150,14 +151,14 @@ def __init__(self, android):

def set_font_family(self, variant=0):
self.font_variant = variant

if variant == 0:
self.font_dir = 'LinLibertine'
self.font_name_1 = 'LinBiolinum_RB_merged_with_Kacst.ttf'
self.font_name_2 = 'LinBiolinum_R_merged_with_Kacst.ttf'
self.font_multiplier = 1
self.font_line_height_adjustment = 1.5
self.font_start_at_adjustment = 5

elif variant == 1:
self.font_dir = 'FreeSans'
self.font_name_1 = 'FreeSansBold.ttf'
Expand All @@ -176,6 +177,17 @@ def set_font_family(self, variant=0):
self.font_line_height_adjustment = 1
self.font_start_at_adjustment = 0

elif variant == 3:
self.font_dir = 'Noto'
self.font_name_1 = 'NotoSerifMalayalam-BoldPlus.ttf'
self.font_name_2 = self.font_name_1 # 'NotoSerifMalayalam-BoldPlus.ttf'
#self.arabic = "Arabic"
self.font_multiplier = 1
self.font_line_height_adjustment = 1.5
self.font_start_at_adjustment = 5
self.font_dir_noto = "Noto"
self.font_ml = 'NotoSerifMalayalam-Regular.ttf'

"""
self.font_dir = 'LinLibertine'
self.font_name_1 = 'LinBiolinum_RBah.ttf'
Expand Down
18 changes: 12 additions & 6 deletions classes/dialogwnd.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,19 +121,25 @@ def __init__(self, mainloop):

self.font_size = 0

self.font_l = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 40)
self.font_s = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 20)
self.font_xs = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 20)
self.font_l = None
self.font_s = None
self.font_xs = None
self.reload_fonts()
self.default_font = None
#self.text = ""
#self.set_text(self.text, font=1)

self.wnd_close_function = None
self.load_images()

def reload_fonts(self):
self.font_l = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 40)
self.font_s = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 20)
self.font_xs = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_1), 20)

def load_images(self):
self.bg_tint_color = ex.hsv_to_rgb(self.mainloop.cl.color_sliders[5][0] * 16, 255, 100)
self.font_color = ex.hsv_to_rgb(self.mainloop.cl.color_sliders[5][0] * 16, 255, 100)
Expand Down
1 change: 1 addition & 0 deletions classes/info_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ def __init__(self, mainloop):
self.game_board = None
self.home_btns_w = 50 + 66
self.last_hover = None
self.fonts = []
self.create()

def create(self):
Expand Down
6 changes: 6 additions & 0 deletions classes/lang.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,11 @@ def get_lang_attr(self, login=False):
self.config.font_line_height_adjustment = 1
self.config.font_start_at_adjustment = 0

if self.lang == 'ml':
font_variant = 3
else:
font_variant = 0

if self.kbrd is None:
import i18n.custom.kbrd.en_gb
import i18n.custom.kbrd.en_course
Expand All @@ -257,6 +262,7 @@ def get_lang_attr(self, login=False):
self.solid_names = self.oi18n.solid_names
self.shape_names = self.oi18n.shape_names
self.letter_names = self.lang_file.letter_names
self.font_variant = font_variant
self.config.set_font_family(font_variant)
if not self.ltr_text:
for each_d in [self.d, self.b]:
Expand Down
12 changes: 10 additions & 2 deletions classes/score_bar.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,20 +161,28 @@ def __init__(self, mainloop):
self.update_me = True
self.widget_list = None
self.mouse_over = False
self.font = None
self.font_bold = None

self.points = int(round((50 * 72 / 96) / 4, 0))
if self.mainloop.android is None:
points_multiplicator = 2.0
self.btn_h = 28
self.link_lbl_h = 32
self.btn_spacing = 3
self.img_ext = ".png"
else:
points_multiplicator = 3.0
self.btn_h = 48
self.link_lbl_h = 48
self.btn_spacing = 5
self.img_ext = "_l.png"

self.update_fonts()

def update_fonts(self):
if self.mainloop.android is None:
points_multiplicator = 2.0
else:
points_multiplicator = 3.0
self.font = pygame.font.Font(
os.path.join('res', 'fonts', self.mainloop.config.font_dir, self.mainloop.config.font_name_2),
(int(self.points * points_multiplicator)))
Expand Down
1 change: 1 addition & 0 deletions game_boards/game000.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def create_game_objects(self, level=1):
["www.eduactiv8.org | info%seduactiv8%sorg" % ("@", "."),
"Copyright (C) 2012 - 2020 Ireneusz Imiolek"], color, "", 3)
self.board.units[-1].font_color = font_color2
self.board.units[-1].update_lng_font_size("def_2.0")

# add main category items
posx =[data[0] // 2 - 8, data[0] // 2 - 2, data[0] // 2 + 4]
Expand Down
20 changes: 16 additions & 4 deletions game_boards/game003.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ def create_game_objects(self, level=1):
self.board.add_unit(c + 4, t, 2, 1, classes.board.Label, self.lang.lang_progress[i], white, "", 3)
self.board.units[-1].font_color = (200, 200, 200)
self.board.add_unit(c - 4, t, 8, 1, classes.board.Letter, self.lang_titles[i], white, "", 2)

self.board.units[-1].update_lng_font_size("def_2.0")
if self.all_lng[i] == lang:
lng_index = i

self.board.add_unit(0, data[1]-1, data[0], 1, classes.board.Label, "https://www.transifex.com/eduactiv8/eduactiv8/", white, "", 4)
self.board.add_unit(0, data[1]-1, data[0], 1, classes.board.Label, "https://www.transifex.com/eduactiv8/eduactiv8/", white, "", 3)
self.board.units[-1].font_color = (150, 150, 150)
self.board.units[-1].update_lng_font_size("def_2.0")


for each in self.board.ships:
each.immobilize()
Expand Down Expand Up @@ -103,6 +105,8 @@ def change_language(self, lng, lng_title, lang_id):
sv = lng_title
self.say(sv)
self.mainloop.info.update_fonts()
self.mainloop.sb.update_fonts()
self.mainloop.dialog.reload_fonts()
self.reselect(lang_id)
self.mainloop.sb.resize()
self.mainloop.sb.update_me = True
Expand All @@ -115,11 +119,19 @@ def reselect(self, selectid):
for each in self.board.ships:
if each.unit_id != selectid:
each.font_color = (40, 40, 40)
each.font = self.board.font_sizes[2]
each.update_lng_font_size("def_1.75")
else:
each.font_color = ex.hsv_to_rgb(self.mainloop.cl.color_sliders[5][0] * 16, 255, 200)
each.font = self.board.font_sizes[0]
each.update_lng_font_size("def_1.25")
each.update_me = True
"""
# Malayam language - font selector - temporarily disabled
if selectid == self.board.ships[-2].unit_id:
self.board.ships[-2].update_lng_font_size("ml_1.25")
else:
self.board.ships[-2].update_lng_font_size("ml_1.75")
"""


def update(self, game):
game.fill((255, 255, 255))
Expand Down
1 change: 1 addition & 0 deletions game_boards/game014.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def create_game_objects(self, level=1):
img_src='nav_l_mts.png', alpha=True)
self.board.ships[-1].set_tint_color(bd_color2)


self.board.add_unit(data[1] + 2, 5, 2, 2, classes.board.Label, str(num2), white, "", 31)
self.nm2 = self.board.units[-1]
self.board.units[-1].font_color = bd_color2
Expand Down
10 changes: 7 additions & 3 deletions game_boards/game049.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@ def create_game_objects(self, level=1):
self.mainloop.info.hide_buttonsa(self.vis_buttons)
v = 255
h = random.randrange(0, 255)
color0 = ex.hsv_to_rgb(h, 40, 230) # highlight 1

bg_colour = (255, 255, 255)
if self.mainloop.scheme is not None:
if self.mainloop.scheme.dark:
bg_colour = (0, 0, 0)

lvl_data = self.mainloop.xml_conn.get_level_data(self.mainloop.m.game_dbid,
self.mainloop.config.user_age_group,
Expand Down Expand Up @@ -209,9 +213,9 @@ def create_game_objects(self, level=1):
x = data[0] - 1
else:
x = 0
self.board.add_unit(x, data[1] - 1, 1, 1, classes.board.Label, "", color0, "", 0)
self.board.add_unit(x, data[1] - 1, 1, 1, classes.board.Label, "", bg_colour, "", 0)

self.outline_all(0, 1)
#self.outline_all(0, 1)

def show_info_dialog(self):
self.mainloop.dialog.show_dialog(3, self.d["Complete abc"])
Expand Down
4 changes: 2 additions & 2 deletions i18n/custom/ar.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,6 @@ def time2str(h, m):

def fract2str(n, d):
if n == 1:
return numerators[0] + " " + d_singular[d-1]
return r(numerators[0] + " " + d_singular[d-1])
else:
return numerators[n-1] + " " + d_plural[d-1]
return r(numerators[n-1] + " " + d_plural[d-1])
15 changes: 15 additions & 0 deletions xml/langs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,4 +253,19 @@
ico_suffix="ru"
ltr="True"
/>
<!--
<lang id="22"
code="ml"
name="മലയാളം"
name_en="Malayalam"
voice="None"
voice_mb="None"
use_mb="False"
has_uc="False"
has_cursive="False"
has_keyboard="False"
ico_suffix=""
ltr="True"
/>
-->
</languages>

0 comments on commit c496e3d

Please sign in to comment.