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
);
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:
if (!dirExists(workingDirFont)) workingDirFont=getHomeDir();
hasOpened=fileDialog->openLoad(
@ -4622,6 +4632,7 @@ bool FurnaceGUI::loop() {
workingDirROMExport=fileDialog->getPath()+DIR_SEPARATOR_STR;
break;
case GUI_FILE_LOAD_MAIN_FONT:
case GUI_FILE_LOAD_BIG_FONT:
case GUI_FILE_LOAD_PAT_FONT:
workingDirFont=fileDialog->getPath()+DIR_SEPARATOR_STR;
break;
@ -5083,6 +5094,9 @@ bool FurnaceGUI::loop() {
case GUI_FILE_LOAD_MAIN_FONT:
settings.mainFontPath=copyOfName;
break;
case GUI_FILE_LOAD_BIG_FONT:
settings.bigFontPath=copyOfName;
break;
case GUI_FILE_LOAD_PAT_FONT:
settings.patFontPath=copyOfName;
break;

View File

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

View File

@ -58,6 +58,16 @@ const char* mainFonts[]={
"<Custom...>"
};
const char* bigFonts[]={
"IBM Plex Sans",
"Liberation Sans",
"Exo",
"Proggy Clean",
"GNU Unifont",
"<Use system font>",
"<Custom...>"
};
const char* patFonts[]={
"IBM Plex Mono",
"Mononoki",
@ -1857,6 +1867,20 @@ void FurnaceGUI::drawSettings() {
if (settings.mainFontSize<3) settings.mainFontSize=3;
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::SameLine();
ImGui::Combo("##PatFont",&settings.patFont,patFonts,7);
@ -2712,6 +2736,7 @@ void FurnaceGUI::drawSettings() {
void FurnaceGUI::syncSettings() {
settings.mainFontSize=e->getConfInt("mainFontSize",18);
settings.bigFontSize=e->getConfInt("bigFontSize",36);
settings.patFontSize=e->getConfInt("patFontSize",18);
settings.iconSize=e->getConfInt("iconSize",16);
settings.audioEngine=(e->getConfString("audioEngine","SDL")=="SDL")?1:0;
@ -2739,6 +2764,7 @@ void FurnaceGUI::syncSettings() {
settings.mainFont=e->getConfInt("mainFont",0);
settings.patFont=e->getConfInt("patFont",0);
settings.mainFontPath=e->getConfString("mainFontPath","");
settings.bigFontPath=e->getConfString("bigFontPath","");
settings.patFontPath=e->getConfString("patFontPath","");
settings.patRowsBase=e->getConfInt("patRowsBase",0);
settings.orderRowsBase=e->getConfInt("orderRowsBase",1);
@ -2866,6 +2892,7 @@ void FurnaceGUI::syncSettings() {
settings.noDMFCompat=e->getConfInt("noDMFCompat",0);
clampSetting(settings.mainFontSize,2,96);
clampSetting(settings.bigFontSize,2,96);
clampSetting(settings.patFontSize,2,96);
clampSetting(settings.iconSize,2,48);
clampSetting(settings.audioEngine,0,1);
@ -3067,6 +3094,7 @@ void FurnaceGUI::commitSettings() {
);
e->setConf("mainFontSize",settings.mainFontSize);
e->setConf("bigFontSize",settings.bigFontSize);
e->setConf("patFontSize",settings.patFontSize);
e->setConf("iconSize",settings.iconSize);
e->setConf("audioEngine",String(audioBackends[settings.audioEngine]));
@ -3092,8 +3120,10 @@ void FurnaceGUI::commitSettings() {
e->setConf("tg100Path",settings.tg100Path);
e->setConf("mu5Path",settings.mu5Path);
e->setConf("mainFont",settings.mainFont);
e->setConf("bigFont",settings.mainFont);
e->setConf("patFont",settings.patFont);
e->setConf("mainFontPath",settings.mainFontPath);
e->setConf("bigFontPath",settings.bigFontPath);
e->setConf("patFontPath",settings.patFontPath);
e->setConf("patRowsBase",settings.patRowsBase);
e->setConf("orderRowsBase",settings.orderRowsBase);
@ -3650,6 +3680,11 @@ void FurnaceGUI::popWarningColor() {
// TODO!
#define SYSTEM_FONT_PATH_3 "C:\\Windows\\Fonts\\tahoma.ttf"
// 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_2 "C:\\Windows\\Fonts\\cour.ttf"
// 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_2 "/System/Library/Fonts/Helvetica.ttc"
#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_2 "/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_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_2 "/system/fonts/DroidSansMono.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_2 "/usr/share/fonts/TTF/DejaVuSans.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_2 "/usr/share/fonts/TTF/DejaVuSansMono.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.bigFont<0 || settings.bigFont>6) settings.bigFont=0;
if (settings.patFont<0 || settings.patFont>6) settings.patFont=0;
if (settings.mainFont==6 && settings.mainFontPath.empty()) {
logW("UI font path is empty! reverting to default font");
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()) {
logW("pattern font path is empty! reverting to default font");
settings.patFont=0;
@ -4004,9 +4053,45 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
// 0x39B = Λ
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) {
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->EllipsisChar='.';