Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
Add fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
MusicOnline committed Jan 23, 2020
1 parent 2a13447 commit dda8698
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 10 deletions.
Binary file not shown.
Binary file added circumstantial-companions/assets/ttf/keifont.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 20 additions & 5 deletions circumstantial-companions/locales.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
{
"en_US": "English (United States)",
"en_GB": "English (United Kingdom)",
"ja_JP": "Japanese",
"zh_CN": "Chinese (Simplified)",
"zh_TW": "Chinese (Traditional)"
"en_US": {
"name": "English (United States)",
"font": "assets/ttf/kirsty_rg.ttf"
},
"en_GB": {
"name": "English (United Kingdom)",
"font": "assets/ttf/kirsty_rg.ttf"
},
"ja_JP": {
"name": "Japanese",
"font": "assets/ttf/keifont.ttf"
},
"zh_CN": {
"name": "Chinese (Simplified)",
"font": "assets/ttf/zcool_kuaile_rg.ttf"
},
"zh_TW": {
"name": "Chinese (Traditional)",
"font": "assets/ttf/han_wang_yan_kai.ttf"
}
}
39 changes: 34 additions & 5 deletions circumstantial-companions/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""
from kivy.app import App
from kivy.core.window import Window
from kivy.metrics import sp
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from kivy.uix.dropdown import DropDown
Expand Down Expand Up @@ -58,30 +59,58 @@ def build(self, locale=SYSTEM_LOCALE):
if locale in LOCALES:
TRANSLATIONS[locale].install()
else:
locale = DEFAULT_LOCALE
TRANSLATIONS[DEFAULT_LOCALE].install()

font = LOCALES[locale]["font"]

# Title
title = Label(
text=_("Options"),
font_name=font,
font_size=sp(40),
size_hint=(1, 0.1),
)

# Language selection
self.dropdown = DropDown()
for locale_code, locale_name in LOCALES.items():
btn = Button(text=locale_name, size_hint_y=None, height=20)
for locale_code, locale_info in LOCALES.items():
btn = Button(
text=locale_info["name"],
font_name=font,
size_hint_y=None,
height=20
)

def _make_select_function(locale_code):
return lambda btn: self.dropdown.select(locale_code)

btn.bind(on_release=_make_select_function(locale_code))
self.dropdown.add_widget(btn)
dropdown_btn = Button(text=_("Select language"), size_hint=(1, 0.1))
dropdown_btn = Button(
text=_("Select language"),
font_name=font,
font_size=sp(30),
size_hint=(1, 0.1),
)
dropdown_btn.bind(on_release=self.dropdown.open)
self.dropdown.bind(on_select=lambda instance, locale: self.build(locale))

reset_btn = Button(text=_("Reset"), size_hint=(1, 0.1))
# Reset
reset_btn = Button(
text=_("Reset"),
font_name=font,
font_size=sp(30),
size_hint=(1, 0.1),
)
reset_btn.bind(on_release=lambda btn: self.chisel.reset())

# Sliders
slider_layout = BoxLayout(orientation="horizontal", spacing=10, size_hint=(1, 0.7))
slider_layout.add_widget(ChiselRadiusSlider(self.chisel))
slider_layout.add_widget(ChiselPowerSlider(self.chisel))

self.add_widget(Label(text=_("Options"), size_hint=(1, 0.1)))
self.add_widget(title)
self.add_widget(dropdown_btn)
self.add_widget(reset_btn)
self.add_widget(slider_layout)
Expand Down

0 comments on commit dda8698

Please sign in to comment.