diff --git a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt index 029f667b62..37ea4a5039 100644 --- a/examples/DemoRunner/Builds/Android/app/CMakeLists.txt +++ b/examples/DemoRunner/Builds/Android/app/CMakeLists.txt @@ -1857,6 +1857,8 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" @@ -4513,6 +4515,8 @@ set_source_files_properties( "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj index 463945211a..479dea4bce 100644 --- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj +++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj @@ -2169,6 +2169,9 @@ true + + true + true @@ -4381,6 +4384,7 @@ + diff --git a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters index dec6bf36c3..583ae234bd 100644 --- a/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters +++ b/examples/DemoRunner/Builds/VisualStudio2019/DemoRunner_App.vcxproj.filters @@ -2944,6 +2944,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -7455,6 +7458,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj index cdda016df4..93cc9e813a 100644 --- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj +++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj @@ -2169,6 +2169,9 @@ true + + true + true @@ -4381,6 +4384,7 @@ + diff --git a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters index 629f3ddc6f..07401609c0 100644 --- a/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters +++ b/examples/DemoRunner/Builds/VisualStudio2022/DemoRunner_App.vcxproj.filters @@ -2944,6 +2944,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -7455,6 +7458,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt index 85eeaabcc1..cc1da3d5da 100644 --- a/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt +++ b/extras/AudioPerformanceTest/Builds/Android/app/CMakeLists.txt @@ -1619,6 +1619,8 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" @@ -3889,6 +3891,8 @@ set_source_files_properties( "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj index 3f1965ef79..893c8f3e28 100644 --- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj +++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj @@ -1860,6 +1860,9 @@ true + + true + true @@ -3794,6 +3797,7 @@ + diff --git a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters index 5f3f20abb3..66e7235de2 100644 --- a/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters +++ b/extras/AudioPerformanceTest/Builds/VisualStudio2022/AudioPerformanceTest_App.vcxproj.filters @@ -2452,6 +2452,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -6414,6 +6417,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt index 8ac5f5b64a..e39f4103f3 100644 --- a/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt +++ b/extras/AudioPluginHost/Builds/Android/app/CMakeLists.txt @@ -1749,6 +1749,8 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" @@ -4172,6 +4174,8 @@ set_source_files_properties( "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj index b34c80cb2d..12a30867a6 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj +++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj @@ -1994,6 +1994,9 @@ true + + true + true @@ -4027,6 +4030,7 @@ + diff --git a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters index 5b98dd4f4c..70e8c2c67f 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters +++ b/extras/AudioPluginHost/Builds/VisualStudio2019/AudioPluginHost_App.vcxproj.filters @@ -2659,6 +2659,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -6849,6 +6852,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj index 0196bd9f3d..9e9320959a 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj +++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj @@ -1994,6 +1994,9 @@ true + + true + true @@ -4027,6 +4030,7 @@ + diff --git a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters index aa47ad15a3..4dad07db53 100644 --- a/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters +++ b/extras/AudioPluginHost/Builds/VisualStudio2022/AudioPluginHost_App.vcxproj.filters @@ -2659,6 +2659,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -6849,6 +6852,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt index 88cd727775..527d16e1c9 100644 --- a/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt +++ b/extras/NetworkGraphicsDemo/Builds/Android/app/CMakeLists.txt @@ -1638,6 +1638,8 @@ add_library( ${BINARY_NAME} "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" @@ -3988,6 +3990,8 @@ set_source_files_properties( "../../../../../modules/juce_graphics/fonts/juce_FunctionPointerDestructor.h" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.cpp" "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangement.h" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp" + "../../../../../modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h" "../../../../../modules/juce_graphics/fonts/juce_LruCache.h" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.cpp" "../../../../../modules/juce_graphics/fonts/juce_TextLayout.h" diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj index 870c6182f8..09c825e796 100644 --- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj +++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj @@ -1881,6 +1881,9 @@ true + + true + true @@ -3892,6 +3895,7 @@ + diff --git a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters index c3db5dc64a..89d1fd7b02 100644 --- a/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters +++ b/extras/NetworkGraphicsDemo/Builds/VisualStudio2022/NetworkGraphicsDemo_App.vcxproj.filters @@ -2506,6 +2506,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -6576,6 +6579,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj index 13875b50ac..b76097d88f 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj @@ -1023,6 +1023,9 @@ true + + true + true @@ -2592,6 +2595,7 @@ + diff --git a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters index 93f0ea36b1..d33ebde60e 100644 --- a/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2019/Projucer_App.vcxproj.filters @@ -1345,6 +1345,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -4218,6 +4221,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj index fa7f1b6b61..4ce609118f 100644 --- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj +++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj @@ -1023,6 +1023,9 @@ true + + true + true @@ -2592,6 +2595,7 @@ + diff --git a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters index 7f68454775..b2c35f95b9 100644 --- a/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters +++ b/extras/Projucer/Builds/VisualStudio2022/Projucer_App.vcxproj.filters @@ -1345,6 +1345,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -4218,6 +4221,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj index 3346d55ba0..e9dd17b043 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj +++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj @@ -2002,6 +2002,9 @@ true + + true + true @@ -4139,6 +4142,7 @@ + diff --git a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters index 982a6a149f..41ab333f30 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters +++ b/extras/UnitTestRunner/Builds/VisualStudio2019/UnitTestRunner_ConsoleApp.vcxproj.filters @@ -2707,6 +2707,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -7008,6 +7011,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj index 0ad82e37d4..619a842e7f 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj +++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj @@ -2002,6 +2002,9 @@ true + + true + true @@ -4139,6 +4142,7 @@ + diff --git a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters index c56b183ef9..575159195e 100644 --- a/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters +++ b/extras/UnitTestRunner/Builds/VisualStudio2022/UnitTestRunner_ConsoleApp.vcxproj.filters @@ -2707,6 +2707,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -7008,6 +7011,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj index 52c5e2fe73..ab305f38d5 100644 --- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj +++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj @@ -1880,6 +1880,9 @@ true + + true + true @@ -3868,6 +3871,7 @@ + diff --git a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters index 0512ee58ff..03cf355dc1 100644 --- a/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters +++ b/extras/WindowsDLL/Builds/VisualStudio2022/WindowsDLL_DynamicLibrary.vcxproj.filters @@ -2503,6 +2503,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts @@ -6543,6 +6546,9 @@ JUCE Modules\juce_graphics\fonts + + JUCE Modules\juce_graphics\fonts + JUCE Modules\juce_graphics\fonts diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp index 519015fdc3..e2fd079f45 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.cpp +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.cpp @@ -461,14 +461,26 @@ void Graphics::drawText (const String& text, int x, int y, int width, int height void Graphics::drawFittedText (const String& text, Rectangle area, Justification justification, const int maximumNumberOfLines, - const float minimumHorizontalScale) const + const float minimumHorizontalScale, + GlyphArrangementOptions options) const { if (text.isEmpty() || area.isEmpty() || ! context.clipRegionIntersects (area)) return; struct ArrangementArgs { - auto tie() const noexcept { return std::tie (font, text, width, height, justification, maximumNumberOfLines, minimumHorizontalScale); } + auto tie() const noexcept + { + return std::tie (font, + text, + width, + height, + justification, + maximumNumberOfLines, + minimumHorizontalScale, + options); + } + bool operator< (const ArrangementArgs& other) const noexcept { return tie() < other.tie(); } const Font font; @@ -478,6 +490,7 @@ void Graphics::drawFittedText (const String& text, Rectangle area, const Justification justification; const int maximumNumberOfLines; const float minimumHorizontalScale; + GlyphArrangementOptions options; }; auto configureArrangement = [] (const ArrangementArgs& args) @@ -488,7 +501,8 @@ void Graphics::drawFittedText (const String& text, Rectangle area, args.width, args.height, args.justification, args.maximumNumberOfLines, - args.minimumHorizontalScale); + args.minimumHorizontalScale, + args.options); return arrangement; }; @@ -498,7 +512,8 @@ void Graphics::drawFittedText (const String& text, Rectangle area, (float) area.getHeight(), justification, maximumNumberOfLines, - minimumHorizontalScale }; + minimumHorizontalScale, + options }; using Cache = GlyphArrangementCache; Cache::getInstance()->get (std::move (args), std::move (configureArrangement)) @@ -509,10 +524,11 @@ void Graphics::drawFittedText (const String& text, Rectangle area, void Graphics::drawFittedText (const String& text, int x, int y, int width, int height, Justification justification, const int maximumNumberOfLines, - const float minimumHorizontalScale) const + const float minimumHorizontalScale, + GlyphArrangementOptions options) const { drawFittedText (text, coordsToRectangle (x, y, width, height), - justification, maximumNumberOfLines, minimumHorizontalScale); + justification, maximumNumberOfLines, minimumHorizontalScale, options); } //============================================================================== diff --git a/modules/juce_graphics/contexts/juce_GraphicsContext.h b/modules/juce_graphics/contexts/juce_GraphicsContext.h index 465c705438..7aa57a7bfc 100644 --- a/modules/juce_graphics/contexts/juce_GraphicsContext.h +++ b/modules/juce_graphics/contexts/juce_GraphicsContext.h @@ -220,7 +220,8 @@ public: int x, int y, int width, int height, Justification justificationFlags, int maximumNumberOfLines, - float minimumHorizontalScale = 0.0f) const; + float minimumHorizontalScale = 0.0f, + GlyphArrangementOptions options = {}) const; /** Tries to draw a text string inside a given space. @@ -245,7 +246,8 @@ public: Rectangle area, Justification justificationFlags, int maximumNumberOfLines, - float minimumHorizontalScale = 0.0f) const; + float minimumHorizontalScale = 0.0f, + GlyphArrangementOptions options = {}) const; //============================================================================== /** Fills the context's entire clip region with the current colour or brush. diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp index 2b6721b5f2..94f38550bc 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.cpp @@ -242,7 +242,7 @@ static auto createFittedText (const Font& f, Justification layout, int maximumLines, float minimumRelativeHorizontalScale, - detail::ShapedText::Options baseOptions = {}) + detail::ShapedText::Options baseOptions) { using namespace detail; @@ -451,6 +451,13 @@ static auto createFittedText (const Font& f, return candidate.shapedText; } +static detail::ShapedText::Options withGlyphArrangementOptions (const detail::ShapedText::Options& opts, + const GlyphArrangementOptions& gaOpts) +{ + return opts.withAdditiveLineSpacing (gaOpts.getLineSpacing()) + .withLeading (gaOpts.getLineHeightMultiple()); +} + void GlyphArrangement::addFittedText (const Font& f, const String& text, float x, @@ -459,9 +466,19 @@ void GlyphArrangement::addFittedText (const Font& f, float height, Justification layout, int maximumLines, - float minimumHorizontalScale) + float minimumHorizontalScale, + GlyphArrangementOptions options) { - const auto st = createFittedText (f, text, width, height, layout, maximumLines, minimumHorizontalScale); + using namespace detail; + + const auto st = createFittedText (f, + text, + width, + height, + layout, + maximumLines, + minimumHorizontalScale, + withGlyphArrangementOptions (ShapedText::Options{}, options)); // ShapedText has the feature for visually truncating the last line, and createFittedText() uses // it. Hence if it's only the last line that requires a larger width, ShapedText will take care @@ -481,7 +498,8 @@ void GlyphArrangement::addFittedText (const Font& f, layout, maximumLines, minimumHorizontalScale, - detail::ShapedText::Options{}.withAllowBreakingInsideWord()); + withGlyphArrangementOptions (ShapedText::Options{}.withAllowBreakingInsideWord(), + options)); addGlyphsFromShapedText (*this, stWithWordBreaks, x, y); } diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangement.h b/modules/juce_graphics/fonts/juce_GlyphArrangement.h index d8c03e3e05..8d7e7476dc 100644 --- a/modules/juce_graphics/fonts/juce_GlyphArrangement.h +++ b/modules/juce_graphics/fonts/juce_GlyphArrangement.h @@ -224,7 +224,8 @@ public: float x, float y, float width, float height, Justification layout, int maximumLinesToUse, - float minimumHorizontalScale = 0.0f); + float minimumHorizontalScale = 0.0f, + GlyphArrangementOptions options = {}); /** Appends another glyph arrangement to this one. */ void addGlyphArrangement (const GlyphArrangement&); diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp b/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp new file mode 100644 index 0000000000..5c74747b4f --- /dev/null +++ b/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.cpp @@ -0,0 +1,50 @@ +/* + ============================================================================== + + This file is part of the JUCE framework. + Copyright (c) Raw Material Software Limited + + JUCE is an open source framework subject to commercial or open source + licensing. + + By downloading, installing, or using the JUCE framework, or combining the + JUCE framework with any other source code, object code, content or any other + copyrightable work, you agree to the terms of the JUCE End User Licence + Agreement, and all incorporated terms including the JUCE Privacy Policy and + the JUCE Website Terms of Service, as applicable, which will bind you. If you + do not agree to the terms of these agreements, we will not license the JUCE + framework to you, and you must discontinue the installation or download + process and cease use of the JUCE framework. + + JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/ + JUCE Privacy Policy: https://juce.com/juce-privacy-policy + JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/ + + Or: + + You may also use this code under the terms of the AGPLv3: + https://www.gnu.org/licenses/agpl-3.0.en.html + + THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL + WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +auto GlyphArrangementOptions::tie() const noexcept +{ + return std::tie (lineSpacing, lineHeightMultiple); +} + +bool GlyphArrangementOptions::operator== (const GlyphArrangementOptions& other) const { return tie() == other.tie(); } +bool GlyphArrangementOptions::operator!= (const GlyphArrangementOptions& other) const { return tie() != other.tie(); } +bool GlyphArrangementOptions::operator< (const GlyphArrangementOptions& other) const { return tie() < other.tie(); } +bool GlyphArrangementOptions::operator<= (const GlyphArrangementOptions& other) const { return tie() <= other.tie(); } +bool GlyphArrangementOptions::operator> (const GlyphArrangementOptions& other) const { return tie() > other.tie(); } +bool GlyphArrangementOptions::operator>= (const GlyphArrangementOptions& other) const { return tie() >= other.tie(); } + +} // namespace juce diff --git a/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h b/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h new file mode 100644 index 0000000000..168ad90096 --- /dev/null +++ b/modules/juce_graphics/fonts/juce_GlyphArrangementOptions.h @@ -0,0 +1,95 @@ +/* + ============================================================================== + + This file is part of the JUCE framework. + Copyright (c) Raw Material Software Limited + + JUCE is an open source framework subject to commercial or open source + licensing. + + By downloading, installing, or using the JUCE framework, or combining the + JUCE framework with any other source code, object code, content or any other + copyrightable work, you agree to the terms of the JUCE End User Licence + Agreement, and all incorporated terms including the JUCE Privacy Policy and + the JUCE Website Terms of Service, as applicable, which will bind you. If you + do not agree to the terms of these agreements, we will not license the JUCE + framework to you, and you must discontinue the installation or download + process and cease use of the JUCE framework. + + JUCE End User Licence Agreement: https://juce.com/legal/juce-8-licence/ + JUCE Privacy Policy: https://juce.com/juce-privacy-policy + JUCE Website Terms of Service: https://juce.com/juce-website-terms-of-service/ + + Or: + + You may also use this code under the terms of the AGPLv3: + https://www.gnu.org/licenses/agpl-3.0.en.html + + THE JUCE FRAMEWORK IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL + WARRANTIES, WHETHER EXPRESSED OR IMPLIED, INCLUDING WARRANTY OF + MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ARE DISCLAIMED. + + ============================================================================== +*/ + +namespace juce +{ + +/** Options that can be used to affect the layout produced by GlyphArrangement::addFittedText. + + @see GlyphArrangement::addFittedText +*/ +class GlyphArrangementOptions +{ +public: + /** We increment the distance between the baselines of subsequent lines with this value. + + Line spacing is added below the line's descender, and doesn't affect the first line's + baseline. + + The total distance between baselines is lineHeight * lineHeightMultiple + lineSpacing. + */ + [[nodiscard]] GlyphArrangementOptions withLineSpacing (float x) const + { + return withMember (*this, &GlyphArrangementOptions::lineSpacing, x); + } + + /** We multiply the original distance between the baselines of subsequent lines with this value. + + The line height multiple is applied to both the ascender and descender, hence it affects + the first line's baseline. + + The total distance between baselines is lineHeight * lineHeightMultiple + lineSpacing. + */ + [[nodiscard]] GlyphArrangementOptions withLineHeightMultiple (float x) const + { + return withMember (*this, &GlyphArrangementOptions::lineHeightMultiple, x); + } + + /** @see withLineSpacing() */ + const auto& getLineSpacing() const { return lineSpacing; } + + /** @see withLineHeightMultiple() */ + const auto& getLineHeightMultiple() const { return lineHeightMultiple; } + + /** Equality operator. */ + [[nodiscard]] bool operator== (const GlyphArrangementOptions& other) const; + /** Inequality operator. */ + [[nodiscard]] bool operator!= (const GlyphArrangementOptions& other) const; + /** Less-than operator. Allows GlyphArrangementOptions to be used as keys in a map. */ + [[nodiscard]] bool operator< (const GlyphArrangementOptions& other) const; + /** Less-than-or-equal operator. */ + [[nodiscard]] bool operator<= (const GlyphArrangementOptions& other) const; + /** Greater-than operator. */ + [[nodiscard]] bool operator> (const GlyphArrangementOptions& other) const; + /** Greater-than-or-equal operator. */ + [[nodiscard]] bool operator>= (const GlyphArrangementOptions& other) const; + +private: + auto tie() const noexcept; + + float lineSpacing = 0.0f; + float lineHeightMultiple = 1.0f; +}; + +} // namespace juce diff --git a/modules/juce_graphics/juce_graphics.cpp b/modules/juce_graphics/juce_graphics.cpp index fd984f2be0..80db67eba0 100644 --- a/modules/juce_graphics/juce_graphics.cpp +++ b/modules/juce_graphics/juce_graphics.cpp @@ -199,6 +199,7 @@ extern "C" #include "detail/juce_SimpleShapedText.cpp" #include "detail/juce_JustifiedText.cpp" #include "detail/juce_ShapedText.cpp" +#include "fonts/juce_GlyphArrangementOptions.cpp" #include "fonts/juce_GlyphArrangement.cpp" #include "fonts/juce_TextLayout.cpp" #include "effects/juce_DropShadowEffect.cpp" diff --git a/modules/juce_graphics/juce_graphics.h b/modules/juce_graphics/juce_graphics.h index 90f48c4bda..aec2075586 100644 --- a/modules/juce_graphics/juce_graphics.h +++ b/modules/juce_graphics/juce_graphics.h @@ -131,6 +131,7 @@ namespace juce #include "images/juce_ImageCache.h" #include "images/juce_ImageConvolutionKernel.h" #include "images/juce_ImageFileFormat.h" +#include "fonts/juce_GlyphArrangementOptions.h" #include "contexts/juce_GraphicsContext.h" #include "images/juce_Image.h" #include "colour/juce_FillType.h"