Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/retro-go/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,10 @@
#ifndef RG_FONT_DEFAULT
#define RG_FONT_DEFAULT RG_FONT_VERA_11
#endif

#ifndef RG_FONT_CHINESE
#define RG_FONT_CHINESE RG_FONT_FUSIONPIXEL_12
#endif

// Will be moved elsewhere, this is for testing
#define RG_CHINESE_SUPPORT 1
11,871 changes: 11,871 additions & 0 deletions components/retro-go/fonts/FusionPixel12.c

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions components/retro-go/fonts/fonts.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ extern const rg_font_t font_DejaVu12;
extern const rg_font_t font_DejaVu15;
extern const rg_font_t font_VeraBold11;
extern const rg_font_t font_VeraBold14;
extern const rg_font_t font_FusionPixel;

enum {
RG_FONT_BASIC_8,
Expand All @@ -19,6 +20,9 @@ enum {
RG_FONT_DEJAVU_15,
RG_FONT_VERA_11,
RG_FONT_VERA_14,
#if RG_CHINESE_SUPPORT
RG_FONT_FUSIONPIXEL_12,
#endif
RG_FONT_MAX,
};

Expand All @@ -30,4 +34,7 @@ static const rg_font_t *fonts[RG_FONT_MAX] = {
&font_DejaVu15,
&font_VeraBold11,
&font_VeraBold14,
#if RG_CHINESE_SUPPORT
&font_FusionPixel,
#endif
};
18 changes: 18 additions & 0 deletions components/retro-go/rg_gui.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,15 @@ void rg_gui_init(void)

bool rg_gui_set_language_id(int index)
{
if (index == RG_LANG_CHS)
{
#if RG_CHINESE_SUPPORT
rg_gui_set_font(RG_FONT_CHINESE);
#else
RG_LOGE("Chinese font not included, impossible to switch to Chinese!");
return false;
#endif
}
if (rg_localization_set_language_id(index))
{
rg_settings_set_number(NS_GLOBAL, SETTING_LANGUAGE, index);
Expand Down Expand Up @@ -222,6 +231,14 @@ bool rg_gui_set_font(int index)
if (index < 0 || index > RG_FONT_MAX - 1)
return false;

#if RG_CHINESE_SUPPORT
if (rg_localization_get_language_id() == RG_LANG_CHS && index != RG_FONT_CHINESE)
{
RG_LOGW("When the language is set to Chinese, only the Chinese font can be used!");
index = RG_FONT_CHINESE;
}
#endif

gui.font = fonts[index];
gui.font_index = index;
gui.font_height = (index < 3) ? (8 + index * 4) : gui.font->height;
Expand Down Expand Up @@ -1678,6 +1695,7 @@ static rg_gui_event_t language_cb(rg_gui_option_t *option, rg_gui_event_t event)

if (event == RG_DIALOG_ENTER)
{
// FIXME: Hide languages that can't be displayed because of a missing font (eg Chinese)
rg_gui_option_t options[RG_LANG_MAX + 1];
for (int i = 0; i < RG_LANG_MAX; i++)
options[i] = (rg_gui_option_t){i, rg_localization_get_language_name(i), NULL, RG_DIALOG_FLAG_NORMAL, NULL};
Expand Down
1 change: 1 addition & 0 deletions components/retro-go/rg_localization.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ typedef enum
RG_LANG_EN = 0,
RG_LANG_FR,
RG_LANG_DE,
RG_LANG_CHS,
//RG_LANG_ES,

RG_LANG_MAX
Expand Down
Loading