Skip to content

Commit

Permalink
Fix DPI scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
JVital2013 committed Aug 17, 2023
1 parent 68b188c commit 6dac816
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
1 change: 1 addition & 0 deletions android/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ void init(struct android_app *app)
// ImGui::StyleColorsClassic();

satdump::initMainUI();
style::setFonts();
was_init = true;
}

Expand Down
7 changes: 3 additions & 4 deletions src-core/common/widgets/markdown_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,13 @@ namespace widgets
void MarkdownHelper::init()
{
mdConfig.linkCallback = link_callback;

mdConfig.headingFormats[0] = {style::bigFont, true};
mdConfig.headingFormats[1] = {style::bigFont, true};
mdConfig.headingFormats[2] = {style::baseFont, true};
};

void MarkdownHelper::render()
{
mdConfig.headingFormats[0] = { style::bigFont, true };
mdConfig.headingFormats[1] = { style::bigFont, true };
mdConfig.headingFormats[2] = { style::baseFont, true };
ImGui::Markdown(markdown_.c_str(), markdown_.length(), mdConfig);
}

Expand Down
4 changes: 3 additions & 1 deletion src-core/core/style.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ namespace style

void setFonts()
{

ImGui::GetIO().Fonts->Clear();
ImFontGlyphRangesBuilder builder;
static const ImWchar def[] = {0x20, 0x2300, 0}; //default range
static ImFontConfig config;
Expand All @@ -189,7 +189,9 @@ namespace style
for (int i = 0; i < 6; i++)
baseFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/font.ttf").c_str(), 16.0f * ui_scale, &config, list[i]);

config.MergeMode = false;
bigFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 45.0f * ui_scale); //, &config, ranges);
//hugeFont = ImGui::GetIO().Fonts->AddFontFromFileTTF(resources::getResourcePath("fonts/Roboto-Medium.ttf").c_str(), 128.0f * ui_scale); //, &config, ranges);
ImGui::GetIO().Fonts->Build();
}
}
13 changes: 9 additions & 4 deletions src-ui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,15 @@ int main(int argc, char *argv[])
// Init UI
satdump::initMainUI();

//Shut down loading screen
logger->del_sink(loading_screen_sink);
loading_screen_sink.reset();

//Set font again to adjust for DPI
style::setFonts();
ImGui_ImplOpenGL3_DestroyFontsTexture();
ImGui_ImplOpenGL3_CreateFontsTexture();

if (satdump::processing::is_processing)
{
satdump::ui_thread_pool.push([&](int)
Expand All @@ -235,10 +244,6 @@ int main(int argc, char *argv[])
{ satdump::updateTLEFile(satdump::user_path + "/satdump_tles.txt");
satdump::loadTLEFileIntoRegistry(satdump::user_path + "/satdump_tles.txt"); });

//Shut down loading screen
logger->del_sink(loading_screen_sink);
loading_screen_sink.reset();

// Main loop
do
{
Expand Down

0 comments on commit 6dac816

Please sign in to comment.