From 4c3fbda98b7c497ef63fc6247558afbf7bea4e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net> Date: Tue, 8 Apr 2025 13:57:21 -0400 Subject: [PATCH] Fix SDL/GDI issue with textmode() using alternate fonts Previously, SDL and GDI modes (but not X11 mode) would return early from textmode() if the new mode is the same as the old mode. This would result in the font not being reset to the defaults for the mode. This was most noticable when using RIP to change the font to one of a difference size since the mode remains the same, but the font and screen dimensions change. Should fix issue 201 --- src/conio/sdl_con.c | 15 +++------------ src/conio/win32gdi.c | 9 --------- src/syncterm/CHANGES | 1 + 3 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/conio/sdl_con.c b/src/conio/sdl_con.c index 9cb4a3b9cc..0690c917e2 100644 --- a/src/conio/sdl_con.c +++ b/src/conio/sdl_con.c @@ -370,19 +370,10 @@ sdl_get_bounds(int *w, int *h) return true; } -static int sdl_init_mode(int mode, bool init) +static int sdl_init_mode(int mode) { int w, h; - if (mode != CIOLIB_MODE_CUSTOM) { - assert_rwlock_rdlock(&vstatlock); - if (mode == vstat.mode && !init) { - assert_rwlock_unlock(&vstatlock); - return 0; - } - assert_rwlock_unlock(&vstatlock); - } - sdl_user_func(SDL_USEREVENT_FLUSH); assert_pthread_mutex_lock(&win_mutex); @@ -434,7 +425,7 @@ int sdl_init(int mode) _beginthread(sdl_video_event_thread, 0, NULL); #endif sdl_user_func_ret(SDL_USEREVENT_INIT); - sdl_init_mode(ciolib_initial_mode, true); + sdl_init_mode(ciolib_initial_mode); if(sdl_init_good) { cio_api.mode=fullscreen?CIOLIB_MODE_SDL_FULLSCREEN:CIOLIB_MODE_SDL; @@ -568,7 +559,7 @@ int sdl_getch(void) /* Called from main thread only */ void sdl_textmode(int mode) { - sdl_init_mode(mode, false); + sdl_init_mode(mode); } /* Called from main thread only (Passes Event) */ diff --git a/src/conio/win32gdi.c b/src/conio/win32gdi.c index 8affa76ad0..1427cb7459 100644 --- a/src/conio/win32gdi.c +++ b/src/conio/win32gdi.c @@ -1090,15 +1090,6 @@ gdi_textmode(int mode) { int mw, mh; - if (mode != CIOLIB_MODE_CUSTOM) { - assert_rwlock_rdlock(&vstatlock); - if (mode == vstat.mode) { - assert_rwlock_unlock(&vstatlock); - return; - } - assert_rwlock_unlock(&vstatlock); - } - assert_rwlock_wrlock(&vstatlock); get_monitor_size_pos(&mw, &mh, NULL, NULL); UnadjustWindowSize(&mw, &mh); diff --git a/src/syncterm/CHANGES b/src/syncterm/CHANGES index 1343c080a6..be9527d813 100644 --- a/src/syncterm/CHANGES +++ b/src/syncterm/CHANGES @@ -10,6 +10,7 @@ Pass control key combinations in BBC Micro mode Add support for DECSC/DECRC control codes Fix crash when first ANSI music note played is in background Fix binary mode tracking, which could cause issues after transfers +Fix SDL and GDI issue with textmode() when font is changed Version 1.6 ------------ -- GitLab