GUI: use less video memory

don't oversample icons, big font and header font
This commit is contained in:
tildearrow 2023-08-21 16:03:16 -05:00
parent bb874d9415
commit f3c438eee5

View file

@ -4243,11 +4243,17 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fontConf;
ImFontConfig fontConfP;
ImFontConfig fontConfB;
ImFontConfig fontConfH;
fontConf.OversampleV=1;
fontConf.OversampleH=2;
fontConfP.OversampleV=1;
fontConfP.OversampleH=2;
fontConfB.OversampleV=1;
fontConfB.OversampleH=1;
fontConfH.OversampleV=1;
fontConfH.OversampleH=1;
//fontConf.RasterizerMultiply=1.5;
//fontConfP.RasterizerMultiply=1.5;
@ -4295,6 +4301,9 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fc1;
fc1.MergeMode=true;
// save memory
fc1.OversampleH=1;
fc1.OversampleV=1;
if (settings.mainFont==6) { // custom font
if ((mainFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.mainFontPath.c_str(),MAX(1,e->getConfInt("mainFontSize",18)*dpiScale),&fontConf,fontRange))==NULL) {
@ -4331,6 +4340,9 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
ImFontConfig fc;
fc.MergeMode=true;
fc.OversampleH=1;
fc.OversampleV=1;
fc.PixelSnapH=true;
fc.GlyphMinAdvanceX=e->getConfInt("iconSize",16)*dpiScale;
static const ImWchar fontRangeIcon[]={ICON_MIN_FA,ICON_MAX_FA,0};
if ((iconFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(iconFont_compressed_data,iconFont_compressed_size,MAX(1,e->getConfInt("iconSize",16)*dpiScale),&fc,fontRangeIcon))==NULL) {
@ -4379,7 +4391,7 @@ 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) {
if ((bigFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(font_plexSans_compressed_data,font_plexSans_compressed_size,MAX(1,40*dpiScale),&fontConfB,bigFontRange))==NULL) {
logE("could not load big UI font!");
}
@ -4388,21 +4400,21 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
headFont=mainFont;
} else {
if (settings.headFont==6) { // custom font
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(settings.headFontPath.c_str(),MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
}
} else if (settings.headFont==5) { // system font
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",27)*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) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_1,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_2,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromFileTTF(SYSTEM_HEAD_FONT_PATH_3,MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logW("could not load header font! reverting to default font");
settings.headFont=0;
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font! falling back to IBM Plex Sans.");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}
@ -4410,7 +4422,7 @@ void FurnaceGUI::applyUISettings(bool updateFonts) {
}
}
} else {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),NULL,upTo800))==NULL) {
if ((headFont=ImGui::GetIO().Fonts->AddFontFromMemoryCompressedTTF(builtinFont[settings.headFont],builtinFontLen[settings.headFont],MAX(1,e->getConfInt("headFontSize",27)*dpiScale),&fontConfH,upTo800))==NULL) {
logE("could not load header font!");
headFont=ImGui::GetIO().Fonts->AddFontDefault();
}