Big font configuration options!

This commit is contained in:
Electric Keet 2023-08-02 13:48:07 -07:00
parent 537f90c3f1
commit 0f4f1a1cf5
3 changed files with 104 additions and 1 deletions

View file

@ -1835,6 +1835,16 @@ void FurnaceGUI::openFileDialog(FurnaceGUIFileDialogs type) {
dpiScale dpiScale
); );
break; break;
case GUI_FILE_LOAD_BIG_FONT:
if (!dirExists(workingDirFont)) workingDirFont=getHomeDir();
hasOpened=fileDialog->openLoad(
"Select Font",
{"compatible files", "*.ttf *.otf *.ttc"},
"compatible files{.ttf,.otf,.ttc}",
workingDirFont,
dpiScale
);
break;
case GUI_FILE_LOAD_PAT_FONT: case GUI_FILE_LOAD_PAT_FONT:
if (!dirExists(workingDirFont)) workingDirFont=getHomeDir(); if (!dirExists(workingDirFont)) workingDirFont=getHomeDir();
hasOpened=fileDialog->openLoad( hasOpened=fileDialog->openLoad(
@ -4622,6 +4632,7 @@ bool FurnaceGUI::loop() {
workingDirROMExport=fileDialog->getPath()+DIR_SEPARATOR_STR; workingDirROMExport=fileDialog->getPath()+DIR_SEPARATOR_STR;
break; break;
case GUI_FILE_LOAD_MAIN_FONT: case GUI_FILE_LOAD_MAIN_FONT:
case GUI_FILE_LOAD_BIG_FONT:
case GUI_FILE_LOAD_PAT_FONT: case GUI_FILE_LOAD_PAT_FONT:
workingDirFont=fileDialog->getPath()+DIR_SEPARATOR_STR; workingDirFont=fileDialog->getPath()+DIR_SEPARATOR_STR;
break; break;
@ -5083,6 +5094,9 @@ bool FurnaceGUI::loop() {
case GUI_FILE_LOAD_MAIN_FONT: case GUI_FILE_LOAD_MAIN_FONT:
settings.mainFontPath=copyOfName; settings.mainFontPath=copyOfName;
break; break;
case GUI_FILE_LOAD_BIG_FONT:
settings.bigFontPath=copyOfName;
break;
case GUI_FILE_LOAD_PAT_FONT: case GUI_FILE_LOAD_PAT_FONT:
settings.patFontPath=copyOfName; settings.patFontPath=copyOfName;
break; break;

View file

@ -423,6 +423,7 @@ enum FurnaceGUIFileDialogs {
GUI_FILE_EXPORT_CMDSTREAM_BINARY, GUI_FILE_EXPORT_CMDSTREAM_BINARY,
GUI_FILE_EXPORT_ROM, GUI_FILE_EXPORT_ROM,
GUI_FILE_LOAD_MAIN_FONT, GUI_FILE_LOAD_MAIN_FONT,
GUI_FILE_LOAD_BIG_FONT,
GUI_FILE_LOAD_PAT_FONT, GUI_FILE_LOAD_PAT_FONT,
GUI_FILE_IMPORT_COLORS, GUI_FILE_IMPORT_COLORS,
GUI_FILE_IMPORT_KEYBINDS, GUI_FILE_IMPORT_KEYBINDS,
@ -1387,7 +1388,7 @@ class FurnaceGUI {
char emptyLabel2[32]; char emptyLabel2[32];
struct Settings { struct Settings {
int mainFontSize, patFontSize, iconSize; int mainFontSize, bigFontSize, patFontSize, iconSize;
int audioEngine; int audioEngine;
int audioQuality; int audioQuality;
int audioChans; int audioChans;
@ -1404,6 +1405,7 @@ class FurnaceGUI {
String tg100Path; String tg100Path;
String mu5Path; String mu5Path;
int mainFont; int mainFont;
int bigFont;
int patFont; int patFont;
int audioRate; int audioRate;
int audioBufSize; int audioBufSize;
@ -1526,6 +1528,7 @@ class FurnaceGUI {
int noDMFCompat; int noDMFCompat;
unsigned int maxUndoSteps; unsigned int maxUndoSteps;
String mainFontPath; String mainFontPath;
String bigFontPath;
String patFontPath; String patFontPath;
String audioDevice; String audioDevice;
String midiInDevice; String midiInDevice;
@ -1681,6 +1684,7 @@ class FurnaceGUI {
noDMFCompat(0), noDMFCompat(0),
maxUndoSteps(100), maxUndoSteps(100),
mainFontPath(""), mainFontPath(""),
bigFontPath(""),
patFontPath(""), patFontPath(""),
audioDevice(""), audioDevice(""),
midiInDevice(""), midiInDevice(""),

View file

@ -58,6 +58,16 @@ const char* mainFonts[]={
"<Custom...>" "<Custom...>"
}; };
const char* bigFonts[]={
"IBM Plex Sans",
"Liberation Sans",
"Exo",
"Proggy Clean",
"GNU Unifont",
"<Use system font>",
"<Custom...>"
};
const char* patFonts[]={ const char* patFonts[]={
"IBM Plex Mono", "IBM Plex Mono",
"Mononoki", "Mononoki",
@ -1857,6 +1867,20 @@ void FurnaceGUI::drawSettings() {
if (settings.mainFontSize<3) settings.mainFontSize=3; if (settings.mainFontSize<3) settings.mainFontSize=3;
if (settings.mainFontSize>96) settings.mainFontSize=96; if (settings.mainFontSize>96) settings.mainFontSize=96;
} }
ImGui::Text("Big font");
ImGui::SameLine();
ImGui::Combo("##BigFont",&settings.bigFont,bigFonts,7);
if (settings.bigFont==6) {
ImGui::InputText("##BigFontPath",&settings.bigFontPath);
ImGui::SameLine();
if (ImGui::Button(ICON_FA_FOLDER "##BigFontLoad")) {
openFileDialog(GUI_FILE_LOAD_BIG_FONT);
}
}
if (ImGui::InputInt("Size##BigFontSize",&settings.bigFontSize)) {
if (settings.bigFontSize<3) settings.bigFontSize=3;
if (settings.bigFontSize>96) settings.bigFontSize=96;
}
ImGui::Text("Pattern font"); ImGui::Text("Pattern font");
ImGui::SameLine(); ImGui::SameLine();
ImGui::Combo("##PatFont",&settings.patFont,patFonts,7); ImGui::Combo("##PatFont",&settings.patFont,patFonts,7);
@ -2712,6 +2736,7 @@ void FurnaceGUI::drawSettings() {
void FurnaceGUI::syncSettings() { void FurnaceGUI::syncSettings() {
settings.mainFontSize=e->getConfInt("mainFontSize",18); settings.mainFontSize=e->getConfInt("mainFontSize",18);
settings.bigFontSize=e->getConfInt("bigFontSize",36);
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;
@ -2739,6 +2764,7 @@ void FurnaceGUI::syncSettings() {
settings.mainFont=e->getConfInt("mainFont",0); settings.mainFont=e->getConfInt("mainFont",0);
settings.patFont=e->getConfInt("patFont",0); settings.patFont=e->getConfInt("patFont",0);
settings.mainFontPath=e->getConfString("mainFontPath",""); settings.mainFontPath=e->getConfString("mainFontPath","");
settings.bigFontPath=e->getConfString("bigFontPath","");
settings.patFontPath=e->getConfString("patFontPath",""); settings.patFontPath=e->getConfString("patFontPath","");
settings.patRowsBase=e->getConfInt("patRowsBase",0); settings.patRowsBase=e->getConfInt("patRowsBase",0);
settings.orderRowsBase=e->getConfInt("orderRowsBase",1); settings.orderRowsBase=e->getConfInt("orderRowsBase",1);
@ -2866,6 +2892,7 @@ void FurnaceGUI::syncSettings() {
settings.noDMFCompat=e->getConfInt("noDMFCompat",0); settings.noDMFCompat=e->getConfInt("noDMFCompat",0);
clampSetting(settings.mainFontSize,2,96); clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.bigFontSize,2,96);
clampSetting(settings.patFontSize,2,96); clampSetting(settings.patFontSize,2,96);
clampSetting(settings.iconSize,2,48); clampSetting(settings.iconSize,2,48);
clampSetting(settings.audioEngine,0,1); clampSetting(settings.audioEngine,0,1);
@ -3067,6 +3094,7 @@ void FurnaceGUI::commitSettings() {
); );
e->setConf("mainFontSize",settings.mainFontSize); e->setConf("mainFontSize",settings.mainFontSize);
e->setConf("bigFontSize",settings.bigFontSize);
e->setConf("patFontSize",settings.patFontSize); e->setConf("patFontSize",settings.patFontSize);
e->setConf("iconSize",settings.iconSize); e->setConf("iconSize",settings.iconSize);
e->setConf("audioEngine",String(audioBackends[settings.audioEngine])); e->setConf("audioEngine",String(audioBackends[settings.audioEngine]));
@ -3092,8 +3120,10 @@ void FurnaceGUI::commitSettings() {
e->setConf("tg100Path",settings.tg100Path); e->setConf("tg100Path",settings.tg100Path);
e->setConf("mu5Path",settings.mu5Path); e->setConf("mu5Path",settings.mu5Path);
e->setConf("mainFont",settings.mainFont); e->setConf("mainFont",settings.mainFont);
e->setConf("bigFont",settings.mainFont);
e->setConf("patFont",settings.patFont); e->setConf("patFont",settings.patFont);
e->setConf("mainFontPath",settings.mainFontPath); e->setConf("mainFontPath",settings.mainFontPath);
e->setConf("bigFontPath",settings.bigFontPath);
e->setConf("patFontPath",settings.patFontPath); e->setConf("patFontPath",settings.patFontPath);
e->setConf("patRowsBase",settings.patRowsBase); e->setConf("patRowsBase",settings.patRowsBase);
e->setConf("orderRowsBase",settings.orderRowsBase); e->setConf("orderRowsBase",settings.orderRowsBase);
@ -3650,6 +3680,11 @@ void FurnaceGUI::popWarningColor() {
// TODO! // TODO!
#define SYSTEM_FONT_PATH_3 "C:\\Windows\\Fonts\\tahoma.ttf" #define SYSTEM_FONT_PATH_3 "C:\\Windows\\Fonts\\tahoma.ttf"
// TODO! // TODO!
#define SYSTEM_BIG_FONT_PATH_1 "C:\\Windows\\Fonts\\segoeui.ttf"
#define SYSTEM_BIG_FONT_PATH_2 "C:\\Windows\\Fonts\\tahoma.ttf"
// TODO!
#define SYSTEM_BIG_FONT_PATH_3 "C:\\Windows\\Fonts\\tahoma.ttf"
// TODO!
#define SYSTEM_PAT_FONT_PATH_1 "C:\\Windows\\Fonts\\consola.ttf" #define SYSTEM_PAT_FONT_PATH_1 "C:\\Windows\\Fonts\\consola.ttf"
#define SYSTEM_PAT_FONT_PATH_2 "C:\\Windows\\Fonts\\cour.ttf" #define SYSTEM_PAT_FONT_PATH_2 "C:\\Windows\\Fonts\\cour.ttf"
// GOOD LUCK WITH THIS ONE - UNTESTED // GOOD LUCK WITH THIS ONE - UNTESTED
@ -3658,6 +3693,9 @@ void FurnaceGUI::popWarningColor() {
#define SYSTEM_FONT_PATH_1 "/System/Library/Fonts/SFAANS.ttf" #define SYSTEM_FONT_PATH_1 "/System/Library/Fonts/SFAANS.ttf"
#define SYSTEM_FONT_PATH_2 "/System/Library/Fonts/Helvetica.ttc" #define SYSTEM_FONT_PATH_2 "/System/Library/Fonts/Helvetica.ttc"
#define SYSTEM_FONT_PATH_3 "/System/Library/Fonts/Helvetica.dfont" #define SYSTEM_FONT_PATH_3 "/System/Library/Fonts/Helvetica.dfont"
#define SYSTEM_BIG_FONT_PATH_1 "/System/Library/Fonts/SFAANS.ttf"
#define SYSTEM_BIG_FONT_PATH_2 "/System/Library/Fonts/Helvetica.ttc"
#define SYSTEM_BIG_FONT_PATH_3 "/System/Library/Fonts/Helvetica.dfont"
#define SYSTEM_PAT_FONT_PATH_1 "/System/Library/Fonts/SFNSMono.ttf" #define SYSTEM_PAT_FONT_PATH_1 "/System/Library/Fonts/SFNSMono.ttf"
#define SYSTEM_PAT_FONT_PATH_2 "/System/Library/Fonts/Courier New.ttf" #define SYSTEM_PAT_FONT_PATH_2 "/System/Library/Fonts/Courier New.ttf"
#define SYSTEM_PAT_FONT_PATH_3 "/System/Library/Fonts/Courier New.ttf" #define SYSTEM_PAT_FONT_PATH_3 "/System/Library/Fonts/Courier New.ttf"
@ -3666,6 +3704,9 @@ void FurnaceGUI::popWarningColor() {
#define SYSTEM_FONT_PATH_2 "/system/fonts/DroidSans.ttf" #define SYSTEM_FONT_PATH_2 "/system/fonts/DroidSans.ttf"
#define SYSTEM_FONT_PATH_3 "/system/fonts/DroidSans.ttf" #define SYSTEM_FONT_PATH_3 "/system/fonts/DroidSans.ttf"
// ??? // ???
#define SYSTEM_BIG_FONT_PATH_1 "/system/fonts/Roboto-Regular.ttf"
#define SYSTEM_BIG_FONT_PATH_2 "/system/fonts/DroidSans.ttf"
#define SYSTEM_BIG_FONT_PATH_3 "/system/fonts/DroidSans.ttf"
#define SYSTEM_PAT_FONT_PATH_1 "/system/fonts/RobotoMono-Regular.ttf" #define SYSTEM_PAT_FONT_PATH_1 "/system/fonts/RobotoMono-Regular.ttf"
#define SYSTEM_PAT_FONT_PATH_2 "/system/fonts/DroidSansMono.ttf" #define SYSTEM_PAT_FONT_PATH_2 "/system/fonts/DroidSansMono.ttf"
#define SYSTEM_PAT_FONT_PATH_3 "/system/fonts/CutiveMono.ttf" #define SYSTEM_PAT_FONT_PATH_3 "/system/fonts/CutiveMono.ttf"
@ -3673,6 +3714,9 @@ void FurnaceGUI::popWarningColor() {
#define SYSTEM_FONT_PATH_1 "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf" #define SYSTEM_FONT_PATH_1 "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
#define SYSTEM_FONT_PATH_2 "/usr/share/fonts/TTF/DejaVuSans.ttf" #define SYSTEM_FONT_PATH_2 "/usr/share/fonts/TTF/DejaVuSans.ttf"
#define SYSTEM_FONT_PATH_3 "/usr/share/fonts/ubuntu/Ubuntu-R.ttf" #define SYSTEM_FONT_PATH_3 "/usr/share/fonts/ubuntu/Ubuntu-R.ttf"
#define SYSTEM_BIG_FONT_PATH_1 "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"
#define SYSTEM_BIG_FONT_PATH_2 "/usr/share/fonts/TTF/DejaVuSans.ttf"
#define SYSTEM_BIG_FONT_PATH_3 "/usr/share/fonts/ubuntu/Ubuntu-R.ttf"
#define SYSTEM_PAT_FONT_PATH_1 "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf" #define SYSTEM_PAT_FONT_PATH_1 "/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf"
#define SYSTEM_PAT_FONT_PATH_2 "/usr/share/fonts/TTF/DejaVuSansMono.ttf" #define SYSTEM_PAT_FONT_PATH_2 "/usr/share/fonts/TTF/DejaVuSansMono.ttf"
#define SYSTEM_PAT_FONT_PATH_3 "/usr/share/fonts/ubuntu/UbuntuMono-R.ttf" #define SYSTEM_PAT_FONT_PATH_3 "/usr/share/fonts/ubuntu/UbuntuMono-R.ttf"
@ -3913,12 +3957,17 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
} }
if (settings.mainFont<0 || settings.mainFont>6) settings.mainFont=0; if (settings.mainFont<0 || settings.mainFont>6) settings.mainFont=0;
if (settings.bigFont<0 || settings.bigFont>6) settings.bigFont=0;
if (settings.patFont<0 || settings.patFont>6) settings.patFont=0; if (settings.patFont<0 || settings.patFont>6) settings.patFont=0;
if (settings.mainFont==6 && settings.mainFontPath.empty()) { if (settings.mainFont==6 && settings.mainFontPath.empty()) {
logW("UI font path is empty! reverting to default font"); logW("UI font path is empty! reverting to default font");
settings.mainFont=0; settings.mainFont=0;
} }
if (settings.bigFont==6 && settings.bigFontPath.empty()) {
logW("UI font path is empty! reverting to default font");
settings.bigFont=0;
}
if (settings.patFont==6 && settings.patFontPath.empty()) { if (settings.patFont==6 && settings.patFontPath.empty()) {
logW("pattern font path is empty! reverting to default font"); logW("pattern font path is empty! reverting to default font");
settings.patFont=0; settings.patFont=0;
@ -4004,9 +4053,45 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
// 0x39B = Λ // 0x39B = Λ
static const ImWchar bigFontRange[]={0x20,0xFF,0x39b,0x39b,0}; static const ImWchar bigFontRange[]={0x20,0xFF,0x39b,0x39b,0};
/*
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),NULL,bigFontRange))==NULL) { if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),NULL,bigFontRange))==NULL) {
logE("could not load big UI font!"); logE("could not load big UI font!");
} }
*/
if (settings.mainFontSize==settings.bigFontSize && settings.bigFont<5 && builtinFontM[settings.bigFont]==builtinFont[settings.mainFont]) {
logD("using main font for big font.");
bigFont=mainFont;
} else {
if (settings.bigFont==6) { // custom font
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.bigFontPath.c_str(),MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
logW("could not load big font! reverting to default font");
settings.bigFont=0;
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.bigFont],builtinFontMLen[settings.bigFont],MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,bigFontRange))==NULL) {
logE("could not load big font! falling back to IBM Plex Sans.");
bigFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.bigFont==5) { // system font
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_BIG_FONT_PATH_1,MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_BIG_FONT_PATH_2,MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_BIG_FONT_PATH_3,MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
logW("could not load big font! reverting to default font");
settings.bigFont=0;
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.bigFont],builtinFontMLen[settings.bigFont],MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
logE("could not load big font! falling back to IBM Plex Sans.");
bigFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
}
}
} else {
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFontM[settings.bigFont],builtinFontMLen[settings.bigFont],MAX(1,e->getConfInt("bigFontSize",36)*dpiScale),NULL,upTo800))==NULL) {
logE("could not load big font!");
bigFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
}
mainFont->FallbackChar='?'; mainFont->FallbackChar='?';
mainFont->EllipsisChar='.'; mainFont->EllipsisChar='.';