diff --git a/plugins/Cardinal/src/ImGuiTextEditor.cpp b/plugins/Cardinal/src/ImGuiTextEditor.cpp index 3e12638..d0b0bc9 100644 --- a/plugins/Cardinal/src/ImGuiTextEditor.cpp +++ b/plugins/Cardinal/src/ImGuiTextEditor.cpp @@ -38,7 +38,10 @@ struct ImGuiTextEditor::PrivateData { ImGuiTextEditor::ImGuiTextEditor() : ImGuiWidget(), - pData(new PrivateData) {} + pData(new PrivateData()) +{ + setUseMonospaceFont(); +} ImGuiTextEditor::~ImGuiTextEditor() { diff --git a/plugins/Cardinal/src/ImGuiWidget.cpp b/plugins/Cardinal/src/ImGuiWidget.cpp index dbe2a2f..d3317dd 100644 --- a/plugins/Cardinal/src/ImGuiWidget.cpp +++ b/plugins/Cardinal/src/ImGuiWidget.cpp @@ -28,6 +28,7 @@ struct ImGuiWidget::PrivateData { ImGuiContext* context = nullptr; bool created = false; bool fontGenerated = false; + bool useMonospacedFont = false; float originalScaleFactor = 0.0f; float scaleFactor = 0.0f; @@ -86,17 +87,31 @@ struct ImGuiWidget::PrivateData { fontGenerated = true; -#ifndef DGL_NO_SHARED_RESOURCES ImGuiIO& io(ImGui::GetIO()); - using namespace dpf_resources; - ImFontConfig fc; - fc.FontDataOwnedByAtlas = false; - fc.OversampleH = 1; - fc.OversampleV = 1; - fc.PixelSnapH = true; - io.Fonts->AddFontFromMemoryTTF((void*)dejavusans_ttf, dejavusans_ttf_size, 13.0f * scaleFactor, &fc); - io.Fonts->Build(); + + if (useMonospacedFont) + { + const std::string fontPath = asset::system("fonts/ShareTechMono-Regular.ttf"); + ImFontConfig fc; + fc.OversampleH = 1; + fc.OversampleV = 1; + fc.PixelSnapH = true; + io.Fonts->AddFontFromFileTTF(fontPath.c_str(), 13.0f * scaleFactor, &fc); + io.Fonts->Build(); + } + else + { +#ifndef DGL_NO_SHARED_RESOURCES + using namespace dpf_resources; + ImFontConfig fc; + fc.FontDataOwnedByAtlas = false; + fc.OversampleH = 1; + fc.OversampleV = 1; + fc.PixelSnapH = true; + io.Fonts->AddFontFromMemoryTTF((void*)dejavusans_ttf, dejavusans_ttf_size, 13.0f * scaleFactor, &fc); + io.Fonts->Build(); #endif + } } void resetStyle() @@ -170,6 +185,13 @@ void ImGuiWidget::setAsCurrentContext() ImGui::SetCurrentContext(imData->context); } +void ImGuiWidget::setUseMonospaceFont(const bool useMonoFont) +{ + DISTRHO_SAFE_ASSERT_RETURN(!imData->fontGenerated,); + + imData->useMonospacedFont = useMonoFont; +} + void ImGuiWidget::onHover(const HoverEvent& e) { ImGui::SetCurrentContext(imData->context); diff --git a/plugins/Cardinal/src/ImGuiWidget.hpp b/plugins/Cardinal/src/ImGuiWidget.hpp index bcb0ba7..778069f 100644 --- a/plugins/Cardinal/src/ImGuiWidget.hpp +++ b/plugins/Cardinal/src/ImGuiWidget.hpp @@ -40,6 +40,7 @@ protected: void onSelectKey(const SelectKeyEvent& e) override; void onSelectText(const SelectTextEvent& e) override; void setAsCurrentContext(); + void setUseMonospaceFont(bool useMonoFont = true); virtual void drawImGui() { diff --git a/plugins/Cardinal/src/TextEditor.cpp b/plugins/Cardinal/src/TextEditor.cpp index 3602f13..cbad142 100644 --- a/plugins/Cardinal/src/TextEditor.cpp +++ b/plugins/Cardinal/src/TextEditor.cpp @@ -26,14 +26,31 @@ // -------------------------------------------------------------------------------------------------------------------- -// defaults -#define DEFAULT_LANG "C++" -#define DEFAULT_TEXT "" \ -"// Welcome to a real text editor inside Cardinal\n\n" \ -"#define I_AM_A_MACRO\n\n" \ -"int and_i_am_a_variable;\n\n" \ -"/* look ma, a comment! */\n" \ -"int such_highlight_much_wow() { return 1337; }\n" +// defaults (artwork based on content from https://www.asciiart.eu/animals/cats) +#define DEFAULT_LANG "None" +#define DEFAULT_TEXT "" \ +" \n" \ +" ^ ^ ,_, \n" \ +" (O,O) (.,.) \n" \ +" ( ) ( ) \n" \ +"--------\"-\"---dwb--\"-\"---dwb- \n" \ +" \n" \ +" \n" \ +" \n" \ +" \n" \ +" \n" \ +" \n" \ +" \n" \ +" /^--^\\ /^--^\\ /^--^\\ \n" \ +" \\____/ \\____/ \\____/ \n" \ +" / \\ / \\ / \\ \n" \ +" | | | | | | \n" \ +" \\__ __/ \\__ __/ \\__ __/ \n" \ +"|^|^|^|^\\ \\^|^|^|^/ /^|^|^|^|^\\ \\^|^|^|^|^|^|^|^|^|\n" \ +"| | | | |\\ \\| | |/ /| | | | | |\\ \\| | | | | | | | |\n" \ +"#########/ /#####\\ \\###########/ /#################\n" \ +"| | | | |\\/ | | | \\/| | | | | |\\/ | | | | | | | | |\n" \ +"|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|_|\n" #define DEFAULT_WIDTH 30 struct TextEditorModule : Module {