This commit is contained in:
Wengier
2021-01-31 02:14:52 -05:00
parent fe683249d4
commit 47ad5a1e3f
3 changed files with 27 additions and 16 deletions

View File

@@ -117,8 +117,8 @@ typedef struct Render_t {
#if defined(USE_TTF)
#include "SDL_ttf.h"
#define txtMaxCols 240
#define txtMaxLins 90
#define txtMaxCols 255
#define txtMaxLins 88
typedef struct {
bool inUse;
TTF_Font *SDL_font;

View File

@@ -3469,6 +3469,24 @@ void SetBlinkRate(Section_prop* section) {
else blinkCursor = IS_PC98_ARCH?6:4; // default cursor blinking is slower on PC-98 systems
}
int lastset=0;
void CheckTTFLimit() {
ttf.lins = MAX(24, MIN(IS_VGA_ARCH?txtMaxLins:60, ttf.lins));
ttf.cols = MAX(40, MIN(IS_VGA_ARCH?txtMaxCols:160, ttf.cols));
if (ttf.cols*ttf.lins>16384) {
if (lastset==1) {
ttf.lins=16384/ttf.cols;
SetVal("render", "ttf.lins", std::to_string(ttf.lins));
} else if (lastset==2) {
ttf.cols=16384/ttf.lins;
SetVal("render", "ttf.cols", std::to_string(ttf.cols));
} else {
ttf.lins = 25;
ttf.cols = 80;
}
}
}
bool firstset=true;
void OUTPUT_TTF_Select(int fsize=-1) {
if (!initttf&&TTF_Init()) { // Init SDL-TTF
@@ -3574,12 +3592,7 @@ void OUTPUT_TTF_Select(int fsize=-1) {
if ((!CurMode||CurMode->type!=M_TEXT)&&!IS_PC98_ARCH) {
if (ttf.cols<1) ttf.cols=80;
if (ttf.lins<1) ttf.lins=25;
ttf.lins = MAX(24, MIN(txtMaxLins, ttf.lins));
ttf.cols = MAX(40, MIN(txtMaxCols, ttf.cols));
if (ttf.cols*ttf.lins>16384) {
ttf.lins = 25;
ttf.cols = 80;
}
CheckTTFLimit();
} else if (firstset) {
bool alter_vmode=false;
uint16_t c=0, r=0;
@@ -3604,12 +3617,7 @@ void OUTPUT_TTF_Select(int fsize=-1) {
if (ttf.lins != r) alter_vmode = true;
}
} else {
ttf.lins = MAX(24, MIN(txtMaxLins, ttf.lins));
ttf.cols = MAX(40, MIN(txtMaxCols, ttf.cols));
if (ttf.cols*ttf.lins>16384) {
ttf.lins = 25;
ttf.cols = 80;
}
CheckTTFLimit();
if (ttf.cols != c || ttf.lins != r) alter_vmode = true;
}
if (alter_vmode) {

View File

@@ -46,7 +46,7 @@ typedef struct {
Bitu call_program;
extern const char *modifier;
extern int enablelfn, paste_speed, wheel_key, freesizecap, wpType, wpVersion;
extern int enablelfn, paste_speed, wheel_key, freesizecap, wpType, wpVersion, lastset;
extern bool dos_kernel_disabled, force_nocachedir, wpcolon, lockmount, enable_config_as_shell_commands, load, winrun, winautorun, startwait, startquiet, mountwarning, wheel_guest, clipboard_dosapi, noremark_save_state, force_load_state, sync_time, manualtime;
/* This registers a file on the virtual drive and creates the correct structure for it*/
@@ -1342,7 +1342,8 @@ void CONFIG::Run(void) {
#endif
} else if (!strcasecmp(inputline.substr(0, 9).c_str(), "ttf.lins=")||!strcasecmp(inputline.substr(0, 9).c_str(), "ttf.cols=")) {
#if defined(USE_TTF)
if (!strcasecmp(inputline.substr(0, 9).c_str(), "ttf.cols=")&&IS_PC98_ARCH)
bool iscol=!strcasecmp(inputline.substr(0, 9).c_str(), "ttf.cols=");
if (iscol&&IS_PC98_ARCH)
SetVal("render", "ttf.cols", "80");
else if (!CurMode)
;
@@ -1352,7 +1353,9 @@ void CONFIG::Run(void) {
reg_ax=(uint16_t)CurMode->mode;
CALLBACK_RunRealInt(0x10);
}
lastset=iscol?2:1;
ttf_setlines(0, 0);
lastset=0;
#endif
} else if (!strcasecmp(inputline.substr(0, 7).c_str(), "ttf.wp=")) {
#if defined(USE_TTF)