Initializing variables, font size change.

This commit is contained in:
Electric Keet 2023-08-02 22:59:45 -07:00
parent ebf8ebf7c0
commit 06d3e8a4b3
3 changed files with 14 additions and 9 deletions

View File

@ -3869,6 +3869,7 @@ bool FurnaceGUI::loop() {
mainFont=ImGui::GetIO().Fonts->AddFontDefault(); mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont; patFont=mainFont;
bigFont=mainFont; bigFont=mainFont;
headFont=mainFont;
if (rend) rend->destroyFontsTexture(); if (rend) rend->destroyFontsTexture();
if (!ImGui::GetIO().Fonts->Build()) { if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!"); logE("error again while building font atlas!");
@ -6025,6 +6026,7 @@ bool FurnaceGUI::loop() {
mainFont=ImGui::GetIO().Fonts->AddFontDefault(); mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont; patFont=mainFont;
bigFont=mainFont; bigFont=mainFont;
headFont=mainFont;
if (rend) rend->destroyFontsTexture(); if (rend) rend->destroyFontsTexture();
if (!ImGui::GetIO().Fonts->Build()) { if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!"); logE("error again while building font atlas!");
@ -6480,6 +6482,7 @@ bool FurnaceGUI::init() {
mainFont=ImGui::GetIO().Fonts->AddFontDefault(); mainFont=ImGui::GetIO().Fonts->AddFontDefault();
patFont=mainFont; patFont=mainFont;
bigFont=mainFont; bigFont=mainFont;
headFont=headFont;
if (rend) rend->destroyFontsTexture(); if (rend) rend->destroyFontsTexture();
if (!ImGui::GetIO().Fonts->Build()) { if (!ImGui::GetIO().Fonts->Build()) {
logE("error again while building font atlas!"); logE("error again while building font atlas!");
@ -6826,6 +6829,7 @@ FurnaceGUI::FurnaceGUI():
iconFont(NULL), iconFont(NULL),
patFont(NULL), patFont(NULL),
bigFont(NULL), bigFont(NULL),
headFont(NULL),
fontRange(NULL), fontRange(NULL),
prevInsData(NULL), prevInsData(NULL),
curIns(0), curIns(0),

View File

@ -1389,7 +1389,7 @@ class FurnaceGUI {
char emptyLabel2[32]; char emptyLabel2[32];
struct Settings { struct Settings {
int mainFontSize, headFontSize, patFontSize, iconSize; int mainFontSize, patFontSize, headFontSize, iconSize;
int audioEngine; int audioEngine;
int audioQuality; int audioQuality;
int audioChans; int audioChans;
@ -1548,6 +1548,7 @@ class FurnaceGUI {
Settings(): Settings():
mainFontSize(18), mainFontSize(18),
patFontSize(18), patFontSize(18),
headFontSize(27),
iconSize(16), iconSize(16),
audioEngine(DIV_AUDIO_SDL), audioEngine(DIV_AUDIO_SDL),
audioQuality(0), audioQuality(0),

View File

@ -2736,7 +2736,7 @@ void FurnaceGUI::drawSettings() {
void FurnaceGUI::syncSettings() { void FurnaceGUI::syncSettings() {
settings.mainFontSize=e->getConfInt("mainFontSize",18); settings.mainFontSize=e->getConfInt("mainFontSize",18);
settings.headFontSize=e->getConfInt("headFontSize",36); settings.headFontSize=e->getConfInt("headFontSize",27);
settings.patFontSize=e->getConfInt("patFontSize",18); settings.patFontSize=e->getConfInt("patFontSize",18);
settings.iconSize=e->getConfInt("iconSize",16); settings.iconSize=e->getConfInt("iconSize",16);
settings.audioEngine=(e->getConfString("audioEngine","SDL")=="SDL")?1:0; settings.audioEngine=(e->getConfString("audioEngine","SDL")=="SDL")?1:0;
@ -4064,21 +4064,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
headFont=mainFont; headFont=mainFont;
} else { } else {
if (settings.headFont==6) { // custom font if (settings.headFont==6) { // custom font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
logW("could not load header font! reverting to default font"); logW("could not load header font! reverting to default font");
settings.headFont=0; settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans."); logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault(); headFont=ImGui::GetIO().Fonts->AddFontDefault();
} }
} }
} else if (settings.headFont==5) { // system font } else if (settings.headFont==5) { // system font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
logW("could not load header font! reverting to default font"); logW("could not load header font! reverting to default font");
settings.headFont=0; settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans."); logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault(); headFont=ImGui::GetIO().Fonts->AddFontDefault();
} }
@ -4086,7 +4086,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
} }
} }
} else { } else {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",36)*dpiScale),NULL,upTo800))==NULL) { if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.headFont],builtinFontMLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
logE("could not load header font!"); logE("could not load header font!");
headFont=ImGui::GetIO().Fonts->AddFontDefault(); headFont=ImGui::GetIO().Fonts->AddFontDefault();
} }