From a1d08059d678f1ae30f5a44c2e75f1e3ca6d09bf Mon Sep 17 00:00:00 2001 From: Paul Date: Fri, 27 Sep 2024 09:47:26 -0400 Subject: [PATCH] Move to our diffs + JUCE 8.0.2 (#7802) * Move to our diffs + JUCE 8.0.2 Lets see if this builds! * Move to ubuntu 20 docker mage * More juce font nonsense * more font nonsense * Turn off melatonin inspector for a bit * more font nonsense * String width nonsense * sigh --- .github/workflows/build-pr.yml | 3 +- .github/workflows/build-release.yml | 1 + CMakeLists.txt | 2 +- fix_string_width.pl | 40 +++++++++++++++++++ libs/JUCE | 2 +- libs/melatonin_inspector | 2 +- src/CMakeLists.txt | 13 ++++-- src/surge-fx/SurgeFXEditor.cpp | 4 +- src/surge-fx/SurgeLookAndFeel.h | 10 ++--- src/surge-xt/gui/RuntimeFont.cpp | 10 +++-- src/surge-xt/gui/RuntimeFont.h | 8 ++-- src/surge-xt/gui/SkinSupport.cpp | 4 +- src/surge-xt/gui/SurgeGUIEditor.cpp | 6 ++- src/surge-xt/gui/SurgeGUIEditor.h | 4 ++ .../gui/SurgeGUIEditorMenuStructures.cpp | 5 +++ src/surge-xt/gui/SurgeJUCELookAndFeel.cpp | 6 +-- src/surge-xt/gui/overlays/AboutScreen.cpp | 4 +- src/surge-xt/gui/overlays/FilterAnalysis.cpp | 16 +++++--- .../gui/overlays/KeyBindingsOverlay.cpp | 2 +- src/surge-xt/gui/overlays/MSEGEditor.cpp | 8 ++-- src/surge-xt/gui/overlays/Oscilloscope.cpp | 15 ++++--- .../gui/overlays/PatchStoreDialog.cpp | 2 +- .../gui/widgets/LFOAndStepDisplay.cpp | 2 +- .../gui/widgets/MenuCustomComponents.cpp | 9 ++--- .../gui/widgets/ModulatableControlInterface.h | 2 +- .../gui/widgets/ModulationSourceButton.h | 2 +- src/surge-xt/gui/widgets/MultiSwitch.h | 2 +- .../gui/widgets/ParameterInfowindow.cpp | 19 ++++----- .../gui/widgets/ParameterInfowindow.h | 2 +- src/surge-xt/gui/widgets/PatchSelector.cpp | 20 ++++++---- src/surge-xt/gui/widgets/VerticalLabel.h | 2 +- x | 27 +++++++++++++ 32 files changed, 177 insertions(+), 77 deletions(-) create mode 100644 fix_string_width.pl create mode 100644 x diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml index 5f83bcff07f..21cae2fe9d0 100644 --- a/.github/workflows/build-pr.yml +++ b/.github/workflows/build-pr.yml @@ -87,7 +87,7 @@ jobs: ctest -j 4 || ctest --rerun-failed --output-on-failure build_plugin_lindoc: - name: PR - U18 Docker + name: PR - U20 Docker runs-on: ubuntu-latest steps: - name: Checkout code @@ -98,6 +98,7 @@ jobs: - name: Build in Docker uses: surge-synthesizer/sst-githubactions/cmake-in-docker@main with: + image: ghcr.io/surge-synthesizer/sst-dockerimages/ubuntu20_gcc11:main username: ${{ github.actor }} token: ${{ secrets.GITHUB_TOKEN }} cmakeArgs: -DCMAKE_BUILD_TYPE=Debug -GNinja diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 8071aef3529..f47bb044071 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -114,6 +114,7 @@ jobs: - name: Build in Docker uses: surge-synthesizer/sst-githubactions/cmake-in-docker@main with: + image: ghcr.io/surge-synthesizer/sst-dockerimages/ubuntu20_gcc11:main username: ${{ github.actor }} token: ${{ secrets.GITHUB_TOKEN }} cmakeArgs: -DAZURE_PIPELINE=1 -DSURGE_BUILD_LV2=TRUE -DSURGE_VERSION="${{ needs.surge_version.outputs.surge_version }}" -DCMAKE_BUILD_TYPE=Release -GNinja diff --git a/CMakeLists.txt b/CMakeLists.txt index f8a80016154..1c059175c90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 3.15) cmake_policy(SET CMP0091 NEW) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9 CACHE STRING "Minimum macOS version") +set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13 CACHE STRING "Minimum macOS version") set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/fix_string_width.pl b/fix_string_width.pl new file mode 100644 index 00000000000..088ffd456b2 --- /dev/null +++ b/fix_string_width.pl @@ -0,0 +1,40 @@ +#!/usr/bin/perl + + +use File::Find; +use File::Basename; + +find( + { + wanted => \&findfiles, + }, + 'src' +); + +sub findfiles +{ + $f = $File::Find::name; + print $f . "\n"; + if ($f =~ m/\.cpp$/ || $f =~ m/\.h$/) + { + $q = basename($f); + + open (IN, "< $q") || die "Cant open $q from $f"; + open (OUT, "> $q.bak"); + while() + { + if (m/getStringWidth/) + { + print; + s/([^\s\{]+).getStringWidthFloat\(/juce::GlyphArrangement::getStringWidth\($1, /; + print; + #die; + } + print OUT; + + } + close(IN); + close(OUT); + system("mv ${q}.bak ${q}"); + } +} diff --git a/libs/JUCE b/libs/JUCE index dd9cf176a15..f468c3a6b4a 160000 --- a/libs/JUCE +++ b/libs/JUCE @@ -1 +1 @@ -Subproject commit dd9cf176a153e3b8f6cad408a843f7f371f86c9d +Subproject commit f468c3a6b4a8541c9b7a653b5d0b4300ee555154 diff --git a/libs/melatonin_inspector b/libs/melatonin_inspector index b7a0f2de07e..ac5595d21b3 160000 --- a/libs/melatonin_inspector +++ b/libs/melatonin_inspector @@ -1 +1 @@ -Subproject commit b7a0f2de07ed8692963605561fe1a3793885994b +Subproject commit ac5595d21b308e18aa2de140c28edb9e7c2adc22 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 31bee8d51db..840789f5e10 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,7 @@ option(SURGE_BUILD_PYTHON_BINDINGS "Build Surge Python bindings with pybind11" O option(SURGE_COPY_TO_PRODUCTS "Copy built plugins to the products directory" ON) option(SURGE_COPY_AFTER_BUILD "Copy JUCE plugins to system plugin area after build" OFF) option(SURGE_EXPOSE_PRESETS "Expose surge presets via the JUCE Program API" OFF) +option(SURGE_INCLUDE_MELATONIN_INSPECTOR "Include melatonin inspector" OFF) # Currently the JUCE LV2 build crashes in our CI pipeline, so leave it for users to self build option(SURGE_BUILD_LV2 "Build Surge as an LV2" OFF) @@ -20,7 +21,9 @@ include(cmake/lib.cmake) if (NOT SURGE_SKIP_JUCE_FOR_RACK) message(STATUS "Using JUCE from ${SURGE_JUCE_PATH}") add_subdirectory(${SURGE_JUCE_PATH} ${CMAKE_BINARY_DIR}/JUCE EXCLUDE_FROM_ALL) - add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../libs/melatonin_inspector" ${CMAKE_BINARY_DIR}/melatonin_inspector EXCLUDE_FROM_ALL) + if (SURGE_INCLUDE_MELATONIN_INSPECTOR) + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../libs/melatonin_inspector" ${CMAKE_BINARY_DIR}/melatonin_inspector EXCLUDE_FROM_ALL) + endif() endif() if(${CMAKE_VERSION} VERSION_LESS 3.21) @@ -57,7 +60,8 @@ target_compile_definitions(surge-juce INTERFACE JUCE_WEB_BROWSER=0 JUCE_USE_CAMERA=disabled - JUCE_DISPLAY_SPLASH_SCREEN=0 + # No longer needed with JUCE 8 + # JUCE_DISPLAY_SPLASH_SCREEN=0 JUCE_REPORT_APP_USAGE=0 JUCE_MODAL_LOOPS_PERMITTED=0 @@ -74,7 +78,10 @@ target_compile_definitions(surge-juce INTERFACE ) if (NOT SURGE_SKIP_JUCE_FOR_RACK) - target_link_libraries(surge-juce INTERFACE melatonin_inspector) + if (SURGE_INCLUDE_MELATONIN_INSPECTOR) + target_link_libraries(surge-juce INTERFACE melatonin_inspector) + target_compile_definitions(surge-juce INTERFACE SURGE_INCLUDE_MELATONIN_INSPECTOR=1) + endif() endif() if(NOT SURGE_SKIP_VST3) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 47a17f6e56a..1ba612b6b52 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -676,7 +676,7 @@ struct SurgefxAudioProcessorEditor::PromptOverlay : juce::Component, juce::TextE PromptOverlay() { ed = std::make_unique(); - ed->setFont(juce::Font(28)); + ed->setFont(juce::FontOptions(28)); ed->setColour(juce::TextEditor::ColourIds::textColourId, juce::Colours::white); ed->setJustification(juce::Justification::centred); ed->addListener(this); @@ -688,7 +688,7 @@ struct SurgefxAudioProcessorEditor::PromptOverlay : juce::Component, juce::TextE { ed->clear(); ed->setText(s, juce::NotificationType::dontSendNotification); - ed->applyFontToAllText(juce::Font(28)); + ed->applyFontToAllText(juce::FontOptions(28)); ed->applyColourToAllText(juce::Colours::white); ed->repaint(); } diff --git a/src/surge-fx/SurgeLookAndFeel.h b/src/surge-fx/SurgeLookAndFeel.h index eb99e6f4bba..591983b78e4 100644 --- a/src/surge-fx/SurgeLookAndFeel.h +++ b/src/surge-fx/SurgeLookAndFeel.h @@ -250,7 +250,7 @@ class SurgeLookAndFeel : public juce::LookAndFeel_V4 g.drawLine(0, h - orangeHeight, w, h - orangeHeight); // text - g.setFont(12); + g.setFont(juce::FontOptions(12)); g.drawSingleLineText(Surge::Build::FullVersionStr, w - 3, h - 26.f, juce::Justification::right); g.drawSingleLineText(Surge::Build::BuildDate, w - 3, h - 6.f, juce::Justification::right); @@ -334,15 +334,15 @@ class SurgeFXParamDisplay : public juce::Component if (isEnabled()) { g.setColour(findColour(SurgeLookAndFeel::SurgeColourIds::paramDisplay)); - g.setFont(10 * hScale); + g.setFont(juce::FontOptions(10 * hScale)); g.drawSingleLineText(group, bounds.getX() + 5, bounds.getY() + 2 + 10 * hScale); - g.setFont(12 * hScale); + g.setFont(juce::FontOptions(12 * hScale)); g.drawSingleLineText(name, bounds.getX() + 5, bounds.getY() + 2 + (10 + 3 + 11) * hScale); if (!overlayEditor->isVisible()) { - g.setFont(20 * hScale); + g.setFont(juce::FontOptions(20 * hScale)); g.drawSingleLineText(display, bounds.getX() + 5, bounds.getY() + bounds.getHeight() - 5); } @@ -384,7 +384,7 @@ class SurgeFXParamDisplay : public juce::Component overlayEditor->setColour(juce::TextEditor::ColourIds::highlightColourId, juce::Colour(0xFF775522)); overlayEditor->setJustification(juce::Justification::bottomLeft); - overlayEditor->setFont(juce::Font(20)); + overlayEditor->setFont(juce::FontOptions(20)); overlayEditor->setText(display, juce::dontSendNotification); overlayEditor->setVisible(true); overlayEditor->grabKeyboardFocus(); diff --git a/src/surge-xt/gui/RuntimeFont.cpp b/src/surge-xt/gui/RuntimeFont.cpp index ee84c1b3722..93257ac193c 100644 --- a/src/surge-xt/gui/RuntimeFont.cpp +++ b/src/surge-xt/gui/RuntimeFont.cpp @@ -77,11 +77,11 @@ juce::Font FontManager::getLatoAtSize(float size, juce::Font::FontStyleFlags sty { if (hasLatoOverride) { - return juce::Font(latoOverride).withPointHeight(size).withStyle(style); + return juce::Font(juce::FontOptions(latoOverride)).withPointHeight(size).withStyle(style); } else if (useOSLato) { - return juce::Font("Lato", 10, 0).withPointHeight(size).withStyle(style); + return juce::Font(juce::FontOptions("Lato", 10, 0)).withPointHeight(size).withStyle(style); } else { @@ -98,13 +98,15 @@ juce::Font FontManager::getLatoAtSize(float size, juce::Font::FontStyleFlags sty { tf = latoItalicTypeface; } - return juce::Font(tf).withPointHeight(size).withStyle(style); + return juce::Font(juce::FontOptions(tf)).withPointHeight(size).withStyle(style); } } juce::Font FontManager::getFiraMonoAtSize(float size, juce::Font::FontStyleFlags style) const { - return juce::Font(firaMonoRegularTypeface).withPointHeight(size).withStyle(style); + return juce::Font(juce::FontOptions(firaMonoRegularTypeface)) + .withPointHeight(size) + .withStyle(style); } void FontManager::overrideLatoWith(juce::ReferenceCountedObjectPtr itf) diff --git a/src/surge-xt/gui/RuntimeFont.h b/src/surge-xt/gui/RuntimeFont.h index 72145595ad8..826e0b77af4 100644 --- a/src/surge-xt/gui/RuntimeFont.h +++ b/src/surge-xt/gui/RuntimeFont.h @@ -45,10 +45,10 @@ struct FontManager bool useOSLato{false}; - juce::Font displayFont; - juce::Font patchNameFont; - juce::Font lfoTypeFont; - juce::Font aboutFont; + juce::Font displayFont{juce::FontOptions()}; + juce::Font patchNameFont{juce::FontOptions()}; + juce::Font lfoTypeFont{juce::FontOptions()}; + juce::Font aboutFont{juce::FontOptions()}; void setupFontMembers(); juce::ReferenceCountedObjectPtr latoRegularTypeface, latoBoldTypeface, diff --git a/src/surge-xt/gui/SkinSupport.cpp b/src/surge-xt/gui/SkinSupport.cpp index c17f4528a73..1f148659eb1 100644 --- a/src/surge-xt/gui/SkinSupport.cpp +++ b/src/surge-xt/gui/SkinSupport.cpp @@ -1141,8 +1141,8 @@ juce::Font Skin::getFont(const Surge::Skin::FontDesc &d) { auto fo = fontOverrides[d.id]; if (typeFaces.find(fo.family) != typeFaces.end()) - return juce::Font(typeFaces[fo.family]).withPointHeight(fo.size); - return juce::Font(fo.family, fo.size, juce::Font::FontStyleFlags::plain); + return juce::Font(juce::FontOptions(typeFaces[fo.family])).withPointHeight(fo.size); + return juce::Font(juce::FontOptions(fo.family, fo.size, juce::Font::FontStyleFlags::plain)); } if (d.hasParent) diff --git a/src/surge-xt/gui/SurgeGUIEditor.cpp b/src/surge-xt/gui/SurgeGUIEditor.cpp index b0218dc15a4..2d5e5be4a5e 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.cpp +++ b/src/surge-xt/gui/SurgeGUIEditor.cpp @@ -20,7 +20,10 @@ * https://github.com/surge-synthesizer/surge */ +#if SURGE_INCLUDE_MELATONIN_INSPECTOR #include "melatonin_inspector/melatonin_inspector.h" +#endif + #include "SurgeGUIEditor.h" #include "resource.h" @@ -4210,7 +4213,8 @@ SurgeGUIEditor::layoutComponentForSkin(std::shared_ptrtypeFaces.find(ff) != currentSkin->typeFaces.end()) { - hs->setFont(juce::Font(currentSkin->typeFaces[ff]).withPointHeight(fs)); + hs->setFont( + juce::Font(juce::FontOptions(currentSkin->typeFaces[ff])).withPointHeight(fs)); hs->setFontSize(fs); } } diff --git a/src/surge-xt/gui/SurgeGUIEditor.h b/src/surge-xt/gui/SurgeGUIEditor.h index dd6b3a1e8a1..99f3e9493af 100644 --- a/src/surge-xt/gui/SurgeGUIEditor.h +++ b/src/surge-xt/gui/SurgeGUIEditor.h @@ -56,10 +56,12 @@ class SurgeSynthEditor; +#if SURGE_INCLUDE_MELATONIN_INSPECTOR namespace melatonin { class Inspector; } +#endif namespace Surge { @@ -183,7 +185,9 @@ class SurgeGUIEditor : public Surge::GUI::IComponentTagValue::Listener, bool debugFocus{false}; void globalFocusChanged(juce::Component *fc) override; +#if SURGE_INCLUDE_MELATONIN_INSPECTOR std::unique_ptr melatoninInspector; +#endif protected: virtual void setParameter(long index, float value); diff --git a/src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp b/src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp index b8d7afe236a..35f4befaaa7 100644 --- a/src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp +++ b/src/surge-xt/gui/SurgeGUIEditorMenuStructures.cpp @@ -20,7 +20,10 @@ * https://github.com/surge-synthesizer/surge */ +#if SURGE_INCLUDE_MELATONIN_INSPECTOR #include "melatonin_inspector/melatonin_inspector.h" +#endif + #include "SurgeGUIEditor.h" #include "SurgeGUIEditorTags.h" #include "SurgeGUIUtils.h" @@ -1821,6 +1824,7 @@ juce::PopupMenu SurgeGUIEditor::makeDevMenu(const juce::Point &where) devSubMenu.addItem(Surge::GUI::toOSCase("Dump Undo/Redo Stack to stdout"), true, false, [this]() { undoManager()->dumpStack(); }); +#if SURGE_INCLUDE_MELATONIN_INSPECTOR if (melatoninInspector) { devSubMenu.addItem("Close Melatonin Inspector", [this]() { @@ -1840,6 +1844,7 @@ juce::PopupMenu SurgeGUIEditor::makeDevMenu(const juce::Point &where) melatoninInspector->setVisible(true); }); } +#endif #ifdef INSTRUMENT_UI devSubMenu.addItem(Surge::GUI::toOSCase("Show UI Instrumentation..."), diff --git a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp index f13756aa99e..f532f683bfe 100644 --- a/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp +++ b/src/surge-xt/gui/SurgeJUCELookAndFeel.cpp @@ -146,7 +146,7 @@ void SurgeJUCELookAndFeel::drawLabel(Graphics &graphics, Label &label) int SurgeJUCELookAndFeel::getTabButtonBestWidth(TabBarButton &b, int d) { auto f = skin->getFont(Fonts::Widgets::TabButtonFont); - auto r = f.getStringWidth(b.getButtonText()) + 20; + auto r = (int)juce::GlyphArrangement::getStringWidth(f, b.getButtonText()) + 20; return r; } @@ -238,8 +238,8 @@ void SurgeJUCELookAndFeel::drawDocumentWindowTitleBar(DocumentWindow &window, Gr fontVersion = fontSurge; } - auto sw = fontSurge.getStringWidth(surgeLabel); - auto vw = fontVersion.getStringWidth(surgeVersion); + auto sw = (int)juce::GlyphArrangement::getStringWidth(fontSurge, surgeLabel); + auto vw = (int)juce::GlyphArrangement::getStringWidth(fontVersion, surgeVersion); auto icon = associatedBitmapStore->getImage(IDB_SURGE_ICON); diff --git a/src/surge-xt/gui/overlays/AboutScreen.cpp b/src/surge-xt/gui/overlays/AboutScreen.cpp index 0f16d818794..f973e19f4db 100644 --- a/src/surge-xt/gui/overlays/AboutScreen.cpp +++ b/src/surge-xt/gui/overlays/AboutScreen.cpp @@ -302,7 +302,7 @@ void AboutScreen::resized() lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link)); lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification); - auto strw = font.getStringWidth(std::get<1>(l)) + 8; + auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8; lb->setBounds(margin + colW, h0, strw, lHeight); addAndMakeVisible(*lb); @@ -344,7 +344,7 @@ void AboutScreen::resized() lb->setColour(juce::Label::textColourId, skin->getColor(Colors::AboutPage::Link)); lb->setText(std::get<1>(l), juce::NotificationType::dontSendNotification); - auto strw = font.getStringWidth(std::get<1>(l)) + 8; + auto strw = (int)juce::GlyphArrangement::getStringWidth(font, std::get<1>(l)) + 8; lb->setBounds(rightSide + colW, h1, strw, lHeight); addAndMakeVisible(*lb); diff --git a/src/surge-xt/gui/overlays/FilterAnalysis.cpp b/src/surge-xt/gui/overlays/FilterAnalysis.cpp index aa2168b2a1c..f825d68acbb 100644 --- a/src/surge-xt/gui/overlays/FilterAnalysis.cpp +++ b/src/surge-xt/gui/overlays/FilterAnalysis.cpp @@ -219,9 +219,11 @@ void FilterAnalysis::paint(juce::Graphics &g) const auto over1000 = freq >= 1000.f; const auto freqString = juce::String(over1000 ? freq / 1000.f : freq) + (over1000 ? "k" : ""); - const auto labelRect = juce::Rectangle{font.getStringWidth(freqString), labelHeight} - .withBottomY(height - 2) - .withRightX((int)xPos); + const auto labelRect = + juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, freqString), + labelHeight} + .withBottomY(height - 2) + .withRightX((int)xPos); g.setColour(skin->getColor(Colors::MSEGEditor::Axis::Text)); g.drawFittedText(freqString, labelRect, juce::Justification::bottom, 1); @@ -245,9 +247,11 @@ void FilterAnalysis::paint(juce::Graphics &g) g.drawLine(line); const auto dbString = juce::String(dB) + " dB"; - const auto labelRect = juce::Rectangle{font.getStringWidth(dbString), labelHeight} - .withBottomY((int)yPos) - .withRightX(width - 2); + const auto labelRect = + juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, dbString), + labelHeight} + .withBottomY((int)yPos) + .withRightX(width - 2); g.setColour(skin->getColor(Colors::MSEGEditor::Axis::SecondaryText)); g.drawFittedText(dbString, labelRect, juce::Justification::right, 1); diff --git a/src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp b/src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp index 45588e146eb..43e09a64525 100644 --- a/src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp +++ b/src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp @@ -75,7 +75,7 @@ struct KeyBindingsListRow : public juce::Component std::string desc = ""; keyDesc = std::make_unique("Key Binding", desc); keyDesc->setAccessible(true); - keyDesc->setFont(juce::Font(10)); + keyDesc->setFont(juce::Font(juce::FontOptions(10))); addAndMakeVisible(*keyDesc); reset = std::make_unique("Reset"); diff --git a/src/surge-xt/gui/overlays/MSEGEditor.cpp b/src/surge-xt/gui/overlays/MSEGEditor.cpp index 866f199130d..fc2f989bf3b 100644 --- a/src/surge-xt/gui/overlays/MSEGEditor.cpp +++ b/src/surge-xt/gui/overlays/MSEGEditor.cpp @@ -865,14 +865,14 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp g.setColour(skin->getColor(Colors::MSEGEditor::Axis::Text)); g.setFont(primaryFont); txt = fmt::format("{:d}", int(t)); - sw = primaryFont.getStringWidthFloat(txt); + sw = juce::GlyphArrangement::getStringWidth(primaryFont, txt); } else { g.setColour(skin->getColor(Colors::MSEGEditor::Axis::SecondaryText)); g.setFont(secondaryFont); txt = fmt::format("{:5.2f}", t); - sw = secondaryFont.getStringWidthFloat(txt); + sw = juce::GlyphArrangement::getStringWidth(secondaryFont, txt); } g.drawText(txt, px - (sw / 2), haxisArea.getY() + 2, sw, yofs, @@ -1553,8 +1553,8 @@ struct MSEGCanvas : public juce::Component, public Surge::GUI::SkinConsumingComp std::string txt = fmt::format("X: {:.{}f}", pxt(cx), prec), txt2 = fmt::format("Y: {:.{}f}", val, prec); - int sw1 = g.getCurrentFont().getStringWidth(txt), - sw2 = g.getCurrentFont().getStringWidth(txt2); + int sw1 = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt), + sw2 = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt2); float dragX = r.getRight(), dragY = r.getBottom(); float dragW = 6 + std::max(sw1, sw2), dragH = 22; diff --git a/src/surge-xt/gui/overlays/Oscilloscope.cpp b/src/surge-xt/gui/overlays/Oscilloscope.cpp index e775db48bbd..b9938024775 100644 --- a/src/surge-xt/gui/overlays/Oscilloscope.cpp +++ b/src/surge-xt/gui/overlays/Oscilloscope.cpp @@ -1499,8 +1499,9 @@ void Oscilloscope::Background::paintSpectrumBackground(juce::Graphics &g) juce::String(over1000 ? freq / 1000.f : freq) + (over1000 ? "k" : ""); // Label will go past the end of the scopeRect. const auto labelRect = - juce::Rectangle{font.getStringWidth(freqString), labelHeight}.withCentre( - juce::Point(xPos, height + 10)); + juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, freqString), + labelHeight} + .withCentre(juce::Point(xPos, height + 10)); g.setColour(skin->getColor(Colors::MSEGEditor::Axis::Text)); g.drawFittedText(freqString, labelRect, juce::Justification::bottom, 1); @@ -1541,9 +1542,11 @@ void Oscilloscope::Background::paintSpectrumBackground(juce::Graphics &g) std::string dbString = convert.str() + " dB"; // Label will go past the end of the scopeRect. - const auto labelRect = juce::Rectangle{font.getStringWidth(dbString), labelHeight} - .withBottomY((int)(yPos + (labelHeight / 2)) + 1) - .withRightX(width + 32); + const auto labelRect = + juce::Rectangle{(int)juce::GlyphArrangement::getStringWidth(font, dbString), + labelHeight} + .withBottomY((int)(yPos + (labelHeight / 2)) + 1) + .withRightX(width + 32); g.setColour(skin->getColor(Colors::MSEGEditor::Axis::SecondaryText)); g.drawFittedText(dbString, labelRect, juce::Justification::right, 1); @@ -1654,7 +1657,7 @@ void Oscilloscope::Background::paintWaveformBackground(juce::Graphics &g) } // Label will go past the end of the scopeRect. - auto labelWidth = font.getStringWidth(timeString); + auto labelWidth = (int)juce::GlyphArrangement::getStringWidth(font, timeString); auto labelRect = juce::Rectangle{labelWidth, labelHeight}.withCentre( juce::Point(xPos, height + 10)); auto justify = juce::Justification::bottom; diff --git a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp index 0ea7e75e4be..45ba9c0b027 100644 --- a/src/surge-xt/gui/overlays/PatchStoreDialog.cpp +++ b/src/surge-xt/gui/overlays/PatchStoreDialog.cpp @@ -106,7 +106,7 @@ struct PatchStoreDialogCategoryProvider : public Surge::Widgets::TypeAheadDataPr return res; } - juce::Font font{12}; + juce::Font font{juce::FontOptions{12}}; juce::Colour hl, hlbg, txt, bg; void paintDataItem(int searchIndex, juce::Graphics &g, int width, int height, diff --git a/src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp b/src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp index 115377d6db3..bd1657537a8 100644 --- a/src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp +++ b/src/surge-xt/gui/widgets/LFOAndStepDisplay.cpp @@ -1390,7 +1390,7 @@ void LFOAndStepDisplay::paintStepSeq(juce::Graphics &g) std::string txt = fmt::format("{:.{}f} %", ss->steps[draggedStep] * 100.f, prec); - int sw = g.getCurrentFont().getStringWidth(txt); + int sw = (int)juce::GlyphArrangement::getStringWidth(g.getCurrentFont(), txt); auto sr = steprect[draggedStep]; diff --git a/src/surge-xt/gui/widgets/MenuCustomComponents.cpp b/src/surge-xt/gui/widgets/MenuCustomComponents.cpp index f1cfc1353c0..dbddff9a462 100644 --- a/src/surge-xt/gui/widgets/MenuCustomComponents.cpp +++ b/src/surge-xt/gui/widgets/MenuCustomComponents.cpp @@ -82,11 +82,8 @@ void MenuTitleHelpComponent::getIdealSize(int &idealWidth, int &idealHeight) { auto standardMenuItemHeight = 25; - juce::Font font; - - auto ft = getLookAndFeel().getPopupMenuFont(); - ft = ft.withHeight(ft.getHeight() - 1); - font = ft; + auto font = getLookAndFeel().getPopupMenuFont(); + font = font.withHeight(font.getHeight() - 1); if (isBoldened) { @@ -99,7 +96,7 @@ void MenuTitleHelpComponent::getIdealSize(int &idealWidth, int &idealHeight) idealHeight = standardMenuItemHeight > 0 ? standardMenuItemHeight : std::round(font.getHeight() * 1.3f); - idealWidth = font.getStringWidth(label) + idealHeight * 2; + idealWidth = (int)juce::GlyphArrangement::getStringWidth(font, label) + idealHeight * 2; idealWidth += 20; } diff --git a/src/surge-xt/gui/widgets/ModulatableControlInterface.h b/src/surge-xt/gui/widgets/ModulatableControlInterface.h index c57df2f4f28..4a4a4d2c9a2 100644 --- a/src/surge-xt/gui/widgets/ModulatableControlInterface.h +++ b/src/surge-xt/gui/widgets/ModulatableControlInterface.h @@ -170,7 +170,7 @@ struct ModulatableControlInterface virtual void setIntStepRange(int i) { intRange = i; } // Font handling. FIXME - implement this - juce::Font font; + juce::Font font{juce::FontOptions()}; virtual void setFont(juce::Font f) { font = f; } virtual void setFontStyle(int x) {} virtual void setTextAlign(juce::Justification x) {} diff --git a/src/surge-xt/gui/widgets/ModulationSourceButton.h b/src/surge-xt/gui/widgets/ModulationSourceButton.h index 358c028a986..9ceabe3059c 100644 --- a/src/surge-xt/gui/widgets/ModulationSourceButton.h +++ b/src/surge-xt/gui/widgets/ModulationSourceButton.h @@ -156,7 +156,7 @@ struct ModulationSourceButton : public juce::Component, repaint(); } - juce::Font font; + juce::Font font{juce::FontOptions()}; void setFont(const juce::Font &f) { diff --git a/src/surge-xt/gui/widgets/MultiSwitch.h b/src/surge-xt/gui/widgets/MultiSwitch.h index e3340c33ef0..2ff737df19b 100644 --- a/src/surge-xt/gui/widgets/MultiSwitch.h +++ b/src/surge-xt/gui/widgets/MultiSwitch.h @@ -137,7 +137,7 @@ struct MultiSwitch : public juce::Component, struct MultiSwitchSelfDraw : public MultiSwitch { MultiSwitchSelfDraw() : MultiSwitch() {} - juce::Font font{36}; + juce::Font font{juce::FontOptions{36}}; void paint(juce::Graphics &g) override; std::vector labels; diff --git a/src/surge-xt/gui/widgets/ParameterInfowindow.cpp b/src/surge-xt/gui/widgets/ParameterInfowindow.cpp index 6fd4e2aac37..c626aec7282 100644 --- a/src/surge-xt/gui/widgets/ParameterInfowindow.cpp +++ b/src/surge-xt/gui/widgets/ParameterInfowindow.cpp @@ -131,9 +131,9 @@ void ParameterInfowindow::setBoundsToAccompany(const juce::Rectangle &contr if (name.empty()) { - auto sl1 = font.getStringWidth(display); - auto sl2 = font.getStringWidth(displayAlt); - auto pad = font.getStringWidth(" "); + auto sl1 = (int)juce::GlyphArrangement::getStringWidth(font, display); + auto sl2 = (int)juce::GlyphArrangement::getStringWidth(font, displayAlt); + auto pad = (int)juce::GlyphArrangement::getStringWidth(font, " "); desiredWidth = std::max(sl1 + sl2 + pad, desiredWidth); } else @@ -144,16 +144,17 @@ void ParameterInfowindow::setBoundsToAccompany(const juce::Rectangle &contr { lheight = font.getHeight() * 3 + 11; // row 2 - auto r1l = font.getStringWidth(name); - auto r2l = - font.getStringWidth(mdiws.dvalminus + " " + mdiws.val + " " + mdiws.dvalplus); - auto r3l = font.getStringWidth(mdiws.valminus + " " + mdiws.valplus); + auto r1l = (int)juce::GlyphArrangement::getStringWidth(font, name); + auto r2l = (int)juce::GlyphArrangement::getStringWidth( + font, mdiws.dvalminus + " " + mdiws.val + " " + mdiws.dvalplus); + auto r3l = (int)juce::GlyphArrangement::getStringWidth(font, mdiws.valminus + " " + + mdiws.valplus); desiredWidth = std::max(std::max(std::max(r1l, r2l), r3l) + 8, desiredWidth); } else { - auto sln = font.getStringWidth(name); - auto sl1 = font.getStringWidth(display); + auto sln = (int)juce::GlyphArrangement::getStringWidth(font, name); + auto sl1 = (int)juce::GlyphArrangement::getStringWidth(font, display); desiredWidth = std::max(std::max(sln, sl1) + 8, desiredWidth); lheight = font.getHeight() * 2 + 9; } diff --git a/src/surge-xt/gui/widgets/ParameterInfowindow.h b/src/surge-xt/gui/widgets/ParameterInfowindow.h index b6437d3bcb0..f5cb101c8eb 100644 --- a/src/surge-xt/gui/widgets/ParameterInfowindow.h +++ b/src/surge-xt/gui/widgets/ParameterInfowindow.h @@ -37,7 +37,7 @@ struct ParameterInfowindow : public juce::Component, public Surge::GUI::SkinCons ParameterInfowindow(); ~ParameterInfowindow(); - juce::Font font; + juce::Font font{juce::FontOptions()}; void setFont(const juce::Font &f) { font = f; diff --git a/src/surge-xt/gui/widgets/PatchSelector.cpp b/src/surge-xt/gui/widgets/PatchSelector.cpp index d68875f19a2..f2b4c5b0ff7 100644 --- a/src/surge-xt/gui/widgets/PatchSelector.cpp +++ b/src/surge-xt/gui/widgets/PatchSelector.cpp @@ -342,13 +342,17 @@ void PatchSelector::paint(juce::Graphics &g) // patch name if (!isTypeaheadSearchOn) { - auto catsz = skin->fontManager->displayFont.getStringWidthFloat(category); - auto authsz = skin->fontManager->displayFont.getStringWidthFloat(author); - - auto catszwith = - skin->fontManager->displayFont.getStringWidthFloat("Category: " + category); - auto authszwith = skin->fontManager->displayFont.getStringWidthFloat("By: " + author); - auto mainsz = skin->fontManager->patchNameFont.getStringWidthFloat(pname); + auto catsz = + juce::GlyphArrangement::getStringWidth(skin->fontManager->displayFont, category); + auto authsz = + juce::GlyphArrangement::getStringWidth(skin->fontManager->displayFont, author); + + auto catszwith = juce::GlyphArrangement::getStringWidth(skin->fontManager->displayFont, + "Category: " + category); + auto authszwith = + juce::GlyphArrangement::getStringWidth(skin->fontManager->displayFont, "By: " + author); + auto mainsz = + juce::GlyphArrangement::getStringWidth(skin->fontManager->patchNameFont, pname); bool useCatAndBy{false}, alignTop{false}; @@ -1564,7 +1568,7 @@ void PatchSelectorCommentTooltip::positionForComment(const juce::Point &cen while (std::getline(ss, to, '\n')) { - auto w = ft.getStringWidthFloat(to); + auto w = juce::GlyphArrangement::getStringWidth(ft, to); // in case of an empty line, we still need to count it as an extra row // so bump it up a bit so that the rows calculation ceils to 1 diff --git a/src/surge-xt/gui/widgets/VerticalLabel.h b/src/surge-xt/gui/widgets/VerticalLabel.h index 0c463d0a874..489535a85b0 100644 --- a/src/surge-xt/gui/widgets/VerticalLabel.h +++ b/src/surge-xt/gui/widgets/VerticalLabel.h @@ -48,7 +48,7 @@ struct VerticalLabel : public juce::Component repaint(); } - juce::Font font; + juce::Font font{juce::FontOptions()}; void setFont(const juce::Font &f) { font = f; diff --git a/x b/x new file mode 100644 index 00000000000..bef181b2f5f --- /dev/null +++ b/x @@ -0,0 +1,27 @@ +src/surge-xt/gui/overlays/PatchStoreDialog.cpp: juce::Font font{12}; +src/surge-xt/gui/overlays/KeyBindingsOverlay.cpp: keyDesc->setFont(juce::Font(10)); +src/surge-xt/gui/SurgeJUCELookAndFeel.h: juce::Font getPopupMenuFont() override; +src/surge-xt/gui/SurgeJUCELookAndFeel.h: juce::Font getPopupMenuBoldFont(); +src/surge-xt/gui/SurgeGUIEditor.cpp: hs->setFont(juce::Font(currentSkin->typeFaces[ff]).withPointHeight(fs)); +src/surge-xt/gui/SkinSupport.cpp: return juce::Font::FontStyleFlags::bold; +src/surge-xt/gui/SkinSupport.cpp: return juce::Font::FontStyleFlags::italic; +src/surge-xt/gui/SkinSupport.cpp: return juce::Font::FontStyleFlags::underlined; +src/surge-xt/gui/SkinSupport.cpp: return juce::Font::FontStyleFlags::plain; +src/surge-xt/gui/SkinSupport.cpp: jassert((int)Surge::Skin::FontDesc::plain == juce::Font::FontStyleFlags::plain); +src/surge-xt/gui/SkinSupport.cpp: jassert((int)Surge::Skin::FontDesc::italic == juce::Font::FontStyleFlags::italic); +src/surge-xt/gui/SkinSupport.cpp: jassert((int)Surge::Skin::FontDesc::bold == juce::Font::FontStyleFlags::bold); +src/surge-xt/gui/SkinSupport.cpp: return juce::Font(typeFaces[fo.family]).withPointHeight(fo.size); +src/surge-xt/gui/SkinSupport.cpp: return juce::Font(fo.family, fo.size, juce::Font::FontStyleFlags::plain); +src/surge-xt/gui/RuntimeFont.h: juce::Font +src/surge-xt/gui/RuntimeFont.h: juce::Font +src/surge-xt/gui/widgets/XMLConfiguredMenus.h: juce::Font::FontStyleFlags font_style{juce::Font::plain}; +src/surge-xt/gui/widgets/MultiSwitch.h: juce::Font font{36}; +src/surge-xt/gui/widgets/ModulationSourceButton.h: juce::Font font; +src/surge-xt/gui/widgets/ParameterInfowindow.h: juce::Font font; +src/surge-xt/gui/widgets/ModulatableControlInterface.h: juce::Font font; +src/surge-xt/gui/widgets/ModulatableControlInterface.h: virtual void setFont(juce::Font f) { font = f; } +src/surge-xt/gui/widgets/VerticalLabel.h: juce::Font font; +src/surge-xt/gui/SurgeJUCELookAndFeel.cpp: auto fontVersion = skin->fontManager->getFiraMonoAtSize(14, juce::Font::bold); +src/surge-xt/gui/SurgeJUCELookAndFeel.cpp:juce::Font SurgeJUCELookAndFeel::getPopupMenuFont() +src/surge-xt/gui/SurgeJUCELookAndFeel.cpp:juce::Font SurgeJUCELookAndFeel::getPopupMenuBoldFont() +src/surge-xt/gui/SurgeJUCELookAndFeel.cpp: // return juce::Font("Comic Sans MS", 15, juce::Font::plain);