diff --git a/desktop_version/src/Font.cpp b/desktop_version/src/Font.cpp index 8a7ad421..b1f6a049 100644 --- a/desktop_version/src/Font.cpp +++ b/desktop_version/src/Font.cpp @@ -404,7 +404,7 @@ uint8_t get_font_idx_8x8(void) return font_idx_8x8; } -static void set_custom_font(const char* name) +void set_custom_font(const char* name) { /* Apply the choice for a certain level-specific font. */ diff --git a/desktop_version/src/Font.h b/desktop_version/src/Font.h index 66ecafc1..72072dd4 100644 --- a/desktop_version/src/Font.h +++ b/desktop_version/src/Font.h @@ -64,6 +64,7 @@ bool find_main_font_by_name(const char* name, uint8_t* idx); const char* get_main_font_name(uint8_t idx); uint8_t get_font_idx_8x8(void); +void set_custom_font(const char* name); void load_main(void); void load_custom(const char* name); void unload_custom(void); diff --git a/desktop_version/src/Game.cpp b/desktop_version/src/Game.cpp index 4df093b3..fca7b922 100644 --- a/desktop_version/src/Game.cpp +++ b/desktop_version/src/Game.cpp @@ -7185,6 +7185,9 @@ void Game::returntoeditor(void) ed.notedelay = 0; ed.roomnamehide = 0; + // Might've been changed in a script + font::set_custom_font(cl.level_font_name.c_str()); + DEFER_CALLBACK(resetbg); music.fadeout(); //If warpdir() is used during playtesting, we need to set it back after! diff --git a/desktop_version/src/Script.cpp b/desktop_version/src/Script.cpp index 22b47f4e..51ec3c89 100644 --- a/desktop_version/src/Script.cpp +++ b/desktop_version/src/Script.cpp @@ -2424,6 +2424,19 @@ void scriptclass::run(void) position--; } } + else if (words[0] == "setfont") + { +#ifndef NO_CUSTOM_LEVELS + if (words[1] == "") + { + font::set_custom_font(cl.level_font_name.c_str()); + } + else + { + font::set_custom_font(words[1].c_str()); + } +#endif + } position++; } @@ -3433,6 +3446,9 @@ bool scriptclass::loadcustom(const std::string& t) }else if(words[0] == "loadtext"){ if(customtextmode==1){ add("endtext"); customtextmode=0;} add(lines[i]); + }else if(words[0] == "setfont"){ + if(customtextmode==1){ add("endtext"); customtextmode=0;} + add(lines[i]); }else if(words[0] == "destroy"){ if(customtextmode==1){ add("endtext"); customtextmode=0;} add(lines[i]);