diff --git a/src/hello_imgui/doc_api.md b/src/hello_imgui/doc_api.md index d2b638b8..9157234c 100644 --- a/src/hello_imgui/doc_api.md +++ b/src/hello_imgui/doc_api.md @@ -51,6 +51,13 @@ ImVec2 EmToVec2(ImVec2 v); float EmSize(); // __HelloImGui::EmSize(nbLines)__ returns a size corresponding to nbLines text lines float EmSize(float nbLines); + +// __HelloImGui::PixelToEm()__ converts a Vec2 in pixels coord to a Vec2 in em units +ImVec2 PixelsToEm(ImVec2 pixels); + +// __HelloImGui::PixelSizeToEm()__ converts a size in pixels coord to a size in em units +float PixelSizeToEm(float pixelSize); + ``` ---- diff --git a/src/hello_imgui/dpi_aware.h b/src/hello_imgui/dpi_aware.h index 04f4ca2c..74b37088 100644 --- a/src/hello_imgui/dpi_aware.h +++ b/src/hello_imgui/dpi_aware.h @@ -127,7 +127,6 @@ ImVec2 EmToVec2(ImVec2 v); float EmSize(); // __HelloImGui::EmSize(nbLines)__ returns a size corresponding to nbLines text lines float EmSize(float nbLines); -// @@md // __HelloImGui::PixelToEm()__ converts a Vec2 in pixels coord to a Vec2 in em units ImVec2 PixelsToEm(ImVec2 pixels); @@ -135,6 +134,12 @@ ImVec2 PixelsToEm(ImVec2 pixels); // __HelloImGui::PixelSizeToEm()__ converts a size in pixels coord to a size in em units float PixelSizeToEm(float pixelSize); +// @@md + +// Returns the current DpiAwareParams, which are used +// for font loading and window size scaling +DpiAwareParams* GetDpiAwareParams(); + } // namespace HelloImGui diff --git a/src/hello_imgui/impl/hello_imgui_font.cpp b/src/hello_imgui/impl/hello_imgui_font.cpp index 039e4463..0bd4ad3e 100644 --- a/src/hello_imgui/impl/hello_imgui_font.cpp +++ b/src/hello_imgui/impl/hello_imgui_font.cpp @@ -130,11 +130,11 @@ namespace HelloImGui // Font oversampling (set by dpiAwareParams) { - const auto& dpiAwareParams = HelloImGui::GetRunnerParams()->dpiAwareParams; - if (dpiAwareParams.fontOversampleH > 0) - params.fontConfig.OversampleH = dpiAwareParams.fontOversampleH; - if (dpiAwareParams.fontOversampleV > 0) - params.fontConfig.OversampleV = dpiAwareParams.fontOversampleV; + const auto& dpiAwareParams = HelloImGui::GetDpiAwareParams(); + if (dpiAwareParams->fontOversampleH > 0) + params.fontConfig.OversampleH = dpiAwareParams->fontOversampleH; + if (dpiAwareParams->fontOversampleV > 0) + params.fontConfig.OversampleV = dpiAwareParams->fontOversampleV; } float fontSize = fontSize_;